All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] xfrm: convert alg_key to flexible array member
@ 2022-05-24 20:47 Stephen Hemminger
  2022-05-25  0:15 ` Herbert Xu
  2022-06-02 10:45 ` Steffen Klassert
  0 siblings, 2 replies; 4+ messages in thread
From: Stephen Hemminger @ 2022-05-24 20:47 UTC (permalink / raw)
  To: netdev
  Cc: Stephen Hemminger, Steffen Klassert, Herbert Xu, David S. Miller,
	open list

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.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 include/uapi/linux/xfrm.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
index 65e13a099b1a..3ed61df9cc91 100644
--- a/include/uapi/linux/xfrm.h
+++ b/include/uapi/linux/xfrm.h
@@ -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 {
-- 
2.35.1


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

* Re: [RFC] xfrm: convert alg_key to flexible array member
  2022-05-24 20:47 [RFC] xfrm: convert alg_key to flexible array member Stephen Hemminger
@ 2022-05-25  0:15 ` Herbert Xu
  2022-06-02 10:45 ` Steffen Klassert
  1 sibling, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2022-05-25  0:15 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, Steffen Klassert, David S. Miller, open list

On Tue, May 24, 2022 at 01:47:40PM -0700, Stephen Hemminger wrote:
> 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.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  include/uapi/linux/xfrm.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [RFC] xfrm: convert alg_key to flexible array member
  2022-05-24 20:47 [RFC] xfrm: convert alg_key to flexible array member Stephen Hemminger
  2022-05-25  0:15 ` Herbert Xu
@ 2022-06-02 10:45 ` Steffen Klassert
  2022-06-23 10:49   ` Steffen Klassert
  1 sibling, 1 reply; 4+ messages in thread
From: Steffen Klassert @ 2022-06-02 10:45 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, Herbert Xu, David S. Miller, open list

On Tue, May 24, 2022 at 01:47:40PM -0700, Stephen Hemminger wrote:
> 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.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

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

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

* Re: [RFC] xfrm: convert alg_key to flexible array member
  2022-06-02 10:45 ` Steffen Klassert
@ 2022-06-23 10:49   ` Steffen Klassert
  0 siblings, 0 replies; 4+ messages in thread
From: Steffen Klassert @ 2022-06-23 10:49 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, Herbert Xu, David S. Miller, open list

On Thu, Jun 02, 2022 at 12:45:15PM +0200, Steffen Klassert wrote:
> On Tue, May 24, 2022 at 01:47:40PM -0700, Stephen Hemminger wrote:
> > 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.
> > 
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> 
> 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!

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

end of thread, other threads:[~2022-06-23 10:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-24 20:47 [RFC] xfrm: convert alg_key to flexible array member Stephen Hemminger
2022-05-25  0:15 ` Herbert Xu
2022-06-02 10:45 ` Steffen Klassert
2022-06-23 10:49   ` Steffen Klassert

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.