klibc-bot for Ben Hutchings
2020-Aug-28 19:36 UTC
[klibc] [klibc:ia64-signal-fix] ia64: sigaction: Make signal updates atomic
Commit-ID: 623b03fb63f0c0473b378cf61c77258fd450b5a1 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=623b03fb63f0c0473b378cf61c77258fd450b5a1 Author: Ben Hutchings <ben at decadent.org.uk> AuthorDate: Fri, 28 Aug 2020 19:59:28 +0100 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Fri, 28 Aug 2020 20:22:50 +0100 [klibc] ia64: sigaction: Make signal updates atomic * If rt_sigaction() fails, undo the descriptor update * Mask the signal while we're (potentially) updating its descriptor Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/klibc/arch/ia64/sigaction.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/usr/klibc/arch/ia64/sigaction.c b/usr/klibc/arch/ia64/sigaction.c index e512bdcd..7f01ea44 100644 --- a/usr/klibc/arch/ia64/sigaction.c +++ b/usr/klibc/arch/ia64/sigaction.c @@ -21,6 +21,7 @@ __extern int ____rt_sigaction(int, const struct sigaction *, struct sigaction *, int __rt_sigaction(int sig, const struct sigaction *act, struct sigaction *oact, size_t size) { + sigset_t signal_mask, old_signal_mask; uintptr_t old_entry; int rv; @@ -29,6 +30,13 @@ int __rt_sigaction(int sig, const struct sigaction *act, return -1; } + /* Mask the signal to avoid races on access to its descriptor */ + sigemptyset(&signal_mask); + sigaddset(&signal_mask, sig); + rv = sigprocmask(SIG_BLOCK, &signal_mask, &old_signal_mask); + if (rv) + return -1; + if (oact) { old_entry = signal_descriptors[sig].entry; } @@ -41,6 +49,12 @@ int __rt_sigaction(int sig, const struct sigaction *act, rv = ____rt_sigaction(sig, act, oact, size); + if (rv) + signal_descriptors[sig].entry = old_entry; + + /* Restore signal mask */ + (void)sigprocmask(SIG_SETMASK, &old_signal_mask, NULL); + if (oact && oact->sa_handler != SIG_IGN && oact->sa_handler != SIG_DFL) { oact->sa_handler = (__sighandler_t)old_entry;
Reasonably Related Threads
- [klibc:master] ia64: sigaction: Make signal updates atomic
- [klibc:ia64-signal-fix] ia64: Fix sigaction struct layout and function implementation
- [klibc:master] ia64: Fix sigaction function implementation
- [PATCH 2/2] ia64: Fix sigaction struct layout and function implementation
- [klibc:ia64-signal-fix] signal: Move rt_sigaction() argument mangling to arch directories