From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Kees Cook <keescook@chromium.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Jan Kara <jack@suse.cz>, Amir Goldstein <amir73il@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] fsnotify: Avoid -Wflex-array-member-not-at-end warning
Date: Wed, 6 Mar 2024 09:42:17 -0600 [thread overview]
Message-ID: <00b30dee-59ed-4782-8d1a-64b66c38c901@embeddedor.com> (raw)
In-Reply-To: <202403051548.045B16BF@keescook>
On 3/5/24 17:52, Kees Cook wrote:
> On Tue, Mar 05, 2024 at 04:18:46PM -0600, Gustavo A. R. Silva wrote:
>> -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
>> ready to enable it globally.
>>
>> There is currently a local structure `f` that is using a flexible
>> `struct file_handle` as header for an on-stack place-holder for the
>> flexible-array member `unsigned char f_handle[];`.
>>
>> struct {
>> struct file_handle handle;
>> u8 pad[MAX_HANDLE_SZ];
>> } f;
>
> This code pattern is "put a flex array struct on the stack", but we have
> a macro for this now:
>
> DEFINE_FLEX(struct file_handle, handle, f_handle, MAX_HANDLE_SZ);
>
> And you can even include the initializer:
>
> _DEFINE_FLEX(struct file_handle, handle, f_handle, MAX_HANDLE_SZ,
> = { .handle_bytes = MAX_HANDLE_SZ });
>
> I think this would be a simpler conversion.
>
> Also, this could use a __counted_by tag...
>
> I need to improve the DEFINE_FLEX macro a bit, though, to take advantage
> of __counted_by.
>
Yep, I like it.
I'll go and hunt down all those on-stack -Wflex-array-member-not-at-end
issues with this helper. :)
Thanks
--
Gustavo
prev parent reply other threads:[~2024-03-06 15:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 22:18 [PATCH][next] fsnotify: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2024-03-05 23:52 ` Kees Cook
2024-03-06 7:36 ` Amir Goldstein
2024-03-06 15:42 ` Gustavo A. R. Silva
2024-03-06 15:42 ` Gustavo A. R. Silva [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=00b30dee-59ed-4782-8d1a-64b66c38c901@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=gustavoars@kernel.org \
--cc=jack@suse.cz \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).