Bug 201891 - “-mstack-protector-guard-offset=xxx” got lost, for out-of-tree modules, which cause it's kernel stack corrupted
Summary: “-mstack-protector-guard-offset=xxx” got lost, for out-of-tree modules, which...
Status: NEW
Alias: None
Product: Other
Classification: Unclassified
Component: Modules (show other bugs)
Hardware: PPC-32 Linux
: P1 high
Assignee: other_configuration@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-05 07:51 UTC by wangxu
Modified: 2020-07-31 12:58 UTC (History)
2 users (show)

See Also:
Kernel Version: 4.20-rc5
Subsystem:
Regression: No
Bisected commit-id:


Attachments
“-mstack-protector-guard-offset=xxx” got lost, for out-of-tree modules, which cause it's kernel stack corrupted (680 bytes, patch)
2018-12-05 07:51 UTC, wangxu
Details | Diff

Description wangxu 2018-12-05 07:51:11 UTC
Created attachment 279859 [details]
“-mstack-protector-guard-offset=xxx” got lost, for out-of-tree modules, which cause it's kernel stack corrupted

"-mstack-protector-guard-offset=xxx" got lost, when build modules out-of-tree for PPC32 and PPC64. As a result, for out-of-tree modules, the default offset value was used( -0x7008 for PPC32), which may cause out-of-tree build modules panic.

Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: cd5df2c4

CPU:0 PID: 1278 Comm: createfile Tainted G O 4.20
Call Trace:
....

Further more, 
" $(eval KBUILD_CFLAGS_MODULE += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h)) " was set in arch/powerpc/Makefile only, and when build out-of-tree modules, arch/powerpc/Makefile will not be included. This patch looks ugly, but works well...


--- a/Makefile  2018-12-05 15:46:18.957594000 +0800
+++ b/Makefile  2018-12-05 15:46:33.353594000 +0800
@@ -645,6 +645,11 @@
 PHONY += include/config/auto.conf

 include/config/auto.conf:
+ifdef CONFIG_PPC64
+       $(eval KBUILD_CFLAGS_MODULE += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
+else ifdef CONFIG_PPC32
+       $(eval KBUILD_CFLAGS_MODULE += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
+endif
        $(Q)test -e include/generated/autoconf.h -a -e $@ || (          \
        echo >&2;                                                       \
        echo >&2 "  ERROR: Kernel configuration is invalid.";           \




Reference:
1. For gcc-7.3.0, the default stack-protector-guard-offset = TARGET_THREAD_SSP_OFFSET. 
   gcc/config/rs6000/linux64.h 
   #define TARGET_THREAD_SSP_OFFSET        (TARGET_64BIT ? -0x7010 : -0x7008)

Note You need to log in before you can comment on or make changes to this bug.