All of lore.kernel.org
 help / color / mirror / Atom feed
* [nf-next PATCH v2] netfilter: include: uapi: Use C99 flexible array member
@ 2020-07-19 10:02 Phil Sutter
  2020-07-19 15:34 ` Gustavo A. R. Silva
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Phil Sutter @ 2020-07-19 10:02 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, Gustavo A . R . Silva

Recent versions of gcc started to complain about the old-style
zero-length array as last member of various structs. For instance, while
compiling iptables:

| In file included from /usr/include/string.h:495,
|                  from libip4tc.c:15:
| In function 'memcpy',
|     inlined from 'iptcc_compile_chain' at libiptc.c:1172:2,
|     inlined from 'iptcc_compile_table' at libiptc.c:1243:13,
|     inlined from 'iptc_commit' at libiptc.c:2572:8,
|     inlined from 'iptc_commit' at libiptc.c:2510:1:
| /usr/include/bits/string_fortified.h:34:10: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
|    34 |   return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
|       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In file included from ../include/libiptc/libiptc.h:12,
|                  from libip4tc.c:29:
| libiptc.c: In function 'iptc_commit':
| ../include/linux/netfilter_ipv4/ip_tables.h:202:19: note: at offset 0 to object 'entries' with size 0 declared here
|   202 |  struct ipt_entry entries[0];
|       |                   ^~~~~~~

(Similar for libip6tc.c.)

Avoid this warning by declaring these fields as an ISO C99 flexible
array member. This makes gcc aware of the intended use and enables
sanity checking as described in:
https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html

This patch is actually a follow-up on commit 6daf14140129d ("netfilter:
Replace zero-length array with flexible-array member") which seems to
have missed a few spots. Like it, alignment attribute syntax is fixed
where found in line with zero-length array fields.

Cc: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
Changes since v1:
- Fix up any zero-length arrays found via:
  `grep -r '\[0\]' include/uapi/linux/netfilter*`.
- Perform alignment attribute syntax fixup just like 6daf14140129d does.
- Point at relationship with 6daf14140129d in commit message.
- Add Gustavo to Cc: for verification.
---
 include/uapi/linux/netfilter/x_tables.h         |  6 +++---
 include/uapi/linux/netfilter_arp/arp_tables.h   |  6 +++---
 include/uapi/linux/netfilter_bridge/ebt_among.h |  2 +-
 include/uapi/linux/netfilter_bridge/ebtables.h  | 10 +++++-----
 include/uapi/linux/netfilter_ipv4/ip_tables.h   |  6 +++---
 include/uapi/linux/netfilter_ipv6/ip6_tables.h  |  6 +++---
 6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/include/uapi/linux/netfilter/x_tables.h b/include/uapi/linux/netfilter/x_tables.h
index a8283f7dbc519..7a52c69c74a2b 100644
--- a/include/uapi/linux/netfilter/x_tables.h
+++ b/include/uapi/linux/netfilter/x_tables.h
@@ -28,7 +28,7 @@ struct xt_entry_match {
 		__u16 match_size;
 	} u;
 
-	unsigned char data[0];
+	unsigned char data[];
 };
 
 struct xt_entry_target {
@@ -51,7 +51,7 @@ struct xt_entry_target {
 		__u16 target_size;
 	} u;
 
-	unsigned char data[0];
+	unsigned char data[];
 };
 
 #define XT_TARGET_INIT(__name, __size)					       \
@@ -119,7 +119,7 @@ struct xt_counters_info {
 	unsigned int num_counters;
 
 	/* The counters (actually `number' of these). */
-	struct xt_counters counters[0];
+	struct xt_counters counters[];
 };
 
 #define XT_INV_PROTO		0x40	/* Invert the sense of PROTO. */
