[PATCH 01/24] x86/traps: Remove stack-protector from traps.c

From: Lai Jiangshan
Date: Tue Aug 31 2021 - 13:50:35 EST


From: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>

When stack-protector is enabled, the compiler adds some instrument code
at the beginning and the end of some functions. Many functions in traps.c
are non-instrumentable. Moreover, stack-protector code in the beginning
of the affected function accesses the canary that might be watched by
hardware breakpoints which might also violate the non-instrumentable
nature of some functions.

So it is better to remove stack-protector from traps.c.

It is also prepared for later patches that move some entry code into
traps.c, some of which can NOT use percpu register until gsbase is
properly switched. And stack-protector depends on the percpu register
to work.

Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>
---
arch/x86/kernel/Makefile | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 3e625c61f008..21aa164cece2 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -48,6 +48,9 @@ KCOV_INSTRUMENT := n

CFLAGS_head$(BITS).o += -fno-stack-protector

+CFLAGS_REMOVE_traps.o = -fstack-protector -fstack-protector-strong
+CFLAGS_traps.o += -fno-stack-protector
+
CFLAGS_irq.o := -I $(srctree)/$(src)/../include/asm/trace

obj-y := process_$(BITS).o signal.o
--
2.19.1.6.gb485710b