Re: [PATCH] signals: work around random wakeups in sigsuspend()

From: Oleg Nesterov
Date: Tue Jan 26 2016 - 16:10:19 EST

On 01/25, Andrew Morton wrote:
> On Mon, 25 Jan 2016 10:21:46 -0500 Sasha Levin <sasha.levin@xxxxxxxxxx> 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.
> What we're lacking here is any description of the end-user-visible
> effects of the bug.

The warning in dmesg and -ERESTARTNOHAND which we should never return to user
space, although I bet nobody checks the error code returned by sigsuspend().

Plus, of course, sys_sigsuspend() can return while it should not.

> Enough for people to be able to decide (and to
> recognize!) whether their kernel needs this patch.</stdrefrain>

I don't think this problem is really serious, plus it is very unlikely. The
spurious return from sigsuspend() should not really hurt.

And, ironically, there is another more serious "reverse" problem ;) sigsuspend()
orany other user of -ERESTARTNOHAND can "miss" the signal, in a sense that the
kernel can wrongly restart this syscall after return from signal handler. This
is not trivial to fix..