* [PATCH] netfilter: ebtables: replace zero-length array members
@ 2023-08-09  7:51 GONG, Ruiqi
  2023-08-09 11:03 ` Phil Sutter
  2023-08-10 20:18 ` Kees Cook
  0 siblings, 2 replies; 3+ messages in thread
From: GONG, Ruiqi @ 2023-08-09  7:51 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	Roopa Prabhu, Nikolay Aleksandrov, Kees Cook,
	Gustavo A . R . Silva
  Cc: netfilter-devel, coreteam, netdev, linux-hardening, linux-kernel,
	Wang Weiyang, Xiu Jianfeng, gongruiqi1
From: "GONG, Ruiqi" <gongruiqi1@huawei.com>
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/
Link: https://github.com/KSPP/linux/issues/21
Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
---
 include/uapi/linux/netfilter_bridge/ebtables.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/uapi/linux/netfilter_bridge/ebtables.h b/include/uapi/linux/netfilter_bridge/ebtables.h
index b0caad82b693..673b00df162c 100644
--- a/include/uapi/linux/netfilter_bridge/ebtables.h
+++ b/include/uapi/linux/netfilter_bridge/ebtables.h
@@ -87,7 +87,7 @@ struct ebt_entries {
 	/* nr. of entries */
 	unsigned int nentries;
 	/* entry list */
-	char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
+	char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
 };
 
 /* used for the bitmask of struct ebt_entry */
@@ -129,7 +129,7 @@ struct ebt_entry_match {
 	} u;
 	/* size of data */
 	unsigned int match_size;
-	unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
+	unsigned char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
 };
 
 struct ebt_entry_watcher {
@@ -142,7 +142,7 @@ struct ebt_entry_watcher {
 	} u;
 	/* size of data */
 	unsigned int watcher_size;
-	unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
+	unsigned char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
 };
 
 struct ebt_entry_target {
@@ -155,7 +155,7 @@ struct ebt_entry_target {
 	} u;
 	/* size of data */
 	unsigned int target_size;
-	unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
+	unsigned char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
 };
 
 #define EBT_STANDARD_TARGET "standard"
@@ -190,7 +190,7 @@ struct ebt_entry {
 		/* sizeof ebt_entry + matches + watchers + target */
 		unsigned int next_offset;
 	);
-	unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
+	unsigned char elems[] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
 };
 
 static __inline__ struct ebt_entry_target *
-- 
2.41.0
^ permalink raw reply related	[flat|nested] 3+ messages in thread- * Re: [PATCH] netfilter: ebtables: replace zero-length array members
  2023-08-09  7:51 [PATCH] netfilter: ebtables: replace zero-length array members GONG, Ruiqi
@ 2023-08-09 11:03 ` Phil Sutter
  2023-08-10 20:18 ` Kees Cook
  1 sibling, 0 replies; 3+ messages in thread
From: Phil Sutter @ 2023-08-09 11:03 UTC (permalink / raw)
  To: GONG, Ruiqi
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	Roopa Prabhu, Nikolay Aleksandrov, Kees Cook,
	Gustavo A . R . Silva, netfilter-devel, coreteam, netdev,
	linux-hardening, linux-kernel, Wang Weiyang, Xiu Jianfeng,
	gongruiqi1
On Wed, Aug 09, 2023 at 03:51:36PM +0800, GONG, Ruiqi wrote:
> From: "GONG, Ruiqi" <gongruiqi1@huawei.com>
> 
> 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/
> 
> Link: https://github.com/KSPP/linux/issues/21
> Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
I tried this once[1], but it was rejected pointing at a revert[2]. It
seems gcc was improved since then: The warning is gone and I don't find
-Wno-stringop-overflow flag in iptables sources.
Cheers, Phil
[1] https://lore.kernel.org/all/20200719100220.4666-1-phil@nwl.cc/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1e6e9d0f4859ec698d55381ea26f4136eff3afe1
^ permalink raw reply	[flat|nested] 3+ messages in thread 
- * Re: [PATCH] netfilter: ebtables: replace zero-length array members
  2023-08-09  7:51 [PATCH] netfilter: ebtables: replace zero-length array members GONG, Ruiqi
  2023-08-09 11:03 ` Phil Sutter
@ 2023-08-10 20:18 ` Kees Cook
  1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2023-08-10 20:18 UTC (permalink / raw)
  To: GONG, Ruiqi
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	Roopa Prabhu, Nikolay Aleksandrov, Gustavo A . R . Silva,
	netfilter-devel, coreteam, netdev, linux-hardening, linux-kernel,
	Wang Weiyang, Xiu Jianfeng, gongruiqi1
On Wed, Aug 09, 2023 at 03:51:36PM +0800, GONG, Ruiqi wrote:
> From: "GONG, Ruiqi" <gongruiqi1@huawei.com>
> 
> 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/
> 
> Link: https://github.com/KSPP/linux/issues/21
> Signed-off-by: GONG, Ruiqi <gongruiqi1@huawei.com>
In theory, this should be fine. It is possible there are userspace tools
that are doing (already) buggy things that will now turn into build
failures. If the userspace ebtable tools still build happily with these
UAPI changes, I imagine that would be a sufficient test.
Reviewed-by: Kees Cook <keescook@chromium.org>
-- 
Kees Cook
^ permalink raw reply	[flat|nested] 3+ messages in thread 
end of thread, other threads:[~2023-08-10 20:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09  7:51 [PATCH] netfilter: ebtables: replace zero-length array members GONG, Ruiqi
2023-08-09 11:03 ` Phil Sutter
2023-08-10 20:18 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).