Skip to content

Commit 2561b06

Browse files
Matt Flemingtorvalds
authored andcommitted
alpha: use set_current_blocked() and block_sigmask()
As described in e6fa16a ("signal: sigprocmask() should do retarget_shared_pending()") the modification of current->blocked is incorrect as we need to check for shared signals we're about to block. Also, use the new helper function introduced in commit 5e6292c ("signal: add block_sigmask() for adding sigmask to current->blocked") which centralises the code for updating current->blocked after successfully delivering a signal and reduces the amount of duplicate code across architectures. In the past some architectures got this code wrong, so using this helper function should stop that from happening again. Cc: Richard Henderson <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Matt Turner <[email protected]> Cc: Al Viro <[email protected]> Acked-by: Oleg Nesterov <[email protected]> Signed-off-by: Matt Fleming <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 234e340 commit 2561b06

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

arch/alpha/kernel/signal.c

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ SYSCALL_DEFINE5(rt_sigaction, int, sig, const struct sigaction __user *, act,
120120
*/
121121
SYSCALL_DEFINE1(sigsuspend, old_sigset_t, mask)
122122
{
123-
mask &= _BLOCKABLE;
124-
spin_lock_irq(&current->sighand->siglock);
123+
sigset_t blocked;
124+
125125
current->saved_sigmask = current->blocked;
126-
siginitset(&current->blocked, mask);
127-
recalc_sigpending();
128-
spin_unlock_irq(&current->sighand->siglock);
126+
127+
mask &= _BLOCKABLE;
128+
siginitset(&blocked, mask);
129+
set_current_blocked(&blocked);
129130

130131
current->state = TASK_INTERRUPTIBLE;
131132
schedule();
@@ -238,10 +239,7 @@ do_sigreturn(struct sigcontext __user *sc, struct pt_regs *regs,
238239
goto give_sigsegv;
239240

240241
sigdelsetmask(&set, ~_BLOCKABLE);
241-
spin_lock_irq(&current->sighand->siglock);
242-
current->blocked = set;
243-
recalc_sigpending();
244-
spin_unlock_irq(&current->sighand->siglock);
242+
set_current_blocked(&set);
245243

246244
if (restore_sigcontext(sc, regs, sw))
247245
goto give_sigsegv;
@@ -276,10 +274,7 @@ do_rt_sigreturn(struct rt_sigframe __user *frame, struct pt_regs *regs,
276274
goto give_sigsegv;
277275

278276
sigdelsetmask(&set, ~_BLOCKABLE);
279-
spin_lock_irq(&current->sighand->siglock);
280-
current->blocked = set;
281-
recalc_sigpending();
282-
spin_unlock_irq(&current->sighand->siglock);
277+
set_current_blocked(&set);
283278

284279
if (restore_sigcontext(&frame->uc.uc_mcontext, regs, sw))
285280
goto give_sigsegv;
@@ -501,14 +496,8 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
501496
else
502497
ret = setup_frame(sig, ka, oldset, regs, sw);
503498

504-
if (ret == 0) {
505-
spin_lock_irq(&current->sighand->siglock);
506-
sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
507-
if (!(ka->sa.sa_flags & SA_NODEFER))
508-
sigaddset(&current->blocked,sig);
509-
recalc_sigpending();
510-
spin_unlock_irq(&current->sighand->siglock);
511-
}
499+
if (ret == 0)
500+
block_sigmask(ka, sig);
512501

513502
return ret;
514503
}

0 commit comments

Comments
 (0)