diff --git a/include/uapi/linux/netfilter_arp/arp_tables.h b/include/uapi/linux/netfilter_arp/arp_tables.h
index bbf5af2b67a8f..a6ac2463f787a 100644
--- a/include/uapi/linux/netfilter_arp/arp_tables.h
+++ b/include/uapi/linux/netfilter_arp/arp_tables.h
@@ -109,7 +109,7 @@ struct arpt_entry
 	struct xt_counters counters;
 
 	/* The matches (if any), then the target. */
-	unsigned char elems[0];
+	unsigned char elems[];
 };
 
 /*
@@ -181,7 +181,7 @@ struct arpt_replace {
 	struct xt_counters __user *counters;
 
 	/* The entries (hang off end: not really an array). */
-	struct arpt_entry entries[0];
+	struct arpt_entry entries[];
 };
 
 /* The argument to ARPT_SO_GET_ENTRIES. */
@@ -193,7 +193,7 @@ struct arpt_get_entries {
 	unsigned int size;
 
 	/* The entries. */
-	struct arpt_entry entrytable[0];
+	struct arpt_entry entrytable[];
 };
 
 /* Helper functions */
diff --git a/include/uapi/linux/netfilter_bridge/ebt_among.h b/include/uapi/linux/netfilter_bridge/ebt_among.h
index 9acf757bc1f79..73b26a280c4fd 100644
--- a/include/uapi/linux/netfilter_bridge/ebt_among.h
+++ b/include/uapi/linux/netfilter_bridge/ebt_among.h
@@ -40,7 +40,7 @@ struct ebt_mac_wormhash_tuple {
 struct ebt_mac_wormhash {
 	int table[257];
 	int poolsize;
-	struct ebt_mac_wormhash_tuple pool[0];
+	struct ebt_mac_wormhash_tuple pool[];
 };
 
 #define ebt_mac_wormhash_size(x) ((x) ? sizeof(struct ebt_mac_wormhash) \
diff --git a/include/uapi/linux/netfilter_bridge/ebtables.h b/include/uapi/linux/netfilter_bridge/ebtables.h
index a494cf43a7552..0b4f8994a0a54 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[] __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[] __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[] __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[] __aligned(__alignof__(struct ebt_replace));
 };
 
 #define EBT_STANDARD_TARGET "standard"
@@ -188,7 +188,7 @@ struct ebt_entry {
 	unsigned int target_offset;
 	/* sizeof ebt_entry + matches + watchers + target */
 	unsigned int next_offset;
-	unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
+	unsigned char elems[] __aligned(__alignof__(struct ebt_replace));
 };
 
 static __inline__ struct ebt_entry_target *
diff --git a/include/uapi/linux/netfilter_ipv4/ip_tables.h b/include/uapi/linux/netfilter_ipv4/ip_tables.h
index 50c7fee625ae9..1485df28b2391 100644
--- a/include/uapi/linux/netfilter_ipv4/ip_tables.h
+++ b/include/uapi/linux/netfilter_ipv4/ip_tables.h
@@ -121,7 +121,7 @@ struct ipt_entry {
 	struct xt_counters counters;
 
 	/* The matches (if any), then the target. */
-	unsigned char elems[0];
+	unsigned char elems[];
 };
 
 /*
@@ -203,7 +203,7 @@ struct ipt_replace {
 	struct xt_counters __user *counters;
 
 	/* The entries (hang off end: not really an array). */
-	struct ipt_entry entries[0];
+	struct ipt_entry entries[];
 };
 
 /* The argument to IPT_SO_GET_ENTRIES. */
@@ -215,7 +215,7 @@ struct ipt_get_entries {
 	unsigned int size;
 
 	/* The entries. */
-	struct ipt_entry entrytable[0];
+	struct ipt_entry entrytable[];
 };
 
 /* Helper functions */
diff --git a/include/uapi/linux/netfilter_ipv6/ip6_tables.h b/include/uapi/linux/netfilter_ipv6/ip6_tables.h
index d9e364f96a5cf..d4d7f47d9104d 100644
--- a/include/uapi/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/uapi/linux/netfilter_ipv6/ip6_tables.h
@@ -125,7 +125,7 @@ struct ip6t_entry {
 	struct xt_counters counters;
 
 	/* The matches (if any), then the target. */
-	unsigned char elems[0];
+	unsigned char elems[];
 };
 
 /* Standard entry */
