File tree Expand file tree Collapse file tree 4 files changed +20
-3
lines changed Expand file tree Collapse file tree 4 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 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
1111struct x86_mapping_info {
Original file line number Diff line number Diff line change 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")
Original file line number Diff line number Diff line change @@ -22,3 +22,15 @@ ubsan-integer-wrap-cflags-$(CONFIG_UBSAN_INTEGER_WRAP) += \
2222 -fsanitize=implicit-unsigned-integer-truncation \
2323 -fsanitize-ignorelist=$(srctree)/scripts/integer-wrap-ignore.scl
2424export CFLAGS_UBSAN_INTEGER_WRAP := $(ubsan-integer-wrap-cflags-y)
25+
26+ ifdef CONFIG_CC_IS_CLANG
27+ stackleak-cflags-$(CONFIG_STACKLEAK) += \
28+ -fsanitize-coverage=stack-depth \
29+ -fsanitize-coverage-stack-depth-callback-min=$(CONFIG_STACKLEAK_TRACK_MIN_SIZE)
30+ export STACKLEAK_CFLAGS := $(stackleak-cflags-y)
31+ ifdef CONFIG_STACKLEAK
32+ DISABLE_STACKLEAK := -fno-sanitize-coverage=stack-depth
33+ endif
34+ export DISABLE_STACKLEAK
35+ KBUILD_CFLAGS += $(STACKLEAK_CFLAGS)
36+ endif
Original file line number Diff line number Diff line change @@ -158,10 +158,13 @@ config GCC_PLUGIN_STRUCTLEAK_VERBOSE
158158 initialized. Since not all existing initializers are detected
159159 by the plugin, this can produce false positive warnings.
160160
161+ config CC_HAS_SANCOV_STACK_DEPTH_CALLBACK
162+ def_bool $(cc-option,-fsanitize-coverage-stack-depth-callback-min=1)
163+
161164config STACKLEAK
162165 bool "Poison kernel stack before returning from syscalls"
163166 depends on HAVE_ARCH_STACKLEAK
164- depends on GCC_PLUGINS
167+ depends on GCC_PLUGINS || CC_HAS_SANCOV_STACK_DEPTH_CALLBACK
165168 help
166169 This option makes the kernel erase the kernel stack before
167170 returning from system calls. This has the effect of leaving
You can’t perform that action at this time.
0 commit comments