Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

parisc: fix unaligned accesses in BPF

There were spurious unaligned access warnings when calling BPF code.
Sometimes, the warnings were triggered with any incoming packet, making
the machine hard to use.

The reason for the warnings is this: on parisc64, pointers to functions
are not really pointers to functions, they are pointers to 16-byte
descriptor. The first 8 bytes of the descriptor is a pointer to the
function and the next 8 bytes of the descriptor is the content of the
"dp" register. This descriptor is generated in the function
bpf_jit_build_prologue.

The problem is that the function bpf_int_jit_compile advertises 4-byte
alignment when calling bpf_jit_binary_alloc, bpf_jit_binary_alloc
randomizes the returned array and if the array happens to be not aligned
on 8-byte boundary, the descriptor generated in bpf_jit_build_prologue is
also not aligned and this triggers the unaligned access warning.

Fix this by advertising 8-byte alignment on parisc64 when calling
bpf_jit_binary_alloc.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Mikulas Patocka and committed by
Helge Deller
1fd2c10a 8400291e

+1 -1
+1 -1
arch/parisc/net/bpf_jit_core.c
··· 114 114 jit_data->header = 115 115 bpf_jit_binary_alloc(prog_size + extable_size, 116 116 &jit_data->image, 117 - sizeof(u32), 117 + sizeof(long), 118 118 bpf_fill_ill_insns); 119 119 if (!jit_data->header) { 120 120 prog = orig_prog;