@@ -243,7 +243,7 @@ struct ip6t_replace {
 	struct xt_counters __user *counters;
 
 	/* The entries (hang off end: not really an array). */
-	struct ip6t_entry entries[0];
+	struct ip6t_entry entries[];
 };
 
 /* The argument to IP6T_SO_GET_ENTRIES. */
@@ -255,7 +255,7 @@ struct ip6t_get_entries {
 	unsigned int size;
 
 	/* The entries. */
-	struct ip6t_entry entrytable[0];
+	struct ip6t_entry entrytable[];
 };
 
 /* Helper functions */
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [nf-next PATCH v2] netfilter: include: uapi: Use C99 flexible array member
  2020-07-19 10:02 [nf-next PATCH v2] netfilter: include: uapi: Use C99 flexible array member Phil Sutter
@ 2020-07-19 15:34 ` Gustavo A. R. Silva
  2020-07-20 11:26   ` Phil Sutter
  2020-07-20  3:22   ` kernel test robot
  2020-07-20  3:41   ` kernel test robot
  2 siblings, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2020-07-19 15:34 UTC (permalink / raw)
  To: Phil Sutter, Pablo Neira Ayuso; +Cc: netfilter-devel

Hi,

Please, see this:

https://git.kernel.org/linus/1e6e9d0f4859ec698d55381ea26f4136eff3afe1

We are refraining from doing flexible-array conversions in UAPI, for now.

--
Gustavo

