Re: [PATCH v2] overflow: Match arithmetic in both parts of __builtin_choose_expr

From: Kees Cook

Date: Wed Oct 14 2026 - 21:06:40 EST


On Tue, 13 Oct 2026 20:31:46 +0000, Bill Wendling wrote:
> The two parts of '__builtin_choose_expr()' had different arithmetic
> expressions. This patch corrects it so that both parts calculate:
>
> COUNT * sizeof(*MEMBER) + __must_be_array(MEMBER)
>
> In practice, '__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).
>
> [...]

Applied to for-next/hardening, thanks!

[1/1] overflow: Match arithmetic in both parts of __builtin_choose_expr
https://git.kernel.org/kees/c/2f70a9b7e9c7

Take care,

--
Kees Cook