* [PATCH][next] tls: Avoid -Wflex-array-member-not-at-end warning
@ 2025-09-22 14:39 Gustavo A. R. Silva
2025-09-22 15:21 ` Sabrina Dubroca
0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2025-09-22 14:39 UTC (permalink / raw)
To: John Fastabend, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman
Cc: netdev, linux-kernel, Gustavo A. R. Silva, linux-hardening
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.
Use the new TRAILING_OVERLAP() helper to fix the following warning:
net/tls/tls.h:131:29: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
This helper creates a union between a flexible-array member (FAM)
and a set of members that would otherwise follow it. This overlays
the trailing members onto the FAM while preserving the original
memory layout.
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
net/tls/tls.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/tls/tls.h b/net/tls/tls.h
index 4e077068e6d9..d06435d186c0 100644
--- a/net/tls/tls.h
+++ b/net/tls/tls.h
@@ -128,8 +128,9 @@ struct tls_rec {
char aad_space[TLS_AAD_SPACE_SIZE];
u8 iv_data[TLS_MAX_IV_SIZE];
- struct aead_request aead_req;
- u8 aead_req_ctx[];
+ TRAILING_OVERLAP(struct aead_request, aead_req, __ctx,
+ u8 aead_req_ctx[];
+ );
};
int __net_init tls_proc_init(struct net *net);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH][next] tls: Avoid -Wflex-array-member-not-at-end warning
2025-09-22 14:39 [PATCH][next] tls: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
@ 2025-09-22 15:21 ` Sabrina Dubroca
2025-09-23 9:37 ` Gustavo A. R. Silva
0 siblings, 1 reply; 5+ messages in thread
From: Sabrina Dubroca @ 2025-09-22 15:21 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: John Fastabend, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, netdev, linux-kernel, linux-hardening
2025-09-22, 16:39:20 +0200, Gustavo A. R. Silva wrote:
> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> getting ready to enable it, globally.
>
> Use the new TRAILING_OVERLAP() helper to fix the following warning:
>
> net/tls/tls.h:131:29: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
>
> This helper creates a union between a flexible-array member (FAM)
> and a set of members that would otherwise follow it. This overlays
> the trailing members onto the FAM while preserving the original
> memory layout.
Do we need to keep aead_req_ctx in tls_rec? It doesn't seem to be
used, and I don't see it ever being used since it was introduced in
commit a42055e8d2c3 ("net/tls: Add support for async encryption of
records for performance").
--
Sabrina
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH][next] tls: Avoid -Wflex-array-member-not-at-end warning
2025-09-22 15:21 ` Sabrina Dubroca
@ 2025-09-23 9:37 ` Gustavo A. R. Silva
2025-09-23 20:27 ` Sabrina Dubroca
0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2025-09-23 9:37 UTC (permalink / raw)
To: Sabrina Dubroca, Gustavo A. R. Silva
Cc: John Fastabend, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, netdev, linux-kernel, linux-hardening
On 9/22/25 17:21, Sabrina Dubroca wrote:
> 2025-09-22, 16:39:20 +0200, Gustavo A. R. Silva wrote:
>> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
>> getting ready to enable it, globally.
>>
>> Use the new TRAILING_OVERLAP() helper to fix the following warning:
>>
>> net/tls/tls.h:131:29: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
>>
>> This helper creates a union between a flexible-array member (FAM)
>> and a set of members that would otherwise follow it. This overlays
>> the trailing members onto the FAM while preserving the original
>> memory layout.
>
> Do we need to keep aead_req_ctx in tls_rec? It doesn't seem to be
> used, and I don't see it ever being used since it was introduced in
> commit a42055e8d2c3 ("net/tls: Add support for async encryption of
> records for performance").
If this (flex array) is not going to be needed in the future, I'm
happy to remove it. :)
Thanks
-Gustavo
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH][next] tls: Avoid -Wflex-array-member-not-at-end warning
2025-09-23 9:37 ` Gustavo A. R. Silva
@ 2025-09-23 20:27 ` Sabrina Dubroca
2025-09-23 20:53 ` Gustavo A. R. Silva
0 siblings, 1 reply; 5+ messages in thread
From: Sabrina Dubroca @ 2025-09-23 20:27 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Gustavo A. R. Silva, John Fastabend, Jakub Kicinski,
David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman, netdev,
linux-kernel, linux-hardening
2025-09-23, 11:37:55 +0200, Gustavo A. R. Silva wrote:
>
>
> On 9/22/25 17:21, Sabrina Dubroca wrote:
> > 2025-09-22, 16:39:20 +0200, Gustavo A. R. Silva wrote:
> > > -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> > > getting ready to enable it, globally.
> > >
> > > Use the new TRAILING_OVERLAP() helper to fix the following warning:
> > >
> > > net/tls/tls.h:131:29: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> > >
> > > This helper creates a union between a flexible-array member (FAM)
> > > and a set of members that would otherwise follow it. This overlays
> > > the trailing members onto the FAM while preserving the original
> > > memory layout.
> >
> > Do we need to keep aead_req_ctx in tls_rec? It doesn't seem to be
> > used, and I don't see it ever being used since it was introduced in
> > commit a42055e8d2c3 ("net/tls: Add support for async encryption of
> > records for performance").
>
> If this (flex array) is not going to be needed in the future, I'm
> happy to remove it. :)
I don't see what we'd use it for, aead_request.__ctx contains private
data from the crypto code (all accesses seem to be through
aead_request_ctx defined in include/crypto/internal/aead.h, see also
the kdoc: "Start of private context data").
And we haven't seen the author of a42055e8d2c3 in a while, so we can't
ask about the intention behind this field.
So IMO, tls_rec.aead_req_ctx can simply go away. Would you send the
patch?
--
Sabrina
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH][next] tls: Avoid -Wflex-array-member-not-at-end warning
2025-09-23 20:27 ` Sabrina Dubroca
@ 2025-09-23 20:53 ` Gustavo A. R. Silva
0 siblings, 0 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2025-09-23 20:53 UTC (permalink / raw)
To: Sabrina Dubroca
Cc: Gustavo A. R. Silva, John Fastabend, Jakub Kicinski,
David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman, netdev,
linux-kernel, linux-hardening
>>
>> If this (flex array) is not going to be needed in the future, I'm
>> happy to remove it. :)
>
> I don't see what we'd use it for, aead_request.__ctx contains private
> data from the crypto code (all accesses seem to be through
> aead_request_ctx defined in include/crypto/internal/aead.h, see also
> the kdoc: "Start of private context data").
> And we haven't seen the author of a42055e8d2c3 in a while, so we can't
> ask about the intention behind this field.
>
> So IMO, tls_rec.aead_req_ctx can simply go away. Would you send the
> patch?
>
Done: https://lore.kernel.org/linux-hardening/aNMG1lyXw4XEAVaE@kspp/
Thank you for the feedback. :)
-Gustavo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-23 20:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-22 14:39 [PATCH][next] tls: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2025-09-22 15:21 ` Sabrina Dubroca
2025-09-23 9:37 ` Gustavo A. R. Silva
2025-09-23 20:27 ` Sabrina Dubroca
2025-09-23 20:53 ` Gustavo A. R. Silva
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).