Skip to content

Commit

Permalink
signals: disallow_signal() should flush the potentially pending signal
Browse files Browse the repository at this point in the history
disallow_signal() simply sets SIG_IGN, this is not enough and
recalc_sigpending() is simply pointless because in can never change the
state of TIF_SIGPENDING.

If we ignore a signal, we also need to do flush_sigqueue_mask() for the
case when this signal is pending, this way recalc_sigpending() can
actually clear TIF_SIGPENDING and we do not "leak" the allocated
siginfo's.

Signed-off-by: Oleg Nesterov <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Al Viro <[email protected]>
Cc: David Woodhouse <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Mathieu Desnoyers <[email protected]>
Cc: Richard Weinberger <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Tejun Heo <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
oleg-nesterov authored and torvalds committed Jun 6, 2014
1 parent ec5955b commit 580d34e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3085,8 +3085,15 @@ EXPORT_SYMBOL(allow_signal);

void disallow_signal(int sig)
{
sigset_t mask;

sigemptyset(&mask);
sigaddset(&mask, sig);

spin_lock_irq(&current->sighand->siglock);
current->sighand->action[(sig)-1].sa.sa_handler = SIG_IGN;
flush_sigqueue_mask(&mask, &current->signal->shared_pending);
flush_sigqueue_mask(&mask, &current->pending);
recalc_sigpending();
spin_unlock_irq(&current->sighand->siglock);
}
Expand Down

0 comments on commit 580d34e

Please sign in to comment.