From: Sasha Levin Date: Fri, 5 Feb 2016 23:36:05 +0000 (-0800) Subject: UPSTREAM: signals: avoid random wakeups in sigsuspend() X-Git-Tag: firefly_0821_release~1268 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2303a7faef52063c2b71861516fb4eddc5af03f6;p=firefly-linux-kernel-4.4.55.git UPSTREAM: signals: avoid random wakeups in sigsuspend() A random wakeup can get us out of sigsuspend() without TIF_SIGPENDING being set. Avoid that by making sure we were signaled, like sys_pause() does. Change-Id: Ie647d2797416c6e53628174a07b62246e23081e7 Signed-off-by: Sasha Levin Acked-by: Oleg Nesterov Acked-by: Peter Zijlstra (Intel) Cc: Dmitry Vyukov Cc: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Huang, Tao (cherry picked from commit 823dd3224a07f618d652a7743c9603222d019de3) --- diff --git a/kernel/signal.c b/kernel/signal.c index f3f1f7a972fd..0508544c8ced 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -3508,8 +3508,10 @@ static int sigsuspend(sigset_t *set) current->saved_sigmask = current->blocked; set_current_blocked(set); - __set_current_state(TASK_INTERRUPTIBLE); - schedule(); + while (!signal_pending(current)) { + __set_current_state(TASK_INTERRUPTIBLE); + schedule(); + } set_restore_sigmask(); return -ERESTARTNOHAND; }