avoid spurious POLLIN returns in signalfd
authorDavide Libenzi <davidel@xmailserver.org>
Wed, 27 Jun 2007 21:09:59 +0000 (14:09 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Thu, 28 Jun 2007 18:34:54 +0000 (11:34 -0700)
The new code in kernel/signal.c does not allow fetching private signals
from another task.  This patch avoid spurious POLLIN returns from a
signalfd poll(2) operation.

Signed-off-by: Davide Libenzi <davidel@xmailserver.org>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/signalfd.c

index f1da89203a9aeea3108fe9270169c501df821129..3b07f26d984d6bc6ee35eb7bce1e834d1e594da1 100644 (file)
@@ -133,7 +133,8 @@ static unsigned int signalfd_poll(struct file *file, poll_table *wait)
         * the peer disconnects.
         */
        if (signalfd_lock(ctx, &lk)) {
-               if (next_signal(&lk.tsk->pending, &ctx->sigmask) > 0 ||
+               if ((lk.tsk == current &&
+                    next_signal(&lk.tsk->pending, &ctx->sigmask) > 0) ||
                    next_signal(&lk.tsk->signal->shared_pending,
                                &ctx->sigmask) > 0)
                        events |= POLLIN;