Skip to content

Commit 101d9b0

Browse files
Matt FlemingRussell King
authored andcommitted
ARM: 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: Arnd Bergmann <arnd.bergmann@linaro.org> Cc: Dave Martin <dave.martin@linaro.org> Cc: Nicolas Pitre <nicolas.pitre@linaro.org> Cc: Will Deacon <will.deacon@arm.com> Acked-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent e88443c commit 101d9b0

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

‎arch/arm/kernel/signal.c‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ const unsigned long syscall_restart_code[2] = {
6666
*/
6767
asmlinkage int sys_sigsuspend(int restart, unsigned long oldmask, old_sigset_t mask)
6868
{
69-
mask &= _BLOCKABLE;
70-
spin_lock_irq(&current->sighand->siglock);
69+
sigset_t blocked;
70+
7171
current->saved_sigmask = current->blocked;
72-
siginitset(&current->blocked, mask);
73-
recalc_sigpending();
74-
spin_unlock_irq(&current->sighand->siglock);
72+
73+
mask &= _BLOCKABLE;
74+
siginitset(&blocked, mask);
75+
set_current_blocked(&blocked);
7576

7677
current->state = TASK_INTERRUPTIBLE;
7778
schedule();
@@ -281,10 +282,7 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
281282
err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set));
282283
if (err == 0) {
283284
sigdelsetmask(&set, ~_BLOCKABLE);
284-
spin_lock_irq(&current->sighand->siglock);
285-
current->blocked = set;
286-
recalc_sigpending();
287-
spin_unlock_irq(&current->sighand->siglock);
285+
set_current_blocked(&set);
288286
}
289287

290288
__get_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err);
@@ -637,13 +635,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
637635
/*
638636
* Block the signal if we were successful.
639637
*/
640-
spin_lock_irq(&tsk->sighand->siglock);
641-
sigorsets(&tsk->blocked, &tsk->blocked,
642-
&ka->sa.sa_mask);
643-
if (!(ka->sa.sa_flags & SA_NODEFER))
644-
sigaddset(&tsk->blocked, sig);
645-
recalc_sigpending();
646-
spin_unlock_irq(&tsk->sighand->siglock);
638+
block_sigmask(ka, sig);
647639

648640
return 0;
649641
}

0 commit comments

Comments
 (0)