]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
init.h: Disable sanitizer coverage for __init and __head
authorKees Cook <kees@kernel.org>
Thu, 24 Jul 2025 05:50:27 +0000 (22:50 -0700)
committerKees Cook <kees@kernel.org>
Sat, 26 Jul 2025 21:28:35 +0000 (14:28 -0700)
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 coverage options (trace-pc and trace-cmp) aren't
needed in __head nor __init either ("We are interested in code coverage
as a function of a syscall inputs"[1]), so this is fine to disable for
them as well.

Link: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/kcov.c?h=v6.14#n179
Acked-by: Marco Elver <elver@google.com>
Link: https://lore.kernel.org/r/20250724055029.3623499-3-kees@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
arch/x86/include/asm/init.h
include/linux/init.h

index 8b1b1abcef1565ee5f5106b80eea1e07b53fc5f8..6bfdaeddbae888afd8334b9641c9ddf009e6ec56 100644 (file)
@@ -5,7 +5,7 @@
 #if defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION < 170000
 #define __head __section(".head.text") __no_sanitize_undefined __no_stack_protector
 #else
-#define __head __section(".head.text") __no_sanitize_undefined
+#define __head __section(".head.text") __no_sanitize_undefined __no_sanitize_coverage
 #endif
 
 struct x86_mapping_info {
index ee1309473bc626745284d50128a5272ea65ff10e..c65a050d52a770d290bb22ab5de1a5e9097ca9e0 100644 (file)
@@ -49,7 +49,9 @@
 
 /* These are for everybody (although not all archs will actually
    discard it in modules) */
-#define __init         __section(".init.text") __cold  __latent_entropy __noinitretpoline
+#define __init         __section(".init.text") __cold __latent_entropy \
+                                               __noinitretpoline       \
+                                               __no_sanitize_coverage
 #define __initdata     __section(".init.data")
 #define __initconst    __section(".init.rodata")
 #define __exitdata     __section(".exit.data")