From: Eric Dumazet Date: Thu, 21 Jun 2018 00:24:09 +0000 (-0700) Subject: bpf: enforce correct alignment for instructions X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=9262478220eac908ae6e168c3df2c453c87e2da3;p=linux.git bpf: enforce correct alignment for instructions 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 Cc: Daniel Borkmann Cc: Martin KaFai Lau Cc: Alexei Starovoitov Signed-off-by: David S. Miller --- diff --git a/include/linux/filter.h b/include/linux/filter.h index b615df57b7d5b..20f2659dd8292 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -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 {