linux/arch/powerpc/platforms/powermac
Christophe Leroy c3ff2a5193 powerpc/32: add stack protector support
This functionality was tentatively added in the past
(commit 6533b7c16e ("powerpc: Initial stack protector
(-fstack-protector) support")) but had to be reverted
(commit f2574030b0 ("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>
2018-10-03 15:40:03 +10:00
..
backlight.c powerpc: Fix old-style function definition 2018-01-21 23:37:44 +11:00
bootx_init.c powerpc: fix spelling mistake: "Usupported" -> "Unsupported" 2018-06-05 11:33:43 +10:00
cache.S powerpc: clean inclusions of asm/feature-fixups.h 2018-07-30 22:48:17 +10:00
feature.c powerpc/powermac: of_node_put() is not needed after iterator 2018-08-08 00:32:34 +10:00
Kconfig License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
low_i2c.c treewide: correct "differenciate" and "instanciate" typos 2018-08-23 18:48:43 -07:00
Makefile powerpc/32: add stack protector support 2018-10-03 15:40:03 +10:00
nvram.c powerpc: Remove more traces of bootmem 2014-11-19 21:41:51 +11:00
pci.c powerpc/powermac: Make some functions static 2018-08-10 22:12:37 +10:00
pfunc_base.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pfunc_core.c powerpc: Use sizeof(*foo) rather than sizeof(struct foo) 2018-03-20 16:47:53 +11:00
pic.c powerpc: make use of for_each_node_by_type() instead of open-coding it 2018-01-16 23:47:10 +11:00
pmac.h powerpc: use time64_t in read_persistent_clock 2018-06-03 20:43:33 +10:00
setup.c powerpc/powermac: Add missing prototype for note_bootable_part() 2018-05-25 12:04:42 +10:00
sleep.S powerpc: clean inclusions of asm/feature-fixups.h 2018-07-30 22:48:17 +10:00
smp.c powerpc/powermac: Move pmac_pfunc_base_install prototype to header file 2018-05-25 12:04:41 +10:00
time.c powerpc/powermac: Add missing include of header pmac.h 2018-08-10 22:12:36 +10:00
udbg_adb.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
udbg_scc.c powerpc/powermac: Remove variable x that's never read 2018-08-10 22:12:37 +10:00