Skip to content

Commit 33cd65e

Browse files
melvertorvalds
authored andcommitted
kasan: disable branch tracing for core runtime
During early boot, while KASAN is not yet initialized, it is possible to enter reporting code-path and end up in kasan_report(). While uninitialized, the branch there prevents generating any reports, however, under certain circumstances when branches are being traced (TRACE_BRANCH_PROFILING), we may recurse deep enough to cause kernel reboots without warning. To prevent similar issues in future, we should disable branch tracing for the core runtime. [[email protected]: remove duplicate DISABLE_BRANCH_PROFILING, per Qian Cai] Link: https://lore.kernel.org/lkml/20200517011732.GE24705@shao2-debian/ Link: http://lkml.kernel.org/r/[email protected] Reported-by: kernel test robot <[email protected]> Signed-off-by: Marco Elver <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Andrey Konovalov <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: Andrey Ryabinin <[email protected]> Cc: Qian Cai <[email protected]> Cc: <[email protected]> Link: http://lkml.kernel.org/r//20200517011732.GE24705@shao2-debian/ Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 380e5c1 commit 33cd65e

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

mm/kasan/Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ CFLAGS_REMOVE_tags_report.o = $(CC_FLAGS_FTRACE)
1515

1616
# Function splitter causes unnecessary splits in __asan_load1/__asan_store1
1717
# see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63533
18-
CFLAGS_common.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
19-
CFLAGS_generic.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
20-
CFLAGS_generic_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
21-
CFLAGS_init.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
22-
CFLAGS_quarantine.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
23-
CFLAGS_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
24-
CFLAGS_tags.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
25-
CFLAGS_tags_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
18+
CFLAGS_common.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
19+
CFLAGS_generic.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
20+
CFLAGS_generic_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
21+
CFLAGS_init.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
22+
CFLAGS_quarantine.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
23+
CFLAGS_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
24+
CFLAGS_tags.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
25+
CFLAGS_tags_report.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector) -DDISABLE_BRANCH_PROFILING
2626

2727
obj-$(CONFIG_KASAN) := common.o init.o report.o
2828
obj-$(CONFIG_KASAN_GENERIC) += generic.o generic_report.o quarantine.o

mm/kasan/generic.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18-
#define DISABLE_BRANCH_PROFILING
1918

2019
#include <linux/export.h>
2120
#include <linux/interrupt.h>

mm/kasan/tags.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313

1414
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15-
#define DISABLE_BRANCH_PROFILING
1615

1716
#include <linux/export.h>
1817
#include <linux/interrupt.h>

0 commit comments

Comments
 (0)