bpf: enforce correct alignment for instructions

After commit 9facc33687 ("bpf: reject any prog that failed read-only lock")
offsetof(struct bpf_binary_header, image) became 3 instead of 4,
breaking powerpc BPF badly, since instructions need to be word aligned.

Fixes: 9facc33687 ("bpf: reject any prog that failed read-only lock")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Eric Dumazet 2018-06-20 17:24:09 -07:00 committed by David S. Miller
parent 08d02364b1
commit 9262478220
1 changed files with 3 additions and 1 deletions

View File

@ -472,7 +472,9 @@ struct sock_fprog_kern {
struct bpf_binary_header {
u16 pages;
u16 locked:1;
u8 image[];
/* Some arches need word alignment for their instructions */
u8 image[] __aligned(4);
};
struct bpf_prog {