mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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] overflow: Clarify expectations for getting DEFINE_FLEX variable sizes
Date: Wed, 16 Apr 2025 11:37:40 -0600	[thread overview]
Message-ID: <658d0535-6842-4515-a888-217cb375968c@embeddedor.com> (raw)
In-Reply-To: <20250416172911.work.854-kees@kernel.org>



On 16/04/25 11:29, Kees Cook wrote:
> Mention the use of __member_size() for DEFINE_FLEX variables as a hint
> for getting at the compile-time size of the resulting flexible array
> member.
> 
> Signed-off-by: Kees Cook <kees@kernel.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks!
--
Gustavo

> ---
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: linux-hardening@vger.kernel.org
> ---
>   include/linux/overflow.h | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/overflow.h b/include/linux/overflow.h
> index 0c7e3dcfe867..6ee67c20b575 100644
> --- a/include/linux/overflow.h
> +++ b/include/linux/overflow.h
> @@ -419,6 +419,7 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
>    * Define a zeroed, on-stack, instance of @type structure with a trailing
>    * flexible array member.
>    * Use __struct_size(@name) to get compile-time size of it afterwards.
> + * Use __member_size(@name->member) to get compile-time size of @name members.
>    */
>   #define DEFINE_RAW_FLEX(type, name, member, count)	\
>   	_DEFINE_FLEX(type, name, member, count, = {})
> @@ -436,6 +437,7 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
>    * Define a zeroed, on-stack, instance of @TYPE structure with a trailing
>    * flexible array member.
>    * Use __struct_size(@NAME) to get compile-time size of it afterwards.
> + * Use __member_size(@NAME->member) to get compile-time size of @NAME members.
>    */
>   #define DEFINE_FLEX(TYPE, NAME, MEMBER, COUNTER, COUNT)	\
>   	_DEFINE_FLEX(TYPE, NAME, MEMBER, COUNT, = { .obj.COUNTER = COUNT, })


  reply	other threads:[~2025-04-16 17:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 17:29 Kees Cook
2025-04-16 17:37 ` Gustavo A. R. Silva [this message]
2025-04-16 19:29 ` Kees Cook

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=658d0535-6842-4515-a888-217cb375968c@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

all inboxes | Powered by JetHome®