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

2016-02-25 Thread Al Viro
On Thu, Feb 25, 2016 at 09:11:44AM +0100, Peter Zijlstra wrote: > > Out of curiousity - where did that stray wakeup come from? PTRACE_KILL > > used to trigger those, but that got fixed. How does one trigger that > > kind of bugs on the current kernels? > > Its a regular TASK_INTERRUPTIBLE

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

2016-02-25 Thread Al Viro
On Thu, Feb 25, 2016 at 09:11:44AM +0100, Peter Zijlstra wrote: > > Out of curiousity - where did that stray wakeup come from? PTRACE_KILL > > used to trigger those, but that got fixed. How does one trigger that > > kind of bugs on the current kernels? > > Its a regular TASK_INTERRUPTIBLE

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

2016-02-25 Thread Peter Zijlstra
On Thu, Feb 25, 2016 at 03:18:52AM +, Al Viro wrote: > On Mon, Jan 25, 2016 at 08:09:15PM +0100, Oleg Nesterov wrote: > > On 01/25, Sasha Levin wrote: > > > > > > A random wakeup can get us out of sigsuspend() without TIF_SIGPENDING > > > being set. > > > > and TIF_RESTORE_SIGMASK is just

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

2016-02-25 Thread Peter Zijlstra
On Thu, Feb 25, 2016 at 03:18:52AM +, Al Viro wrote: > On Mon, Jan 25, 2016 at 08:09:15PM +0100, Oleg Nesterov wrote: > > On 01/25, Sasha Levin wrote: > > > > > > A random wakeup can get us out of sigsuspend() without TIF_SIGPENDING > > > being set. > > > > and TIF_RESTORE_SIGMASK is just

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

2016-02-24 Thread Al Viro
On Mon, Jan 25, 2016 at 08:09:15PM +0100, Oleg Nesterov wrote: > On 01/25, Sasha Levin wrote: > > > > A random wakeup can get us out of sigsuspend() without TIF_SIGPENDING > > being set. > > and TIF_RESTORE_SIGMASK is just wrong in this case. I'd say this is the > bugfix, not work-around ;) > >

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

2016-02-24 Thread Al Viro
On Mon, Jan 25, 2016 at 08:09:15PM +0100, Oleg Nesterov wrote: > On 01/25, Sasha Levin wrote: > > > > A random wakeup can get us out of sigsuspend() without TIF_SIGPENDING > > being set. > > and TIF_RESTORE_SIGMASK is just wrong in this case. I'd say this is the > bugfix, not work-around ;) > >

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

2016-01-27 Thread Oleg Nesterov
On 01/27, Andrew Morton wrote: > > On Wed, 27 Jan 2016 17:41:54 +0100 Oleg Nesterov wrote: > > > IOW, signal_pending() is the "special" condition, you do not need to > > serialize > > this check with task->state setting, exactly because schedule() knows about > > the > > signals. > > So it's

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

2016-01-27 Thread Andrew Morton
On Wed, 27 Jan 2016 17:41:54 +0100 Oleg Nesterov wrote: > > But it did get me to > > look at the patch again: > > > > + while (!signal_pending(current)) { > > + __set_current_state(TASK_INTERRUPTIBLE); > > + schedule(); > > + } > > > > That should very

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

2016-01-27 Thread Peter Zijlstra
On Wed, Jan 27, 2016 at 05:41:54PM +0100, Oleg Nesterov wrote: > Why? It should work either way. Yes, signal_wakeup() can come right before > __set_current_state(TASK_INTERRUPTIBLE) but this is fine, __schedule() must > not > sleep if signal_pending() == T, Urgh yes, I always forget this :/

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

2016-01-27 Thread Sasha Levin
On 01/27/2016 03:44 AM, Peter Zijlstra wrote: > On Tue, Jan 26, 2016 at 10:10:09PM +0100, Oleg Nesterov wrote: > >> 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

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

2016-01-27 Thread Oleg Nesterov
On 01/27, Peter Zijlstra wrote: > > On Tue, Jan 26, 2016 at 10:10:09PM +0100, Oleg Nesterov wrote: > > > 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

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

2016-01-27 Thread Peter Zijlstra
On Tue, Jan 26, 2016 at 10:10:09PM +0100, Oleg Nesterov wrote: > 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

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

2016-01-27 Thread Oleg Nesterov
On 01/27, Peter Zijlstra wrote: > > On Tue, Jan 26, 2016 at 10:10:09PM +0100, Oleg Nesterov wrote: > > > 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

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