On 7/19/20 05:02, Phil Sutter wrote:
> Recent versions of gcc started to complain about the old-style
> zero-length array as last member of various structs. For instance, while
> compiling iptables:
> 
> | In file included from /usr/include/string.h:495,
> |                  from libip4tc.c:15:
> | In function 'memcpy',
> |     inlined from 'iptcc_compile_chain' at libiptc.c:1172:2,
> |     inlined from 'iptcc_compile_table' at libiptc.c:1243:13,
> |     inlined from 'iptc_commit' at libiptc.c:2572:8,
> |     inlined from 'iptc_commit' at libiptc.c:2510:1:
> | /usr/include/bits/string_fortified.h:34:10: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
> |    34 |   return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
> |       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> | In file included from ../include/libiptc/libiptc.h:12,
> |                  from libip4tc.c:29:
> | libiptc.c: In function 'iptc_commit':
> | ../include/linux/netfilter_ipv4/ip_tables.h:202:19: note: at offset 0 to object 'entries' with size 0 declared here
> |   202 |  struct ipt_entry entries[0];
> |       |                   ^~~~~~~
> 
> (Similar for libip6tc.c.)
> 
> Avoid this warning by declaring these fields as an ISO C99 flexible
> array member. This makes gcc aware of the intended use and enables
> sanity checking as described in:
> https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
> 
> This patch is actually a follow-up on commit 6daf14140129d ("netfilter:
> Replace zero-length array with flexible-array member") which seems to
> have missed a few spots. Like it, alignment attribute syntax is fixed
> where found in line with zero-length array fields.
> 
> Cc: Gustavo A. R. Silva <gustavo@embeddedor.com>
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
> Changes since v1:
> - Fix up any zero-length arrays found via:
>   `grep -r '\[0\]' include/uapi/linux/netfilter*`.
> - Perform alignment attribute syntax fixup just like 6daf14140129d does.
> - Point at relationship with 6daf14140129d in commit message.
> - Add Gustavo to Cc: for verification.
> ---
>  include/uapi/linux/netfilter/x_tables.h         |  6 +++---
>  include/uapi/linux/netfilter_arp/arp_tables.h   |  6 +++---
>  include/uapi/linux/netfilter_bridge/ebt_among.h |  2 +-
>  include/uapi/linux/netfilter_bridge/ebtables.h  | 10 +++++-----
>  include/uapi/linux/netfilter_ipv4/ip_tables.h   |  6 +++---
>  include/uapi/linux/netfilter_ipv6/ip6_tables.h  |  6 +++---
>  6 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/include/uapi/linux/netfilter/x_tables.h b/include/uapi/linux/netfilter/x_tables.h
> index a8283f7dbc519..7a52c69c74a2b 100644
> --- a/include/uapi/linux/netfilter/x_tables.h
> +++ b/include/uapi/linux/netfilter/x_tables.h
> @@ -28,7 +28,7 @@ struct xt_entry_match {
>  		__u16 match_size;
>  	} u;
>  
> -	unsigned char data[0];
> +	unsigned char data[];
>  };
>  
>  struct xt_entry_target {
> @@ -51,7 +51,7 @@ struct xt_entry_target {
>  		__u16 target_size;
>  	} u;
>  
> -	unsigned char data[0];
> +	unsigned char data[];
>  };
>  
>  #define XT_TARGET_INIT(__name, __size)					       \
> @@ -119,7 +119,7 @@ struct xt_counters_info {
>  	unsigned int num_counters;
>  
>  	/* The counters (actually `number' of these). */
> -	struct xt_counters counters[0];
> +	struct xt_counters counters[];
>  };
>  
>  #define XT_INV_PROTO		0x40	/* Invert the sense of PROTO. */
> diff --git a/include/uapi/linux/netfilter_arp/arp_tables.h b/include/uapi/linux/netfilter_arp/arp_tables.h
> index bbf5af2b67a8f..a6ac2463f787a 100644
> --- a/include/uapi/linux/netfilter_arp/arp_tables.h
> +++ b/include/uapi/linux/netfilter_arp/arp_tables.h
> @@ -109,7 +109,7 @@ struct arpt_entry
>  	struct xt_counters counters;
>  
>  	/* The matches (if any), then the target. */
> -	unsigned char elems[0];
> +	unsigned char elems[];
>  };
>  
>  /*
> @@ -181,7 +181,7 @@ struct arpt_replace {
>  	struct xt_counters __user *counters;
>  
>  	/* The entries (hang off end: not really an array). */
> -	struct arpt_entry entries[0];
> +	struct arpt_entry entries[];
>  };
>  
>  /* The argument to ARPT_SO_GET_ENTRIES. */
> @@ -193,7 +193,7 @@ struct arpt_get_entries {
>  	unsigned int size;
>  
>  	/* The entries. */
> -	struct arpt_entry entrytable[0];
> +	struct arpt_entry entrytable[];
>  };
>  
>  /* Helper functions */
> diff --git a/include/uapi/linux/netfilter_bridge/ebt_among.h b/include/uapi/linux/netfilter_bridge/ebt_among.h
> index 9acf757bc1f79..73b26a280c4fd 100644
> --- a/include/uapi/linux/netfilter_bridge/ebt_among.h
> +++ b/include/uapi/linux/netfilter_bridge/ebt_among.h
> @@ -40,7 +40,7 @@ struct ebt_mac_wormhash_tuple {
>  struct ebt_mac_wormhash {
>  	int table[257];
>  	int poolsize;
> -	struct ebt_mac_wormhash_tuple pool[0];
> +	struct ebt_mac_wormhash_tuple pool[];
>  };
>  
>  #define ebt_mac_wormhash_size(x) ((x) ? sizeof(struct ebt_mac_wormhash) \
> diff --git a/include/uapi/linux/netfilter_bridge/ebtables.h b/include/uapi/linux/netfilter_bridge/ebtables.h
> index a494cf43a7552..0b4f8994a0a54 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[] __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[] __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[] __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[] __aligned(__alignof__(struct ebt_replace));
>  };
>  
>  #define EBT_STANDARD_TARGET "standard"
> @@ -188,7 +188,7 @@ struct ebt_entry {
>  	unsigned int target_offset;
>  	/* sizeof ebt_entry + matches + watchers + target */
>  	unsigned int next_offset;
> -	unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
> +	unsigned char elems[] __aligned(__alignof__(struct ebt_replace));
>  };
>  
>  static __inline__ struct ebt_entry_target *
> diff --git a/include/uapi/linux/netfilter_ipv4/ip_tables.h b/include/uapi/linux/netfilter_ipv4/ip_tables.h
> index 50c7fee625ae9..1485df28b2391 100644
> --- a/include/uapi/linux/netfilter_ipv4/ip_tables.h
> +++ b/include/uapi/linux/netfilter_ipv4/ip_tables.h
> @@ -121,7 +121,7 @@ struct ipt_entry {
>  	struct xt_counters counters;
>  
>  	/* The matches (if any), then the target. */
> -	unsigned char elems[0];
> +	unsigned char elems[];
>  };
>  
>  /*
> @@ -203,7 +203,7 @@ struct ipt_replace {
>  	struct xt_counters __user *counters;
>  
>  	/* The entries (hang off end: not really an array). */
> -	struct ipt_entry entries[0];
> +	struct ipt_entry entries[];
>  };
>  
>  /* The argument to IPT_SO_GET_ENTRIES. */
> @@ -215,7 +215,7 @@ struct ipt_get_entries {
>  	unsigned int size;
>  
>  	/* The entries. */
> -	struct ipt_entry entrytable[0];
> +	struct ipt_entry entrytable[];
>  };
>  
>  /* Helper functions */
> diff --git a/include/uapi/linux/netfilter_ipv6/ip6_tables.h b/include/uapi/linux/netfilter_ipv6/ip6_tables.h
> index d9e364f96a5cf..d4d7f47d9104d 100644
> --- a/include/uapi/linux/netfilter_ipv6/ip6_tables.h
> +++ b/include/uapi/linux/netfilter_ipv6/ip6_tables.h
> @@ -125,7 +125,7 @@ struct ip6t_entry {
>  	struct xt_counters counters;
>  
>  	/* The matches (if any), then the target. */
> -	unsigned char elems[0];
> +	unsigned char elems[];
>  };
>  
>  /* Standard entry */
> @@ -243,7 +243,7 @@ struct ip6t_replace {
>  	struct xt_counters __user *counters;
>  
>  	/* The entries (hang off end: not really an array). */
> -	struct ip6t_entry entries[0];
> +	struct ip6t_entry entries[];
>  };
>  
>  /* The argument to IP6T_SO_GET_ENTRIES. */
> @@ -255,7 +255,7 @@ struct ip6t_get_entries {
>  	unsigned int size;
>  
>  	/* The entries. */
> -	struct ip6t_entry entrytable[0];
> +	struct ip6t_entry entrytable[];
>  };
>  
>  /* Helper functions */
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [nf-next PATCH v2] netfilter: include: uapi: Use C99 flexible array member
  2020-07-19 10:02 [nf-next PATCH v2] netfilter: include: uapi: Use C99 flexible array member Phil Sutter
