kasan: remove redundant config option
Subsystems (9)
PATCH v2 1/1 kasan: remove redundant config option
CONFIG_KASAN_STACK and CONFIG_KASAN_STACK_ENABLE both enable KASAN stack instrumentation, but we should only need one config, so that we remove CONFIG_KASAN_STACK_ENABLE and make CONFIG_KASAN_STACK workable. see [1].
When enable KASAN stack instrumentation, then for gcc we could do no prompt and default value y, and for clang prompt and default value n.
[1]: https://bugzilla.kernel.org/show_bug.cgi?id=210221
Signed-off-by Walter Wu <[email protected]>
Suggested-by Dmitry Vyukov <[email protected]>
Cc Andrey Ryabinin <[email protected]>
Cc Dmitry Vyukov <[email protected]>
Cc Andrey Konovalov <[email protected]>
Cc Alexander Potapenko <[email protected]>
Cc Andrew Morton <[email protected]>
---
v2: make commit log to be more readable.
--- arch/arm64/kernel/sleep.S | 2 +- arch/x86/kernel/acpi/wakeup_64.S | 2 +- include/linux/kasan.h | 2 +- lib/Kconfig.kasan | 11 ++++------- mm/kasan/common.c | 2 +- mm/kasan/kasan.h | 2 +- mm/kasan/report_generic.c | 2 +- scripts/Makefile.kasan | 10 ++++++++-- 8 files changed, 18 insertions(+), 15 deletions(-)
arch/arm64/kernel/sleep.S +1 -1
@@ -133,7 +133,7 @@ SYM_FUNC_START(_cpu_resume) */ bl cpu_do_resume -#if defined(CONFIG_KASAN) && CONFIG_KASAN_STACK +#if defined(CONFIG_KASAN) && defined(CONFIG_KASAN_STACK) mov x0, sp bl kasan_unpoison_task_stack_below #endif
arch/x86/kernel/acpi/wakeup_64.S +1 -1
@@ -112,7 +112,7 @@ SYM_FUNC_START(do_suspend_lowlevel) movq pt_regs_r14(%rax), %r14 movq pt_regs_r15(%rax), %r15 -#if defined(CONFIG_KASAN) && CONFIG_KASAN_STACK +#if defined(CONFIG_KASAN) && defined(CONFIG_KASAN_STACK) /* * The suspend path may have poisoned some areas deeper in the stack, * which we now need to unpoison.
include/linux/kasan.h +1 -1
@@ -302,7 +302,7 @@ static inline void kasan_kfree_large(void *ptr, unsigned long ip) {}#endif /* CONFIG_KASAN */ -#if defined(CONFIG_KASAN ) &&CONFIG_KASAN_STACK +#if defined(CONFIG_KASAN ) && defined(CONFIG_KASAN_STACK )void kasan_unpoison_task_stack (struct task_struct *task);#else static inline void kasan_unpoison_task_stack (struct task_struct *task) {}
lib/Kconfig.kasan +4 -7
@@ -138,9 +138,11 @@ config KASAN_INLINE endchoice -config KASAN_STACK_ENABLE - bool "Enable stack instrumentation (unsafe)" if CC_IS_CLANG && !COMPILE_TEST +config KASAN_STACK + bool "Enable stack instrumentation (unsafe)" depends on KASAN_GENERIC || KASAN_SW_TAGS + default y if CC_IS_GCC + default n if CC_IS_CLANG help The LLVM stack address sanitizer has a know problem that causes excessive stack usage in a lot of functions, see
@@ -154,11 +156,6 @@ config KASAN_STACK_ENABLE CONFIG_COMPILE_TEST. On gcc it is assumed to always be safe to use and enabled by default. -config KASAN_STACK - int - default 1 if KASAN_STACK_ENABLE || CC_IS_GCC - default 0 - config KASAN_SW_TAGS_IDENTIFY bool "Enable memory corruption identification" depends on KASAN_SW_TAGS
mm/kasan/common.c +1 -1
@@ -63,7 +63,7 @@ void __kasan_unpoison_range(const void *address, size_t size)unpoison_range (address, size); } -#if CONFIG_KASAN_STACK +#if defined(CONFIG_KASAN_STACK )/* Unpoison the entire stack for a task. */ void kasan_unpoison_task_stack (struct task_struct *task) {
mm/kasan/kasan.h +1 -1
@@ -224,7 +224,7 @@ void *find_first_bad_addr(void *addr, size_t size);const char *get_bug_type (struct kasan_access_info *info);void metadata_fetch_row (char *buffer,void *row); -#if defined(CONFIG_KASAN_GENERIC ) &&CONFIG_KASAN_STACK +#if defined(CONFIG_KASAN_GENERIC ) && defined(CONFIG_KASAN_STACK )void print_address_stack_frame (const void *addr);#else static inline void print_address_stack_frame (const void *addr) { }
mm/kasan/report_generic.c +1 -1
@@ -128,7 +128,7 @@ void metadata_fetch_row(char *buffer, void *row)memcpy (buffer,kasan_mem_to_shadow (row),META_BYTES_PER_ROW ); } -#if CONFIG_KASAN_STACK +#if defined(CONFIG_KASAN_STACK )static bool __must_check tokenize_frame_descr (const char **frame_descr,char *token,size_t max_tok_len,unsigned long *value)
scripts/Makefile.kasan +8 -2
@@ -2,6 +2,12 @@ CFLAGS_KASAN_NOSANITIZE := -fno-builtin KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET) +ifdef CONFIG_KASAN_STACK + stack_enable := 1 +else + stack_enable := 0 +endif + ifdef CONFIG_KASAN_GENERIC ifdef CONFIG_KASAN_INLINE
@@ -27,7 +33,7 @@ else CFLAGS_KASAN := $(CFLAGS_KASAN_SHADOW) \ $(call cc-param,asan-globals=1) \ $(call cc-param,asan-instrumentation-with-call-threshold=$(call_threshold)) \ - $(call cc-param,asan-stack=$(CONFIG_KASAN_STACK)) \ + $(call cc-param,asan-stack=$(stack_enable)) \ $(call cc-param,asan-instrument-allocas=1) endif
@@ -42,7 +48,7 @@ else endif CFLAGS_KASAN := -fsanitize=kernel-hwaddress \ - -mllvm -hwasan-instrument-stack=$(CONFIG_KASAN_STACK) \ + -mllvm -hwasan-instrument-stack=$(stack_enable) \ -mllvm -hwasan-use-short-granules=0 \ $(instrumentation_flags)
Signature · 1 line
2.18.0