2016-01-27 Thread Peter Zijlstra
On Wed, Jan 27, 2016 at 05:41:54PM +0100, Oleg Nesterov wrote: > Why? It should work either way. Yes, signal_wakeup() can come right before > __set_current_state(TASK_INTERRUPTIBLE) but this is fine, __schedule() must > not > sleep if signal_pending() == T, Urgh yes, I always forget this :/

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

2016-01-27 Thread Sasha Levin
On 01/27/2016 03:44 AM, Peter Zijlstra wrote: > On Tue, Jan 26, 2016 at 10:10:09PM +0100, Oleg Nesterov wrote: > >> 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

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

2016-01-27 Thread Andrew Morton
On Wed, 27 Jan 2016 17:41:54 +0100 Oleg Nesterov wrote: > > But it did get me to > > look at the patch again: > > > > + while (!signal_pending(current)) { > > + __set_current_state(TASK_INTERRUPTIBLE); > > + schedule(); > > + } > > > >

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

2016-01-27 Thread Oleg Nesterov
On 01/27, Andrew Morton wrote: > > On Wed, 27 Jan 2016 17:41:54 +0100 Oleg Nesterov wrote: > > > IOW, signal_pending() is the "special" condition, you do not need to > > serialize > > this check with task->state setting, exactly because schedule() knows about > > the > >

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

2016-01-27 Thread Peter Zijlstra
On Tue, Jan 26, 2016 at 10:10:09PM +0100, Oleg Nesterov wrote: > 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

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

2016-01-26 Thread Oleg Nesterov
On 01/25, Andrew Morton wrote: > > On Mon, 25 Jan 2016 10:21:46 -0500 Sasha Levin 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

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

2016-01-26 Thread Oleg Nesterov
On 01/26, Ingo Molnar wrote: > > * Sasha Levin 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 > > --- > > kernel/signal.c |6

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

2016-01-26 Thread Oleg Nesterov
On 01/26, Ingo Molnar wrote: > > * Sasha Levin 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

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

2016-01-26 Thread Oleg Nesterov
On 01/25, Andrew Morton wrote: > > On Mon, 25 Jan 2016 10:21:46 -0500 Sasha Levin 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

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

2016-01-25 Thread Ingo Molnar
* Sasha Levin 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 > --- > kernel/signal.c |6 -- > 1 file changed, 4 insertions(+), 2

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

2016-01-25 Thread Andrew Morton
On Mon, 25 Jan 2016 10:21:46 -0500 Sasha Levin 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

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

2016-01-25 Thread Peter Zijlstra
On Mon, Jan 25, 2016 at 08:09:15PM +0100, Oleg Nesterov wrote: > On 01/25, Sasha Levin wrote: > > > > A random wakeup can get us out of sigsuspend() without TIF_SIGPENDING > > being set. > > and TIF_RESTORE_SIGMASK is just wrong in this case. I'd say this is the > bugfix, not work-around ;)

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

2016-01-25 Thread Oleg Nesterov
On 01/25, Sasha Levin wrote: > > A random wakeup can get us out of sigsuspend() without TIF_SIGPENDING > being set. and TIF_RESTORE_SIGMASK is just wrong in this case. I'd say this is the bugfix, not work-around ;) > Avoid that by making sure we were signaled, like sys_pause() does. > >

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

2016-01-25 Thread Sasha Levin
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 --- kernel/signal.c |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/signal.c

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

2016-01-25 Thread Ingo Molnar
* Sasha Levin 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 > --- > kernel/signal.c |6

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

2016-01-25 Thread Sasha Levin
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 --- kernel/signal.c |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git

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

2016-01-25 Thread Andrew Morton
On Mon, 25 Jan 2016 10:21:46 -0500 Sasha Levin 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

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

2016-01-25 Thread Oleg Nesterov
On 01/25, Sasha Levin wrote: > > A random wakeup can get us out of sigsuspend() without TIF_SIGPENDING > being set. and TIF_RESTORE_SIGMASK is just wrong in this case. I'd say this is the bugfix, not work-around ;) > Avoid that by making sure we were signaled, like sys_pause() does. > >

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

2016-01-25 Thread Peter Zijlstra
On Mon, Jan 25, 2016 at 08:09:15PM +0100, Oleg Nesterov wrote: > On 01/25, Sasha Levin wrote: > > > > A random wakeup can get us out of sigsuspend() without TIF_SIGPENDING > > being set. > > and TIF_RESTORE_SIGMASK is just wrong in this case. I'd say this is the > bugfix, not work-around ;)