@ 2020-07-20  3:22   ` kernel test robot
  2020-07-20  3:22   ` kernel test robot
  2020-07-20  3:41   ` kernel test robot
  2 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2020-07-20  3:22 UTC (permalink / raw)
  To: Phil Sutter, Pablo Neira Ayuso
  Cc: kbuild-all, netfilter-devel, Gustavo A . R . Silva

[-- Attachment #1: Type: text/plain, Size: 2199 bytes --]

Hi Phil,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on nf-next/master]

url:    https://github.com/0day-ci/linux/commits/Phil-Sutter/netfilter-include-uapi-Use-C99-flexible-array-member/20200719-180355
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master
config: x86_64-randconfig-s022-20200719 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-49-g707c5017-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from <command-line>:32:
>> ./usr/include/linux/netfilter_bridge/ebtables.h:90:14: error: expected ':', ',', ';', '}' or '__attribute__' before '__aligned'
      90 |  char data[] __aligned(__alignof__(struct ebt_replace));
         |              ^~~~~~~~~
   ./usr/include/linux/netfilter_bridge/ebtables.h:132:23: error: expected ':', ',', ';', '}' or '__attribute__' before '__aligned'
     132 |  unsigned char data[] __aligned(__alignof__(struct ebt_replace));
         |                       ^~~~~~~~~
   ./usr/include/linux/netfilter_bridge/ebtables.h:145:23: error: expected ':', ',', ';', '}' or '__attribute__' before '__aligned'
     145 |  unsigned char data[] __aligned(__alignof__(struct ebt_replace));
         |                       ^~~~~~~~~
   ./usr/include/linux/netfilter_bridge/ebtables.h:158:23: error: expected ':', ',', ';', '}' or '__attribute__' before '__aligned'
     158 |  unsigned char data[] __aligned(__alignof__(struct ebt_replace));
         |                       ^~~~~~~~~
   ./usr/include/linux/netfilter_bridge/ebtables.h:191:24: error: expected ':', ',', ';', '}' or '__attribute__' before '__aligned'
     191 |  unsigned char elems[] __aligned(__alignof__(struct ebt_replace));
         |                        ^~~~~~~~~

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33371 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [nf-next PATCH v2] netfilter: include: uapi: Use C99 flexible array member
@ 2020-07-20  3:22   ` kernel test robot
  0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2020-07-20  3:22 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2242 bytes --]

