klibc-bot for Ben Hutchings
2020-Aug-20 22:27 UTC
[klibc] [klibc:execstack-fixes] alpha: Set sa_restorer for signals and disable executable stack
Commit-ID: 7f84d11885cf3e9298d53a2714800a8ac9c4dd74 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=7f84d11885cf3e9298d53a2714800a8ac9c4dd74 Author: Ben Hutchings <ben at decadent.org.uk> AuthorDate: Thu, 30 Apr 2020 13:31:32 +0100 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Thu, 20 Aug 2020 23:22:58 +0100 [klibc] alpha: Set sa_restorer for signals and disable executable stack Add a __sigreturn routine 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/alpha/klibc/archconfig.h | 3 +++ usr/klibc/arch/alpha/Kbuild | 2 +- usr/klibc/arch/alpha/MCONFIG | 5 ++--- usr/klibc/arch/alpha/sigreturn.S | 16 ++++++++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/usr/include/arch/alpha/klibc/archconfig.h b/usr/include/arch/alpha/klibc/archconfig.h index 272fee0a..b80d299f 100644 --- a/usr/include/arch/alpha/klibc/archconfig.h +++ b/usr/include/arch/alpha/klibc/archconfig.h @@ -12,4 +12,7 @@ #define _KLIBC_USE_RT_SIG 1 #define _KLIBC_STATFS_F_TYPE_64 0 +/* So that we can avoid stack trampolines */ +#define _KLIBC_NEEDS_SA_RESTORER 1 + #endif /* _KLIBC_ARCHCONFIG_H */ diff --git a/usr/klibc/arch/alpha/Kbuild b/usr/klibc/arch/alpha/Kbuild index 2e566eb6..eef7cfb4 100644 --- a/usr/klibc/arch/alpha/Kbuild +++ b/usr/klibc/arch/alpha/Kbuild @@ -9,7 +9,7 @@ always := crt0.o targets := crt0.o -klib-y := pipe.o setjmp.o syscall.o sysdual.o +klib-y := pipe.o setjmp.o syscall.o sysdual.o sigreturn.o # Special CFLAGS for the divide code DIVCFLAGS = $(KLIBCREQFLAGS) $(KLIBCARCHREQFLAGS) \ diff --git a/usr/klibc/arch/alpha/MCONFIG b/usr/klibc/arch/alpha/MCONFIG index 072adb85..e71db264 100644 --- a/usr/klibc/arch/alpha/MCONFIG +++ b/usr/klibc/arch/alpha/MCONFIG @@ -15,6 +15,5 @@ KLIBCBITSIZE = 64 # the binary. KLIBCSHAREDFLAGS = -Ttext-segment 0x1c0000000 -# Kernel uses stack trampoline for signal return unless we set -# sa_restorer -KLIBCEXECSTACK := y +# Kernel uses our sa_restorer for signal return +KLIBCEXECSTACK := n diff --git a/usr/klibc/arch/alpha/sigreturn.S b/usr/klibc/arch/alpha/sigreturn.S new file mode 100644 index 00000000..95415edd --- /dev/null +++ b/usr/klibc/arch/alpha/sigreturn.S @@ -0,0 +1,16 @@ +/* + * arch/alpha/sigreturn.S + */ + +#include <asm/unistd.h> + + .text + .align 3 + .type __sigreturn, at function + .ent __sigreturn,0 + .globl __sigreturn +__sigreturn: + mov sp,a0 ; struct sigcontext on stack + lda v0,__NR_sigreturn(zero) + callsys + .size __sigreturn,.-__sigreturn
Reasonably Related Threads
- [klibc:execstack-fixes] alpha: Set sa_restorer for signals and disable executable stack
- [klibc:execstack-fixes] s390: Set sa_restorer for signals and disable executable stack
- [klibc:execstack-fixes] s390: Set sa_restorer for signals and disable executable stack
- [klibc:master] alpha: Pass restorer to rt_sigaction() and disable executable stack
- [klibc:execstack-fixes] sparc: Set sa_restorer for signals and disable executable stack