bpf: enforce correct alignment for instructions
authorEric Dumazet <edumazet@google.com>
Thu, 21 Jun 2018 00:24:09 +0000 (17:24 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Jun 2018 03:46:06 +0000 (12:46 +0900)
After commit 9facc336876f ("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: 9facc336876f ("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>
include/linux/filter.h

index b615df57b7d5b2ccb468c411c3a2aae103cd2aea..20f2659dd829256d7fef206087ab3262e1e291f5 100644 (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 {