]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
kasan: remove redundant config option
authorWalter Wu <walter-zh.wu@mediatek.com>
Fri, 16 Apr 2021 22:46:00 +0000 (15:46 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 7 May 2021 07:54:06 +0000 (09:54 +0200)
BugLink: https://bugs.launchpad.net/bugs/1926999
[ Upstream commit 02c587733c8161355a43e6e110c2e29bd0acff72 ]

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.

This patch fixes the following compilation warning:

  include/linux/kasan.h:333:30: warning: 'CONFIG_KASAN_STACK' is not defined, evaluates to 0 [-Wundef]

[akpm@linux-foundation.org: fix merge snafu]

Link: https://bugzilla.kernel.org/show_bug.cgi?id=210221
Link: https://lkml.kernel.org/r/20210226012531.29231-1-walter-zh.wu@mediatek.com
Fixes: d9b571c885a8 ("kasan: fix KASAN_STACK dependency for HW_TAGS")
Signed-off-by: Walter Wu <walter-zh.wu@mediatek.com>
Suggested-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/arm64/kernel/sleep.S
arch/x86/kernel/acpi/wakeup_64.S
include/linux/kasan.h
lib/Kconfig.kasan
mm/kasan/common.c
mm/kasan/kasan.h
mm/kasan/report_generic.c
scripts/Makefile.kasan
security/Kconfig.hardening

index 6bdef7362c0eba40a4cee4c7fb3b9955b41a3287..7c44ede122a9445236f965a12b94e645e1fa16eb 100644 (file)
@@ -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
index 9c9c66662adab5b4ee26a3a37386a153fa64b0aa..6ca69f3f3e9a144c00e0db2fad862b9e85fff418 100644 (file)
@@ -114,7 +114,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.
index 0aea9e2a2a01d18d4036997967518d56774f371e..f2980f010a488862ed7aad700e30c1869da48e89 100644 (file)
@@ -306,7 +306,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) {}
index 0d3b7940cf4304a378f727266831760ed5170d53..fde82ec85f8f95ffeb0c9af306a1919d6d8008e9 100644 (file)
@@ -138,9 +138,10 @@ config KASAN_INLINE
 
 endchoice
 
-config KASAN_STACK_ENABLE
+config KASAN_STACK
        bool "Enable stack instrumentation (unsafe)" if CC_IS_CLANG && !COMPILE_TEST
        depends on KASAN_GENERIC || KASAN_SW_TAGS
+       default y if CC_IS_GCC
        help
          The LLVM stack address sanitizer has a know problem that
          causes excessive stack usage in a lot of functions, see
@@ -154,12 +155,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
-       depends on KASAN_GENERIC || KASAN_SW_TAGS
-       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
index b25167664ead48b2877ffc2761f4c4739b55a73a..38ceb759f853285cf7ab787240b1b73b39b746e4 100644 (file)
@@ -63,7 +63,7 @@ void __kasan_unpoison_range(const void *address, size_t size)
        unpoison_range(address, size);
 }
 
-#if CONFIG_KASAN_STACK
+#ifdef CONFIG_KASAN_STACK
 /* Unpoison the entire stack for a task. */
 void kasan_unpoison_task_stack(struct task_struct *task)
 {
index 8c706e7652f2b1fa026b7da658382cdcc4b8b8ea..daa06aa5ea19b1c6d9788c95862c46b40187551e 100644 (file)
@@ -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) { }
index 8a9c889872da3041c31eba2e41b7920aa582c288..4e16518d98770a7f490a24ffc46b885b8dcf5537 100644 (file)
@@ -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
+#ifdef CONFIG_KASAN_STACK
 static bool __must_check tokenize_frame_descr(const char **frame_descr,
                                              char *token, size_t max_tok_len,
                                              unsigned long *value)
index 127012f45166ee6ba334941215ee018bfb9a5a33..3d791908ed364ba71f9a589b42a707b72ef3878c 100644 (file)
@@ -4,6 +4,12 @@ KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET)
 
 cc-param = $(call cc-option, -mllvm -$(1), $(call cc-option, --param $(1)))
 
+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 \
-               $(call cc-param,hwasan-instrument-stack=$(CONFIG_KASAN_STACK)) \
+               $(call cc-param,hwasan-instrument-stack=$(stack_enable)) \
                $(call cc-param,hwasan-use-short-granules=0) \
                $(instrumentation_flags)
 
index 269967c4fc1b67e81b403e9925497620974c68f8..a56c36470cb195c30f57faedb8701ef252722dae 100644 (file)
@@ -64,7 +64,7 @@ choice
        config GCC_PLUGIN_STRUCTLEAK_BYREF
                bool "zero-init structs passed by reference (strong)"
                depends on GCC_PLUGINS
-               depends on !(KASAN && KASAN_STACK=1)
+               depends on !(KASAN && KASAN_STACK)
                select GCC_PLUGIN_STRUCTLEAK
                help
                  Zero-initialize any structures on the stack that may
@@ -82,7 +82,7 @@ choice
        config GCC_PLUGIN_STRUCTLEAK_BYREF_ALL
                bool "zero-init anything passed by reference (very strong)"
                depends on GCC_PLUGINS
-               depends on !(KASAN && KASAN_STACK=1)
+               depends on !(KASAN && KASAN_STACK)
                select GCC_PLUGIN_STRUCTLEAK
                help
                  Zero-initialize any stack variables that may be passed