mirror of
https://github.com/torvalds/linux.git
synced 2024-12-29 06:12:08 +00:00
c3ff2a5193
This functionality was tentatively added in the past (commit6533b7c16e
("powerpc: Initial stack protector (-fstack-protector) support")) but had to be reverted (commitf2574030b0
("powerpc: Revert the initial stack protector support") because of GCC implementing it differently whether it had been built with libc support or not. Now, GCC offers the possibility to manually set the stack-protector mode (global or tls) regardless of libc support. This time, the patch selects HAVE_STACKPROTECTOR only if -mstack-protector-guard=tls is supported by GCC. On PPC32, as register r2 points to current task_struct at all time, the stack_canary located inside task_struct can be used directly by using the following GCC options: -mstack-protector-guard=tls -mstack-protector-guard-reg=r2 -mstack-protector-guard-offset=offsetof(struct task_struct, stack_canary)) The protector is disabled for prom_init and bootx_init as it is too early to handle it properly. $ echo CORRUPT_STACK > /sys/kernel/debug/provoke-crash/DIRECT [ 134.943666] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: lkdtm_CORRUPT_STACK+0x64/0x64 [ 134.943666] [ 134.955414] CPU: 0 PID: 283 Comm: sh Not tainted 4.18.0-s3k-dev-12143-ga3272be41209 #835 [ 134.963380] Call Trace: [ 134.965860] [c6615d60] [c001f76c] panic+0x118/0x260 (unreliable) [ 134.971775] [c6615dc0] [c001f654] panic+0x0/0x260 [ 134.976435] [c6615dd0] [c032c368] lkdtm_CORRUPT_STACK_STRONG+0x0/0x64 [ 134.982769] [c6615e00] [ffffffff] 0xffffffff Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
22 lines
799 B
Makefile
22 lines
799 B
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
CFLAGS_bootx_init.o += -fPIC
|
|
CFLAGS_bootx_init.o += $(call cc-option, -fno-stack-protector)
|
|
|
|
ifdef CONFIG_FUNCTION_TRACER
|
|
# Do not trace early boot code
|
|
CFLAGS_REMOVE_bootx_init.o = $(CC_FLAGS_FTRACE)
|
|
endif
|
|
|
|
obj-y += pic.o setup.o time.o feature.o pci.o \
|
|
sleep.o low_i2c.o cache.o pfunc_core.o \
|
|
pfunc_base.o udbg_scc.o udbg_adb.o
|
|
obj-$(CONFIG_PMAC_BACKLIGHT) += backlight.o
|
|
# CONFIG_NVRAM is an arch. independent tristate symbol, for pmac32 we really
|
|
# need this to be a bool. Cheat here and pretend CONFIG_NVRAM=m is really
|
|
# CONFIG_NVRAM=y
|
|
obj-$(CONFIG_NVRAM:m=y) += nvram.o
|
|
# ppc64 pmac doesn't define CONFIG_NVRAM but needs nvram stuff
|
|
obj-$(CONFIG_PPC64) += nvram.o
|
|
obj-$(CONFIG_PPC32) += bootx_init.o
|
|
obj-$(CONFIG_SMP) += smp.o
|