Codebase list klibc / b22afdb
Replace alpha sa_restorer patch with a version that actually builds I now realise that I hadn't actually tested this patch at all before. So it's a good thing it only went to experimental. Ben Hutchings 3 years ago
2 changed file(s) with 59 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
00 klibc (2.0.8-3) UNRELEASED; urgency=medium
11
22 * s390: Define __sigreturn() on both s390 and s390x
3 * Revert "alpha: Set sa_restorer for signals and disable executable stack"
4 * alpha: Pass restorer to rt_sigaction() and disable executable stack
35
46 -- Ben Hutchings <benh@debian.org> Sun, 23 Aug 2020 01:51:10 +0100
57
00 From: Ben Hutchings <ben@decadent.org.uk>
1 Date: Thu, 30 Apr 2020 13:31:32 +0100
2 Subject: [klibc] alpha: Set sa_restorer for signals and disable executable stack
3 Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit?id=7f84d11885cf3e9298d53a2714800a8ac9c4dd74
1 Date: Sun, 23 Aug 2020 15:18:19 +0100
2 Subject: [klibc] alpha: Pass restorer to rt_sigaction() and disable executable stack
43
5 Add a __sigreturn routine and point sa_restorer to it by default, so
6 that the kernel doesn't create stack trampolines for signal return.
7 With that done, we no longer need an executable stack.
4 alpha does not support the SA_RESTORER flag, but allows specifiying a
5 restorer callback as an additional parameter to rt_sigaction().
6
7 Define an __rt_sigreturn routine and pass that, so that the kernel
8 doesn't create stack trampolines for signal return. With that done,
9 we no longer need an executable stack.
810
911 Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
1012 ---
11 usr/include/arch/alpha/klibc/archconfig.h | 3 +++
13 usr/include/arch/alpha/klibc/archsignal.h | 8 +++++++-
1214 usr/klibc/arch/alpha/Kbuild | 2 +-
1315 usr/klibc/arch/alpha/MCONFIG | 5 ++---
14 usr/klibc/arch/alpha/sigreturn.S | 16 ++++++++++++++++
15 4 files changed, 22 insertions(+), 4 deletions(-)
16 create mode 100644 usr/klibc/arch/alpha/sigreturn.S
16 usr/klibc/arch/alpha/rt_sigreturn.S | 18 ++++++++++++++++++
17 usr/klibc/sigaction.c | 2 +-
18 5 files changed, 29 insertions(+), 6 deletions(-)
19 create mode 100644 usr/klibc/arch/alpha/rt_sigreturn.S
1720
18 diff --git a/usr/include/arch/alpha/klibc/archconfig.h b/usr/include/arch/alpha/klibc/archconfig.h
19 index 272fee0a..b80d299f 100644
20 --- a/usr/include/arch/alpha/klibc/archconfig.h
21 +++ b/usr/include/arch/alpha/klibc/archconfig.h
22 @@ -12,4 +12,7 @@
23 #define _KLIBC_USE_RT_SIG 1
24 #define _KLIBC_STATFS_F_TYPE_64 0
21 diff --git a/usr/include/arch/alpha/klibc/archsignal.h b/usr/include/arch/alpha/klibc/archsignal.h
22 index 2193a352..0906f338 100644
23 --- a/usr/include/arch/alpha/klibc/archsignal.h
24 +++ b/usr/include/arch/alpha/klibc/archsignal.h
25 @@ -9,6 +9,12 @@
26 #define _KLIBC_ARCHSIGNAL_H
2527
26 +/* So that we can avoid stack trampolines */
27 +#define _KLIBC_NEEDS_SA_RESTORER 1
28 #include <asm/signal.h>
29 -/* No special stuff for this architecture */
2830 +
29 #endif /* _KLIBC_ARCHCONFIG_H */
31 +/*
32 + * Passed as last parameter to __rt_sigaction(). It is a function
33 + * that should have type void (void), but syscalls.pl can't parse
34 + * function types in syscall parameters.
35 + */
36 +extern void __rt_sigreturn;
37
38 #endif
3039 diff --git a/usr/klibc/arch/alpha/Kbuild b/usr/klibc/arch/alpha/Kbuild
31 index 2e566eb6..eef7cfb4 100644
40 index 2e566eb6..6a62d47d 100644
3241 --- a/usr/klibc/arch/alpha/Kbuild
3342 +++ b/usr/klibc/arch/alpha/Kbuild
3443 @@ -9,7 +9,7 @@
3645 always := crt0.o
3746 targets := crt0.o
3847 -klib-y := pipe.o setjmp.o syscall.o sysdual.o
39 +klib-y := pipe.o setjmp.o syscall.o sysdual.o sigreturn.o
48 +klib-y := pipe.o setjmp.o syscall.o sysdual.o rt_sigreturn.o
4049
4150 # Special CFLAGS for the divide code
4251 DIVCFLAGS = $(KLIBCREQFLAGS) $(KLIBCARCHREQFLAGS) \
5362 -KLIBCEXECSTACK := y
5463 +# Kernel uses our sa_restorer for signal return
5564 +KLIBCEXECSTACK := n
56 diff --git a/usr/klibc/arch/alpha/sigreturn.S b/usr/klibc/arch/alpha/sigreturn.S
65 diff --git a/usr/klibc/arch/alpha/rt_sigreturn.S b/usr/klibc/arch/alpha/rt_sigreturn.S
5766 new file mode 100644
58 index 00000000..95415edd
67 index 00000000..e41b5544
5968 --- /dev/null
60 +++ b/usr/klibc/arch/alpha/sigreturn.S
61 @@ -0,0 +1,16 @@
69 +++ b/usr/klibc/arch/alpha/rt_sigreturn.S
70 @@ -0,0 +1,18 @@
6271 +/*
6372 + * arch/alpha/sigreturn.S
6473 + */
6574 +
75 +#include <machine/asm.h>
6676 +#include <asm/unistd.h>
6777 +
6878 + .text
6979 + .align 3
70 + .type __sigreturn,@function
71 + .ent __sigreturn,0
72 + .globl __sigreturn
73 +__sigreturn:
74 + mov sp,a0 ; struct sigcontext on stack
75 + lda v0,__NR_sigreturn(zero)
80 + .type __rt_sigreturn,@function
81 + .ent __rt_sigreturn,0
82 + .globl __rt_sigreturn
83 +__rt_sigreturn:
84 + mov sp,a0 # struct sigcontext on stack
85 + lda v0,__NR_rt_sigreturn(zero)
7686 + callsys
77 + .size __sigreturn,.-__sigreturn
87 + .size __rt_sigreturn,.-__rt_sigreturn
88 + .end __rt_sigreturn
89 diff --git a/usr/klibc/sigaction.c b/usr/klibc/sigaction.c
90 index 19a8a54b..108c8385 100644
91 --- a/usr/klibc/sigaction.c
92 +++ b/usr/klibc/sigaction.c
93 @@ -47,7 +47,7 @@ int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
94 rv = __rt_sigaction(sig, act, oact, restorer, sizeof(sigset_t));
95 }
96 # elif defined(__alpha__)
97 - rv = __rt_sigaction(sig, act, oact, sizeof(sigset_t), NULL);
98 + rv = __rt_sigaction(sig, act, oact, sizeof(sigset_t), &__rt_sigreturn);
99 # else
100 rv = __rt_sigaction(sig, act, oact, sizeof(sigset_t));
101 # endif