diff mbox series

Fix stack-protector for powerpc

Message ID cfd28ccf2ae6db320afd8d4542c57db0c12fca42.1700045185.git.christophe.leroy@csgroup.eu
State Accepted
Commit 4072572b0f8aeffedcd908dc45b7e046ee0554b0
Delegated to: Tom Rini
Headers show
Series Fix stack-protector for powerpc | expand

Commit Message

Christophe Leroy Nov. 15, 2023, 6:36 p.m. UTC
On powerpc, stack protector expects a function called
__stack_chk_fail_local() instead of __stack_chk_fail()

And some versions of GCC for powerpc default to TLS canary
instead of global canary, so always force GCC to use global
canary with -mstack-protector-guard=global

Cc: Joel Peshkin <joel.peshkin@broadcom.com>
Fixes: 4e9bce12432 ("Add support for stack-protector")
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 Makefile           | 1 +
 common/stackprot.c | 5 +++++
 2 files changed, 6 insertions(+)

Comments

Tom Rini Nov. 29, 2023, 4:57 p.m. UTC | #1
On Wed, Nov 15, 2023 at 07:36:36PM +0100, Christophe Leroy wrote:

> On powerpc, stack protector expects a function called
> __stack_chk_fail_local() instead of __stack_chk_fail()
> 
> And some versions of GCC for powerpc default to TLS canary
> instead of global canary, so always force GCC to use global
> canary with -mstack-protector-guard=global
> 
> Cc: Joel Peshkin <joel.peshkin@broadcom.com>
> Fixes: 4e9bce12432 ("Add support for stack-protector")
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>

Applied to u-boot/next, thanks!
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index ac65605a26..bddccc94e6 100644
--- a/Makefile
+++ b/Makefile
@@ -741,6 +741,7 @@  endif
 
 ifeq ($(CONFIG_STACKPROTECTOR),y)
 KBUILD_CFLAGS += $(call cc-option,-fstack-protector-strong)
+KBUILD_CFLAGS += $(call cc-option,-mstack-protector-guard=global)
 CFLAGS_EFI += $(call cc-option,-fno-stack-protector)
 else
 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
diff --git a/common/stackprot.c b/common/stackprot.c
index d5b7061665..6495951a77 100644
--- a/common/stackprot.c
+++ b/common/stackprot.c
@@ -18,3 +18,8 @@  void __stack_chk_fail(void)
 	panic("Stack smashing detected in function:\n%p relocated from %p",
 	      ra, ra - gd->reloc_off);
 }
+
+void __stack_chk_fail_local(void)
+{
+	__stack_chk_fail();
+}