linux-sg2042/arch/powerpc
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
..
boot powerpc/boot: Ensure _zimage_start is a weak symbol 2018-09-19 22:08:12 +10:00
configs powerpc/configs: Update skiroot defconfig 2018-09-19 22:08:12 +10:00
crypto powerpc updates for 4.19 2018-08-17 11:32:50 -07:00
include powerpc/32: add stack protector support 2018-10-03 15:40:03 +10:00
kernel powerpc/32: add stack protector support 2018-10-03 15:40:03 +10:00
kvm PPC KVM fixes for 4.19 2018-09-04 21:12:46 +02:00
lib powerpc/64: Remove static branch hints from memset() 2018-09-17 21:17:25 +10:00
math-emu License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mm arch/powerpc/mm/hash: validate the pte entries before handling the hash fault 2018-10-03 15:39:59 +10:00
net powerpc updates for 4.19 2018-08-17 11:32:50 -07:00
oprofile treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
perf powerpc/perf: Add missing break in power7_marked_instr_event() 2018-10-03 15:39:45 +10:00
platforms powerpc/32: add stack protector support 2018-10-03 15:40:03 +10:00
purgatory powerpc updates for 4.19 2018-08-17 11:32:50 -07:00
sysdev powerpc/xive: Move a dereference below a NULL test 2018-10-03 15:40:02 +10:00
tools powerpc: Add a checkpatch wrapper with our preferred settings 2018-08-07 21:49:25 +10:00
xmon Revert "convert SLB miss handlers to C" and subsequent commits 2018-10-03 15:32:49 +10:00
Kconfig powerpc/32: add stack protector support 2018-10-03 15:40:03 +10:00
Kconfig.debug Kconfig: consolidate the "Kernel hacking" menu 2018-08-02 08:06:48 +09:00
Makefile powerpc/32: add stack protector support 2018-10-03 15:40:03 +10:00
Makefile.postlink License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00