Re: [PATCH V2 02/41] x86/traps: Remove stack-protector from traps.c

From: Lai Jiangshan
Date: Mon Sep 27 2021 - 06:49:26 EST




On 2021/9/27 18:19, Borislav Petkov wrote:
On Sun, Sep 26, 2021 at 11:07:59PM +0800, Lai Jiangshan wrote:
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 8f4e8fa6ed75..0e054e2304c6 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

Why this too?

+CFLAGS_traps.o += -fno-stack-protector

Isn't this enough to disable stack protector for this file?


I did not investigate deep enough. I reviewed the generated code and
found %gs is accessed early for the C entry function and searched for
solution and I chose to copy the code that I thought is the most complete:
kernel/entry/Makefile

Using only "-fno-stack-protector" is enough to disable stack protector with
my .config, I'm not so sure about other configuration.

Thanks
Lai