Hi Phil,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on nf-next/master]

url:    https://github.com/0day-ci/linux/commits/Phil-Sutter/netfilter-include-uapi-Use-C99-flexible-array-member/20200719-180355
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master
config: x86_64-randconfig-s022-20200719 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-49-g707c5017-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from <command-line>:32:
>> ./usr/include/linux/netfilter_bridge/ebtables.h:90:14: error: expected ':', ',', ';', '}' or '__attribute__' before '__aligned'
      90 |  char data[] __aligned(__alignof__(struct ebt_replace));
         |              ^~~~~~~~~
   ./usr/include/linux/netfilter_bridge/ebtables.h:132:23: error: expected ':', ',', ';', '}' or '__attribute__' before '__aligned'
     132 |  unsigned char data[] __aligned(__alignof__(struct ebt_replace));
         |                       ^~~~~~~~~
   ./usr/include/linux/netfilter_bridge/ebtables.h:145:23: error: expected ':', ',', ';', '}' or '__attribute__' before '__aligned'
     145 |  unsigned char data[] __aligned(__alignof__(struct ebt_replace));
         |                       ^~~~~~~~~
   ./usr/include/linux/netfilter_bridge/ebtables.h:158:23: error: expected ':', ',', ';', '}' or '__attribute__' before '__aligned'
     158 |  unsigned char data[] __aligned(__alignof__(struct ebt_replace));
         |                       ^~~~~~~~~
   ./usr/include/linux/netfilter_bridge/ebtables.h:191:24: error: expected ':', ',', ';', '}' or '__attribute__' before '__aligned'
     191 |  unsigned char elems[] __aligned(__alignof__(struct ebt_replace));
         |                        ^~~~~~~~~

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33371 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [nf-next PATCH v2] netfilter: include: uapi: Use C99 flexible array member
  2020-07-19 10:02 [nf-next PATCH v2] netfilter: include: uapi: Use C99 flexible array member Phil Sutter
