Re: [PATCH] kunit/stackinit: Cover declarations bypassed by goto and switch
From: Kees Cook
Date: Mon Oct 05 2026 - 05:42:04 EST
On Fri, 02 Oct 2026 12:12:53 -0700, Justin Stitt wrote:
> Under -ftrivial-auto-var-init= the initialization is emitted where a
> variable is declared. A switch dispatch that reaches a case label below
> the declaration, or a goto that jumps past it, never reaches that point,
> so the variable was left uninitialized.
>
> Commit 9cf016e6b49b ("lib: test_stackinit.c: XFAIL switch variable init
> tests") marked test_switch_1_none and test_switch_2_none as expected
> failures, noting the test should be retained "so that we can evaluate
> compiler fixes". Clang 24 emits the initialization on the jumps that
> bypass the declaration, so make the expectation depend on the compiler
> version instead of failing unconditionally.
>
> [...]
Applied to for-next/hardening, thanks!
[1/1] kunit/stackinit: Cover declarations bypassed by goto and switch
https://git.kernel.org/kees/c/6bf37b9c59dc
Take care,
--
Kees Cook