[klibc] [klibc:execstack-fixes] sparc: Set sa_restorer for signals and disable executable stack

klibc-bot for Ben Hutchings ben at decadent.org.uk
Thu Aug 20 15:27:06 PDT 2020


Commit-ID:  ba0cf42e26846a1dad444e205932caef78d467ee
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=ba0cf42e26846a1dad444e205932caef78d467ee
Author:     Ben Hutchings <ben at decadent.org.uk>
AuthorDate: Thu, 30 Apr 2020 13:56:47 +0100
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Thu, 20 Aug 2020 23:23:04 +0100

[klibc] sparc: Set sa_restorer for signals and disable executable stack

Add a __sigreturn stub and point sa_restorer to it by default, so
that the kernel doesn't create stack trampolines for signal return.
With that done, we no longer need an executable stack.

Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

---
 usr/include/arch/sparc/klibc/archconfig.h | 3 +++
 usr/klibc/SYSCALLS.def                    | 2 +-
 usr/klibc/arch/sparc/MCONFIG              | 5 ++---
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/usr/include/arch/sparc/klibc/archconfig.h b/usr/include/arch/sparc/klibc/archconfig.h
index 70d5ef08..ab2c5fd7 100644
--- a/usr/include/arch/sparc/klibc/archconfig.h
+++ b/usr/include/arch/sparc/klibc/archconfig.h
@@ -12,4 +12,7 @@
 #define _KLIBC_USE_RT_SIG 1	/* Use rt_* signals */
 #define _KLIBC_SYS_SOCKETCALL 1 /* Use sys_socketcall unconditionally */
 
+/* So that we can avoid stack trampolines */
+#define _KLIBC_NEEDS_SA_RESTORER 1
+
 #endif				/* _KLIBC_ARCHCONFIG_H */
diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def
index 16faabcb..0768df0d 100644
--- a/usr/klibc/SYSCALLS.def
+++ b/usr/klibc/SYSCALLS.def
@@ -212,7 +212,7 @@ ssize_t sendfile64,sendfile::sendfile(int, int, off_t *, size_t, off_t);
 int rt_sigsuspend::__rt_sigsuspend(const sigset_t *, size_t);
 int rt_sigpending::__rt_sigpending(sigset_t *, size_t);
 int rt_sigprocmask::__rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t);
-<sparc64> void rt_sigreturn::__sigreturn();
+<sparc,sparc64> void rt_sigreturn::__sigreturn();
 #else
 int sigaction::__sigaction(int, const struct sigaction *, struct sigaction *);
 int sigpending(sigset_t *);
diff --git a/usr/klibc/arch/sparc/MCONFIG b/usr/klibc/arch/sparc/MCONFIG
index cabc7cd4..fb68ba3f 100644
--- a/usr/klibc/arch/sparc/MCONFIG
+++ b/usr/klibc/arch/sparc/MCONFIG
@@ -18,6 +18,5 @@ KLIBCARCHREQFLAGS	+= -D__sparc32__
 # and call instructions have a 30-bit signed offset, << 2.
 KLIBCSHAREDFLAGS	 = -Ttext-segment 0x40000000
 
-# Kernel uses stack trampoline for signal return unless we set
-# sa_restorer
-KLIBCEXECSTACK := y
+# Kernel uses our sa_restorer for signal return
+KLIBCEXECSTACK := n


More information about the klibc mailing list