Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: ebtables: replace zero-length array members

As suggested by Kees[1], replace the old-style 0-element array members
of multiple structs in ebtables.h with modern C99 flexible array.

[1]: https://lore.kernel.org/all/5E8E0F9C-EE3F-4B0D-B827-DC47397E2A4A@kernel.org/

[ fw@strlen.de:
keep struct ebt_entry_target as-is, causes compiler warning:
"variable sized type 'struct ebt_entry_target' not at the end of a
struct or class is a GNU extension" ]

Link: https://github.com/KSPP/linux/issues/21
Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Florian Westphal <fw@strlen.de>

authored by

GONG, Ruiqi and committed by
Florian Westphal
a2f02c99 a7ed3465

+4 -4
+4 -4
include/uapi/linux/netfilter_bridge/ebtables.h
··· 87 87 /* nr. of entries */ 88 88 unsigned int nentries; 89 89 /* entry list */ 90 - char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); 90 + char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); 91 91 }; 92 92 93 93 /* used for the bitmask of struct ebt_entry */ ··· 129 129 } u; 130 130 /* size of data */ 131 131 unsigned int match_size; 132 - unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); 132 + unsigned char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); 133 133 }; 134 134 135 135 struct ebt_entry_watcher { ··· 142 142 } u; 143 143 /* size of data */ 144 144 unsigned int watcher_size; 145 - unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); 145 + unsigned char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); 146 146 }; 147 147 148 148 struct ebt_entry_target { ··· 190 190 /* sizeof ebt_entry + matches + watchers + target */ 191 191 unsigned int next_offset; 192 192 ); 193 - unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); 193 + unsigned char elems[] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); 194 194 }; 195 195 196 196 static __inline__ struct ebt_entry_target *