From: Kees Cook <kees@kernel.org>
To: Bill Wendling <morbo@google.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] overflow: Match arithmetic in both parts of __builtin_choose_expr
Date: Mon, 12 Oct 2026 20:30:10 -0700 [thread overview]
Message-ID: <202610122028.BB0EDC98@keescook> (raw)
In-Reply-To: <20261012205919.4012405-1-morbo@google.com>
On Mon, Oct 12, 2026 at 08:59:19PM +0000, Bill Wendling wrote:
> The two parts of the '__builtin_choose_expr()' had different arithmetic
> expressions. This patch correct it so that both parts calculate:
>
> COUNT * sizeof(*MEMBER) + __must_be_array(MEMBER)
>
> In practice, the call to '__must_be_array' is meant to assert if
> 'MEMBER' isn't an array and return '0' otherwise. However, symmetry is
> less prone to subtle errors (and far more satisfying).
>
> Fixes: 230f6fa2c1db ("overflow: Provide constant expression struct_size")
A Fixes trailer implies a bug being solved. What problem is there here?
I only see downsides to this change: this adds even more layers of
macros and inlinings to gain the size_add() for a constant integer 0.
?
> - size_mul(count, sizeof(*(p)->member) + __must_be_array((p)->member)))
> + size_add(size_mul(count, sizeof(*(p)->member)), \
> + __must_be_array((p)->member)))
--
Kees Cook
next prev parent reply other threads:[~2026-10-13 3:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 20:59 Bill Wendling
2026-10-13 3:30 ` Kees Cook [this message]
2026-10-13 17:17 ` Bill Wendling
2026-10-13 20:31 ` [PATCH v2] " Bill Wendling
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=202610122028.BB0EDC98@keescook \
--to=kees@kernel.org \
--cc=gustavoars@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=morbo@google.com \
/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®