[klibc] s390: Set sa_restorer for signals and disable executable stack
authorBen Hutchings <ben@decadent.org.uk>
Thu, 30 Apr 2020 02:38:34 +0000 (03:38 +0100)
committerBen Hutchings <benh@debian.org>
Fri, 30 Apr 2021 01:05:23 +0000 (02:05 +0100)
Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=c341c978e3024b9c575fac94012fc5b6f5679334

s390 allows specifiying a signal restorer in the usual way.  We
should do this to avoid needing an executable stack.

* Define a __sigreturn() routine that calls rt_sigreturn
* Force the SA_RESTORER flag on for all signal handlers, and set
  __sigreturn as the restorer if none is already set
* Force the SA_SIGINFO flag on for all signal handlers, so that we can
  always return from them with rt_sigreturn
* Set KLIBCEXECSTACK=n

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0003-klibc-s390-Set-sa_restorer-for-signals-and-disable-e.patch

usr/include/arch/s390/klibc/archconfig.h
usr/klibc/SYSCALLS.def
usr/klibc/arch/s390/MCONFIG

index d7a71a4b9207718c49098ffcc71f5064930ec548..b08bbb3ff80c20381ebae242acd096db09f4af08 100644 (file)
@@ -12,4 +12,9 @@
 /* Both s390 and s390x use the "32-bit" version of this structure */
 #define _KLIBC_STATFS_F_TYPE_64 0
 
+/* So that we can avoid stack trampolines */
+#define _KLIBC_NEEDS_SA_RESTORER 1
+/* Our restorer will call rt_sigreturn() */
+#define _KLIBC_NEEDS_SA_SIGINFO 1
+
 #endif                         /* _KLIBC_ARCHCONFIG_H */
index 461d9bf611196054dfd35e461bc2c621823e953c..30ff58b88d98e3359859478c78824c0101b4dc99 100644 (file)
@@ -212,7 +212,6 @@ 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();
 #else
 int sigaction::__sigaction(int, const struct sigaction *, struct sigaction *);
 int sigpending(sigset_t *);
@@ -229,6 +228,7 @@ int sigprocmask(int, const sigset_t *, sigset_t *);
 <sh,sparc,alpha,ppc,sparc64> int sigsuspend::__sigsuspend_s(sigset_t);
 <arm,frv,i386,m68k,mn10300,s390,s390x> int sigsuspend::__sigsuspend_xxs(int, int, sigset_t);
 #endif
+<s390,s390x,sparc64> void rt_sigreturn::__sigreturn();
 int kill(pid_t, int);
 <?> unsigned int alarm(unsigned int);
 int getitimer(int, struct itimerval *);
index c36acd7a30f720ede9cfaba4f4db4829c8a76203..7ffbcc4579e1d5c8f83854f1e14a2eee2d72054b 100644 (file)
@@ -22,6 +22,5 @@ endif
 KLIBCASMARCH           = s390
 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