[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230408-nolibc-stackprotector-archs-v1-6-271f5c859c71@weissschuh.net>
Date: Mon, 17 Apr 2023 18:01:36 +0200
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Willy Tarreau <w@....eu>, Shuah Khan <shuah@...nel.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>
Cc: linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-riscv@...ts.infradead.org,
Thomas Weißschuh <linux@...ssschuh.net>
Subject: [PATCH 6/6] tools/nolibc: mips: add stackprotector support
Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
---
tools/include/nolibc/arch-mips.h | 8 +++++++-
tools/testing/selftests/nolibc/Makefile | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h
index 8822f150e72f..65c19ccc7f9d 100644
--- a/tools/include/nolibc/arch-mips.h
+++ b/tools/include/nolibc/arch-mips.h
@@ -179,14 +179,20 @@ struct sys_stat_struct {
char **environ __attribute__((weak));
const unsigned long *_auxv __attribute__((weak));
+#define __ARCH_SUPPORTS_STACK_PROTECTOR
+
/* startup code, note that it's called __start on MIPS */
-void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __start(void)
+void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protector)) __start(void)
{
__asm__ volatile (
/*".set nomips16\n"*/
".set push\n"
".set noreorder\n"
".option pic0\n"
+#ifdef NOLIBC_STACKPROTECTOR
+ "jal __stack_chk_init\n" /* initialize stack protector */
+ "nop\n" /* delayed slot */
+#endif
/*".ent __start\n"*/
/*"__start:\n"*/
"lw $a0,($sp)\n" /* argc was in the stack */
diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index efa7a51e0fcd..a7524445f33c 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -84,6 +84,7 @@ CFLAGS_STKP_x86_64 = $(CFLAGS_STACKPROTECTOR)
CFLAGS_STKP_x86 = $(CFLAGS_STACKPROTECTOR)
CFLAGS_STKP_arm64 = $(CFLAGS_STACKPROTECTOR)
CFLAGS_STKP_arm = $(CFLAGS_STACKPROTECTOR)
+CFLAGS_STKP_mips = $(CFLAGS_STACKPROTECTOR)
CFLAGS_STKP_riscv = $(CFLAGS_STACKPROTECTOR)
CFLAGS_STKP_loongarch = $(CFLAGS_STACKPROTECTOR)
CFLAGS_s390 = -m64
--
2.40.0
Powered by blists - more mailing lists