lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aQ9-F34aW__rlMuD@fedora>
Date: Sat, 8 Nov 2025 22:59:59 +0530
From: Ankit Khushwaha <ankitkhushwaha.linux@...il.com>
To: Simon Horman <horms@...nel.org>
Cc: Steffen Klassert <steffen.klassert@...unet.com>,
	Herbert Xu <herbert@...dor.apana.org.au>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Shuah Khan <shuah@...nel.org>,
	Willem de Bruijn <willemdebruijn.kernel@...il.com>,
	Jason Xing <kernelxing@...cent.com>, netdev@...r.kernel.org,
	linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-kernel-mentees@...ts.linuxfoundation.org
Subject: Re: [PATCH] selftest: net: fix variable sized type not at the end of
 struct warnings

On Tue, Oct 28, 2025 at 05:23:12PM +0000, Simon Horman wrote:
> On Mon, Oct 27, 2025 at 10:38:56AM +0530, Ankit Khushwaha wrote:
> > Some network selftests defined variable-sized types defined at the end of
> > struct causing -Wgnu-variable-sized-type-not-at-end warning.
> > 
> > warning:
> > timestamping.c:285:18: warning: field 'cm' with variable sized type 
> > 'struct cmsghdr' not at the end of a struct or class is a GNU 
> > extension [-Wgnu-variable-sized-type-not-at-end]
> >   285 |                 struct cmsghdr cm;
> >       |                                ^
> > 
> > ipsec.c:835:5: warning: field 'u' with variable sized type 'union 
> > (unnamed union at ipsec.c:831:3)' not at the end of a struct or class 
> > is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
> >   835 |                 } u;
> >       |                   ^
> > 
> > This patch move these field at the end of struct to fix these warnings.
> > 
> > Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@...il.com>
> 
> Hi Ankit,
> 
> I don't believe this change is correct.
> 
> I think that the intention of the code is the char arrays (buf and control)
> provide the buffer space for the variable-length trailing field
> of the preceding structure. Where we basically have a header followed
> by data. But your patch would place the before the header.
>
Hi Simon,
So if buf and control providing the buffer space, then i think it is
better to suppress `-Wgnu-variable-sized-type-not-at-end` warning 
within this block of code.

	#pragma GCC diagnostic push
	#pragma GCC diagnostic ignored "-Wgnu-variable-sized-type-not-at-end"

	struct {
		union {
			struct xfrm_algo        alg;
			struct xfrm_algo_aead   aead;
			struct xfrm_algo_auth   auth;
		} u;
		char buf[XFRM_ALGO_KEY_BUF_SIZE];
	} alg = {};

	#pragma GCC diagnostic pop

I think this would be fine.

Thanks
-- Ankit

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