[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a9c0ab40-6907-46d8-9107-7afe2f1782ca@embeddedor.com>
Date: Thu, 1 May 2025 16:57:24 -0600
From: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To: Kees Cook <kees@...nel.org>, "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc: linux-hardening@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH][next] overflow: Fix direct struct member initialization
in _DEFINE_FLEX()
> 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
Powered by blists - more mailing lists