@ 2020-07-20  3:41   ` kernel test robot
  2020-07-20  3:22   ` kernel test robot
  2020-07-20  3:41   ` kernel test robot
  2 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2020-07-20  3:41 UTC (permalink / raw)
  To: Phil Sutter, Pablo Neira Ayuso
  Cc: kbuild-all, clang-built-linux, netfilter-devel, Gustavo A . R . Silva

[-- Attachment #1: Type: text/plain, Size: 4937 bytes --]

Hi Phil,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on nf-next/master]

url:    https://github.com/0day-ci/linux/commits/Phil-Sutter/netfilter-include-uapi-Use-C99-flexible-array-member/20200719-180355
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 3504acc33e8b9ddd7de71d75cdc329a14dbf58d9)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from <built-in>:1:
>> ./usr/include/linux/netfilter_bridge/ebtables.h:90:13: error: expected ';' at end of declaration list
           char data[] __aligned(__alignof__(struct ebt_replace));
                      ^
                      ;
   ./usr/include/linux/netfilter_bridge/ebtables.h:132:22: error: expected ';' at end of declaration list
           unsigned char data[] __aligned(__alignof__(struct ebt_replace));
                               ^
                               ;
   ./usr/include/linux/netfilter_bridge/ebtables.h:145:22: error: expected ';' at end of declaration list
           unsigned char data[] __aligned(__alignof__(struct ebt_replace));
                               ^
                               ;
   ./usr/include/linux/netfilter_bridge/ebtables.h:158:22: error: expected ';' at end of declaration list
           unsigned char data[] __aligned(__alignof__(struct ebt_replace));
                               ^
                               ;
>> ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct ebt_entry_target target;
                                   ^
   ./usr/include/linux/netfilter_bridge/ebtables.h:191:23: error: expected ';' at end of declaration list
           unsigned char elems[] __aligned(__alignof__(struct ebt_replace));
                                ^
                                ;
   1 warning and 5 errors generated.
--
   In file included from <built-in>:1:
   In file included from ./usr/include/linux/netfilter_ipv6/ip6_tables.h:24:
>> ./usr/include/linux/netfilter/x_tables.h:66:25: warning: field 'target' with variable sized type 'struct xt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct xt_entry_target target;
                                  ^
   ./usr/include/linux/netfilter/x_tables.h:71:25: warning: field 'target' with variable sized type 'struct xt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct xt_entry_target target;
                                  ^
   In file included from <built-in>:1:
>> ./usr/include/linux/netfilter_ipv6/ip6_tables.h:131:20: warning: field 'entry' with variable sized type 'struct ip6t_entry' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct ip6t_entry entry;
                             ^
   ./usr/include/linux/netfilter_ipv6/ip6_tables.h:136:20: warning: field 'entry' with variable sized type 'struct ip6t_entry' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct ip6t_entry entry;
                             ^
   4 warnings generated.
--
   In file included from <built-in>:1:
   In file included from ./usr/include/linux/netfilter_arp/arpt_mangle.h:4:
   In file included from ./usr/include/linux/netfilter_arp/arp_tables.h:18:
>> ./usr/include/linux/netfilter/x_tables.h:66:25: warning: field 'target' with variable sized type 'struct xt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct xt_entry_target target;
                                  ^
   ./usr/include/linux/netfilter/x_tables.h:71:25: warning: field 'target' with variable sized type 'struct xt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct xt_entry_target target;
                                  ^
   2 warnings generated.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 75346 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [nf-next PATCH v2] netfilter: include: uapi: Use C99 flexible array member
@ 2020-07-20  3:41   ` kernel test robot
  0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2020-07-20  3:41 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5019 bytes --]

Hi Phil,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on nf-next/master]

url:    https://github.com/0day-ci/linux/commits/Phil-Sutter/netfilter-include-uapi-Use-C99-flexible-array-member/20200719-180355
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 3504acc33e8b9ddd7de71d75cdc329a14dbf58d9)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from <built-in>:1:
>> ./usr/include/linux/netfilter_bridge/ebtables.h:90:13: error: expected ';' at end of declaration list
           char data[] __aligned(__alignof__(struct ebt_replace));
                      ^
                      ;
   ./usr/include/linux/netfilter_bridge/ebtables.h:132:22: error: expected ';' at end of declaration list
           unsigned char data[] __aligned(__alignof__(struct ebt_replace));
                               ^
                               ;
   ./usr/include/linux/netfilter_bridge/ebtables.h:145:22: error: expected ';' at end of declaration list
           unsigned char data[] __aligned(__alignof__(struct ebt_replace));
                               ^
                               ;
   ./usr/include/linux/netfilter_bridge/ebtables.h:158:22: error: expected ';' at end of declaration list
           unsigned char data[] __aligned(__alignof__(struct ebt_replace));
                               ^
                               ;
>> ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct ebt_entry_target target;
                                   ^
   ./usr/include/linux/netfilter_bridge/ebtables.h:191:23: error: expected ';' at end of declaration list
           unsigned char elems[] __aligned(__alignof__(struct ebt_replace));
                                ^
                                ;
   1 warning and 5 errors generated.
--
   In file included from <built-in>:1:
   In file included from ./usr/include/linux/netfilter_ipv6/ip6_tables.h:24:
>> ./usr/include/linux/netfilter/x_tables.h:66:25: warning: field 'target' with variable sized type 'struct xt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct xt_entry_target target;
                                  ^
   ./usr/include/linux/netfilter/x_tables.h:71:25: warning: field 'target' with variable sized type 'struct xt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct xt_entry_target target;
                                  ^
   In file included from <built-in>:1:
>> ./usr/include/linux/netfilter_ipv6/ip6_tables.h:131:20: warning: field 'entry' with variable sized type 'struct ip6t_entry' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct ip6t_entry entry;
                             ^
   ./usr/include/linux/netfilter_ipv6/ip6_tables.h:136:20: warning: field 'entry' with variable sized type 'struct ip6t_entry' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct ip6t_entry entry;
                             ^
   4 warnings generated.
--
   In file included from <built-in>:1:
   In file included from ./usr/include/linux/netfilter_arp/arpt_mangle.h:4:
   In file included from ./usr/include/linux/netfilter_arp/arp_tables.h:18:
>> ./usr/include/linux/netfilter/x_tables.h:66:25: warning: field 'target' with variable sized type 'struct xt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct xt_entry_target target;
                                  ^
   ./usr/include/linux/netfilter/x_tables.h:71:25: warning: field 'target' with variable sized type 'struct xt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
           struct xt_entry_target target;
                                  ^
   2 warnings generated.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 75346 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [nf-next PATCH v2] netfilter: include: uapi: Use C99 flexible array member
  2020-07-19 15:34 ` Gustavo A. R. Silva
@ 2020-07-20 11:26   ` Phil Sutter
  0 siblings, 0 replies; 7+ messages in thread
From: Phil Sutter @ 2020-07-20 11:26 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Pablo Neira Ayuso, netfilter-devel

Hi Gustavo,

On Sun, Jul 19, 2020 at 10:34:01AM -0500, Gustavo A. R. Silva wrote:
> Please, see this:
> 
> https://git.kernel.org/linus/1e6e9d0f4859ec698d55381ea26f4136eff3afe1
> 
> We are refraining from doing flexible-array conversions in UAPI, for now.

Oh, thanks for clarifying. Still, gcc spits out warnings about it when
compiling iptables. I see several options and their downsides:

- Convert iptables' copy of UAPI headers only and maintain the
  divergence in future.

- Compile iptables with -Wno-stringop-overflow, losing the checks in
  valid cases.

Not sure if we may just define that we know how structs in ip_tables.h
and ip6_tables.h are (supposed to) being used and just change it anyway.

BTW: The commit above link points at mentions structs possibly being
embedded as the rationale for keeping things as-is. Yet structs
ipt_entry and ip6t_entry are already embedded into other structs within
the same header file. Seems like gcc is fine with that as long as they
occupy the last field. And that even if they are declared as zero-length
array themselves, which means indexes can't be used to address
individual items.

Cheers, Phil

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-20 11:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-19 10:02 [nf-next PATCH v2] netfilter: include: uapi: Use C99 flexible array member Phil Sutter
2020-07-19 15:34 ` Gustavo A. R. Silva
2020-07-20 11:26   ` Phil Sutter
2020-07-20  3:22 ` kernel test robot
2020-07-20  3:22   ` kernel test robot
2020-07-20  3:41 ` kernel test robot
2020-07-20  3:41   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.