aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/filter.h
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2020-04-30 23:30:47 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2020-05-04 22:54:42 +0200
commitd26c0cc53950464a24adfa76867f1d71f0cbbea6 (patch)
tree31d9b92c73807fe11c553dbbf5b78770f8fa15d7 /include/linux/filter.h
parentbpf, arm: Optimize ALU ARSH K using asr immediate instruction (diff)
downloadwireguard-linux-d26c0cc53950464a24adfa76867f1d71f0cbbea6.tar.xz
wireguard-linux-d26c0cc53950464a24adfa76867f1d71f0cbbea6.zip
bpf: Avoid gcc-10 stringop-overflow warning in struct bpf_prog
gcc-10 warns about accesses to zero-length arrays: kernel/bpf/core.c: In function 'bpf_patch_insn_single': cc1: warning: writing 8 bytes into a region of size 0 [-Wstringop-overflow=] In file included from kernel/bpf/core.c:21: include/linux/filter.h:550:20: note: at offset 0 to object 'insnsi' with size 0 declared here 550 | struct bpf_insn insnsi[0]; | ^~~~~~ In this case, we really want to have two flexible-array members, but that is not possible. Removing the union to make insnsi a flexible-array member while leaving insns as a zero-length array fixes the warning, as nothing writes to the other one in that way. This trick only works on linux-3.18 or higher, as older versions had additional members in the union. Fixes: 60a3b2253c41 ("net: bpf: make eBPF interpreter images read-only") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20200430213101.135134-6-arnd@arndb.de
Diffstat (limited to 'include/linux/filter.h')
-rw-r--r--include/linux/filter.h6
1 files changed, 2 insertions, 4 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h
index af37318bb1c5..73d06a39e2d6 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -545,10 +545,8 @@ struct bpf_prog {
unsigned int (*bpf_func)(const void *ctx,
const struct bpf_insn *insn);
/* Instructions for interpreter */
- union {
- struct sock_filter insns[0];
- struct bpf_insn insnsi[0];
- };
+ struct sock_filter insns[0];
+ struct bpf_insn insnsi[];
};
struct sk_filter {