From: Eric Dumazet <edumazet@google.com>
Date: Wed, 20 Jun 2018 17:24:09 -0700
Subject: bpf: enforce correct alignment for instructions
Patch-mainline: v4.18-rc3
Git-commit: 9262478220eac908ae6e168c3df2c453c87e2da3
References: bsc#1109837
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>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
include/linux/filter.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -474,7 +474,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 {