[PATCH v4 3/4] init.h: Disable sanitizer coverage for __init and __head

2025-07-24 Thread Kees Cook
While __noinstr already contained __no_sanitize_coverage, it needs to be added to __init and __head section markings to support the Clang implementation of CONFIG_KSTACK_ERASE. This is to make sure the stack depth tracking callback is not executed in unsupported contexts. The other sanitizer cover

[PATCH v4 2/4] x86: Handle KCOV __init vs inline mismatches

2025-07-24 Thread Kees Cook
GCC appears to have kind of fragile inlining heuristics, in the sense that it can change whether or not it inlines something based on optimizations. It looks like the kcov instrumentation being added (or in this case, removed) from a function changes the optimization results, and some functions mar

[PATCH v4 1/4] arm64: Handle KCOV __init vs inline mismatches

2025-07-24 Thread Kees Cook
GCC appears to have kind of fragile inlining heuristics, in the sense that it can change whether or not it inlines something based on optimizations. It looks like the kcov instrumentation being added (or in this case, removed) from a function changes the optimization results, and some functions mar

[PATCH v4 4/4] kstack_erase: Support Clang stack depth tracking

2025-07-24 Thread Kees Cook
Wire up CONFIG_KSTACK_ERASE to Clang 21's new stack depth tracking callback[1] option. Link: https://clang.llvm.org/docs/SanitizerCoverage.html#tracing-stack-depth [1] Signed-off-by: Kees Cook --- Cc: Arnd Bergmann Cc: Masahiro Yamada Cc: Nathan Chancellor Cc: Nicolas Schier Cc: Marco Elver

[PATCH v4 0/4] stackleak: Support Clang stack depth tracking

2025-07-24 Thread Kees Cook
v4: - rebase on for-next/hardening tree (took subset of v3 patches) - improve commit logs for x86 and arm64 changes (Mike, Will, Ard) v3: https://lore.kernel.org/lkml/20250717231756.make.423-k...@kernel.org/ v2: https://lore.kernel.org/lkml/20250523043251.it.550-k...@kernel.org/ v1: https:/