Linux Hardening
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3][next] overflow: Fix direct struct member initialization in _DEFINE_FLEX()
Date: Fri, 30 May 2025 11:52:45 -0700	[thread overview]
Message-ID: <202505301151.6CEDBBF8@keescook> (raw)
In-Reply-To: <202505301054.A786A183@keescook>

On Fri, May 30, 2025 at 11:06:01AM -0700, Kees Cook wrote:
> #define __DEFINE_FLEX(type, name, member, count, trailer...)		\
>         _Static_assert(__builtin_constant_p(count),			\
>                        "onstack flex array members require compile-time const count"); \
>         union {								\
>                 u8 bytes[struct_size_t(type, member, count)];		\
>                 type obj;						\
>         } name##_u trailer;						\
>         type *name = (type *)&name##_u
> 
> #define _DEFINE_FLEX(type, name, member, count, initializer...)		\
> 	__DEFINE_FLEX(type, name, member, count, = { .obj = initializer })
> [...]
> Does that look like what you'd want? (Note I didn't actually build this;
> I want to make sure the concept is workable...)

FWIW, this is working as expected: https://godbolt.org/z/P7Go8Tr33

I'll send a proper patch...

-- 
Kees Cook

      reply	other threads:[~2025-05-30 18:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-02  0:44 [PATCH v3][next] overflow: Fix direct struct member initialization in _DEFINE_FLEX() Gustavo A. R. Silva
2025-05-02  2:26 ` Kees Cook
2025-05-30 14:59 ` Alexander Lobakin
2025-05-30 18:06   ` Kees Cook
2025-05-30 18:52     ` Kees Cook [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=202505301151.6CEDBBF8@keescook \
    --to=kees@kernel.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=gustavoars@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