[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070731210817.GA97@tv-sign.ru>
Date: Wed, 1 Aug 2007 01:08:17 +0400
From: Oleg Nesterov <oleg@...sign.ru>
To: Manfred Spraul <manfred@...orfullife.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, Roland McGrath <roland@...hat.com>
Subject: Re: [PATCH] Use ERESTARTNOHAND if poll() is interrupted by a signal
On 07/31, Manfred Spraul wrote:
>
> Mainline has the same problem: poll() returns to user space if it's
> interrupted by SIGSTOP/SIGCONT.
> >I guess the consequences of the thing-which-this-fixes aren't huge, s I ca
> >queue this up for 2.6.24, after Oleg's
> >do_poll-return-eintr-when-signalled.patch?
> >
> >
> Yes, please queue it: most/all linux versions show this behavior.
> Additionally, poll() is usually called in a loop and a spurious wakeup
> has no consequences.
... and so the current behaviour is more or less correct, even if not
optimal.
But this patch in fact adds a bug. We don't even need the "special"
signals like SIGSTOP/SIGCONT or freezer to hit this bug.
Suppose that sys_poll() was interrupted by a "normal" signal which
has a handler. It is quite possible that another thread can steal
this signal before us. Now, ERESTARTNOHAND means we restart sys_poll()
with the same (old) timeout, this means that sys_poll() does _not_
return when timeout expired (if no fds ready), and this is bug.
Also, the false signal_wake_up() is possible, and again, the spurious
-EINTR is better than restart with the same timeout.
What we need is ERESTART_RESTARTBLOCK, and restart_block.arg2 should
have the new timeout value, which takes the time we already slept
into account.
Oleg.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists