[PATCH] x86/cmdline: Disable instrumentation of cmdline unconditionally
From: Arvind Sankar
Date: Sun Sep 06 2020 - 11:47:36 EST
On 32-bit, cmdline_find_option_bool() is used before paging is enabled,
from check_loader_disabled_bsp() in the early microcode loader.
Instrumentation options that insert accesses to global data will likely
crash or corrupt memory at this point.
cmdline_find_option{,_bool}() are only used during boot, so
instrumentation is not that useful anyway.
Disable instrumentation unconditionally, and additionally disable:
- GCOV
- UBSAN
- tracing: change -pg -> CC_FLAGS_FTRACE
- STACKLEAK_PLUGIN
- BRANCH_PROFILING
Signed-off-by: Arvind Sankar <nivedita@xxxxxxxxxxxx>
---
arch/x86/lib/Makefile | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index aa067859a70b..0ad4ae9def44 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -15,17 +15,19 @@ CFLAGS_REMOVE_delay.o = $(CC_FLAGS_FTRACE)
endif
# Early boot use of cmdline; don't instrument it
-ifdef CONFIG_AMD_MEM_ENCRYPT
+GCOV_PROFILE_cmdline.o := n
KCOV_INSTRUMENT_cmdline.o := n
KASAN_SANITIZE_cmdline.o := n
+UBSAN_SANITIZE_cmdline.o := n
KCSAN_SANITIZE_cmdline.o := n
ifdef CONFIG_FUNCTION_TRACER
-CFLAGS_REMOVE_cmdline.o = -pg
+CFLAGS_REMOVE_cmdline.o = $(CC_FLAGS_FTRACE)
endif
CFLAGS_cmdline.o := -fno-stack-protector -fno-jump-tables
-endif
+CFLAGS_cmdline.o += $(DISABLE_STACKLEAK_PLUGIN)
+CFLAGS_cmdline.o += -DDISABLE_BRANCH_PROFILING
inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
--
2.26.2