Skip to contentSkip to conversation

xfrm: convert alg_key to flexible array member

RFC In review Stephen Hemminger 3 participants 4 messages May 24, 2022 – Jun 23, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 xfrm: convert alg_key to flexible array member

Iproute2 build generates a warning when built with gcc-12. This is because the alg_key in xfrm.h API has zero size array element instead of flexible array.

CC xfrm_state.o
In function ‘xfrm_algo_parse’,
inlined from ‘xfrm_state_modify.constprop’ at xfrm_state.c:573:5:
xfrm_state.c:162:32: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]

  162 |                         buf[j] = val;
      |                         ~~~~~~~^~~~~

This patch convert the alg_key into flexible array member. There are other zero size arrays here that should be converted as well.

This patch is RFC only since it is only compile tested and passes trivial iproute2 tests.

---
 include/uapi/linux/xfrm.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
include/uapi/linux/xfrm.h +3 -3
index 65e13a099b1a..3ed61df9cc91 100644
@@ -102,21 +102,21 @@ struct xfrm_replay_state_esn {
 struct xfrm_algo {
 	char		alg_name[64];
 	unsigned int	alg_key_len;    /* in bits */
-	char		alg_key[0];
+	char		alg_key[];
 };
 
 struct xfrm_algo_auth {
 	char		alg_name[64];
 	unsigned int	alg_key_len;    /* in bits */
 	unsigned int	alg_trunc_len;  /* in bits */
-	char		alg_key[0];
+	char		alg_key[];
 };
 
 struct xfrm_algo_aead {
 	char		alg_name[64];
 	unsigned int	alg_key_len;	/* in bits */
 	unsigned int	alg_icv_len;	/* in bits */
-	char		alg_key[0];
+	char		alg_key[];
 };
 
 struct xfrm_stats {
Signature · 1 line
2.35.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Stephen Hemminger

Iproute2 build generates a warning when built with gcc-12. This is because the alg_key in xfrm.h API has zero size array element instead of flexible array.

CC xfrm_state.o
In function ‘xfrm_algo_parse’,
inlined from ‘xfrm_state_modify.constprop’ at xfrm_state.c:573:5:
xfrm_state.c:162:32: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]

  162 |                         buf[j] = val;
      |                         ~~~~~~~^~~~~

This patch convert the alg_key into flexible array member. There are other zero size arrays here that should be converted as well.

Quoted 7 lines

This patch is RFC only since it is only compile tested and passes trivial iproute2 tests.

---
 include/uapi/linux/xfrm.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#2 lore raw
In reply to Stephen Hemminger
Quoted 11 lines · Stephen Hemminger

Iproute2 build generates a warning when built with gcc-12. This is because the alg_key in xfrm.h API has zero size array element instead of flexible array.

CC xfrm_state.o
In function ‘xfrm_algo_parse’,
inlined from ‘xfrm_state_modify.constprop’ at xfrm_state.c:573:5:
xfrm_state.c:162:32: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]

  162 |                         buf[j] = val;
      |                         ~~~~~~~^~~~~
Quoted 8 lines

This patch convert the alg_key into flexible array member. There are other zero size arrays here that should be converted as well.

This patch is RFC only since it is only compile tested and passes trivial iproute2 tests.

I've put this today to our test systems and it showed no problems, so we can integrate it after the merge window.

maintainer
#3 lore raw
Quoted 16 lines · Steffen Klassert
Quoted 15 lines · Stephen Hemminger

Iproute2 build generates a warning when built with gcc-12. This is because the alg_key in xfrm.h API has zero size array element instead of flexible array.

CC xfrm_state.o
In function ‘xfrm_algo_parse’,
inlined from ‘xfrm_state_modify.constprop’ at xfrm_state.c:573:5:
xfrm_state.c:162:32: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]

  162 |                         buf[j] = val;
      |                         ~~~~~~~^~~~~

This patch convert the alg_key into flexible array member. There are other zero size arrays here that should be converted as well.

Quoted 7 lines
Quoted 4 lines

This patch is RFC only since it is only compile tested and passes trivial iproute2 tests.

I've put this today to our test systems and it showed no problems, so we can integrate it after the merge window.

This is now applied to ipsec-next, thanks!