All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Sasha Levin <sasha.levin@oracle.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	oleg@redhat.com, peterz@infradead.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [PATCH] signals: work around random wakeups in sigsuspend()
Date: Tue, 26 Jan 2016 07:44:25 +0100	[thread overview]
Message-ID: <20160126064425.GA5134@gmail.com> (raw)
In-Reply-To: <1453735306-13519-1-git-send-email-sasha.levin@oracle.com>


* Sasha Levin <sasha.levin@oracle.com> wrote:

> 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.
> 
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
>  kernel/signal.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/signal.c b/kernel/signal.c
> index 5da9180..3256c7e 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -3528,8 +3528,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;
>  }

So this does not appear to be anything new, right?

I agree with the fix, but I'm somewhat worried about the potential ABI impact: 
does anything exist out there that has learned to rely on spurious returns from 
SyS_sigsuspend() or SyS_rt_sigsuspend() system calls? These are one of the most 
frequently used system calls in signal based event loops.

Thanks,

	Ingo

  parent reply	other threads:[~2016-01-26  6:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-25 15:21 [PATCH] signals: work around random wakeups in sigsuspend() Sasha Levin
2016-01-25 19:09 ` Oleg Nesterov
2016-01-25 19:37   ` Peter Zijlstra
2016-02-25  3:18   ` Al Viro
2016-02-25  8:11     ` Peter Zijlstra
2016-02-25 17:34       ` Al Viro
2016-01-25 21:32 ` Andrew Morton
2016-01-26 21:10   ` Oleg Nesterov
2016-01-27  8:44     ` Peter Zijlstra
2016-01-27 16:41       ` Oleg Nesterov
2016-01-27 17:54         ` Peter Zijlstra
2016-01-27 18:39         ` Andrew Morton
2016-01-27 21:07           ` Oleg Nesterov
2016-01-27 17:24       ` Sasha Levin
2016-01-26  6:44 ` Ingo Molnar [this message]
2016-01-26 15:05   ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160126064425.GA5134@gmail.com \
    --to=mingo@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sasha.levin@oracle.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.