Skip to content

Commit 381a38e

Browse files
committed
init.h: Disable sanitizer coverage for __init and __head
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 [1] Acked-by: Marco Elver <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 431a380 commit 381a38e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

arch/x86/include/asm/init.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#if defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION < 170000
66
#define __head __section(".head.text") __no_sanitize_undefined __no_stack_protector
77
#else
8-
#define __head __section(".head.text") __no_sanitize_undefined
8+
#define __head __section(".head.text") __no_sanitize_undefined __no_sanitize_coverage
99
#endif
1010

1111
struct x86_mapping_info {

include/linux/init.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949

5050
/* These are for everybody (although not all archs will actually
5151
discard it in modules) */
52-
#define __init __section(".init.text") __cold __latent_entropy __noinitretpoline
52+
#define __init __section(".init.text") __cold __latent_entropy \
53+
__noinitretpoline \
54+
__no_sanitize_coverage
5355
#define __initdata __section(".init.data")
5456
#define __initconst __section(".init.rodata")
5557
#define __exitdata __section(".exit.data")

0 commit comments

Comments
 (0)