From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] overflow: Fix direct struct member initialization in _DEFINE_FLEX()
Date: Thu, 1 May 2025 16:57:24 -0600 [thread overview]
Message-ID: <a9c0ab40-6907-46d8-9107-7afe2f1782ca@embeddedor.com> (raw)
In-Reply-To: <202505011315.AC9590F@keescook>
> Earlier up in the file:
>
> ...
> * @initializer: initializer expression (could be empty for no init).
> ^^^^^^^^^
> */
> #define _DEFINE_FLEX(type, name, member, count, initializer...)
>
> This argument now becomes required, which is fine, but we should keep
Nice catch!
> the docs updated and double check any existing "_DEFINE_FLEX" users that
> may have an empty final argument (I don't see any, so that's nice).
Yep, I build-tested it and saw no errors.
>
>> union { \
>> u8 bytes[struct_size_t(type, member, count)]; \
>> type obj; \
>> - } name##_u initializer; \
>> + } name##_u = { .obj initializer }; \
>> type *name = (type *)&name##_u
>>
>> /**
>> @@ -444,7 +444,7 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
>> * elements in array @member.
>> */
>> #define DEFINE_FLEX(TYPE, NAME, MEMBER, COUNTER, COUNT) \
>> - _DEFINE_FLEX(TYPE, NAME, MEMBER, COUNT, = { .obj.COUNTER = COUNT, })
>> + _DEFINE_FLEX(TYPE, NAME, MEMBER, COUNT, = { .COUNTER = COUNT, })
>>
>> /**
>> * STACK_FLEX_ARRAY_SIZE() - helper macro for DEFINE_FLEX() family.
>
> But otherwise, yes, let's do this!
>
Here you go :)
https://lore.kernel.org/linux-hardening/aBP0b3gfurLFDlwY@kspp/
Thanks!
-Gustavo
prev parent reply other threads:[~2025-05-01 22:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 23:46 [PATCH][next] overflow: Fix direct struct member initialization in _DEFINE_FLEX() Gustavo A. R. Silva
2025-05-01 20:17 ` Kees Cook
2025-05-01 22:57 ` 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=a9c0ab40-6907-46d8-9107-7afe2f1782ca@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=gustavoars@kernel.org \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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