mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Linux Kernel list <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH/RFC] signal races/bugs, losing TIF_SIGPENDING and other woes
Date: Mon, 4 Jun 2007 18:44:00 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.0.98.0706041831400.23741@woody.linux-foundation.org> (raw)
In-Reply-To: <1181006711.31677.97.camel@localhost.localdomain>



On Tue, 5 Jun 2007, Benjamin Herrenschmidt wrote:
> 
>  - something calls recalc_sigpending_tsk() on thread A (for example,
>    something try to sends it S2 which is blocked). There is no longer
>    an active signal and thus TIF_SIGPENDING is cleared on thread A

I agree. That's unquestionably a bug. We should *never* clear sigpending 
for somebody else.

I have to say, your patch looks pretty ugly though. It also looks like 
it's rife to be subtly buggy (ie somebody calls "recalc_sigpending_tsk()" 
with "current" and doesn't realize the subtle rule.

So I'd rather just make it more explicit, and simple, and just have 
something really simple like the appended instead..

If we want to be fancier (and avoid the unnecessary compare for the cases 
where we statically know that we're calling it with "t" being "current"), 
we could make it an inline function and factor things out a bit, but I'm 
not sure how worthwhile that really is.

I also wonder if we should just remove the "clear_tsk_thread_flag()" thing 
*entirely*, and do it only in the do_sigal() path. THAT, however, is a 
much bigger change. This one-liner seems the trivial and most obvious 
patch.

Comments?

		Linus

---
 kernel/signal.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index acdfc05..61abd8d 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -105,7 +105,8 @@ static int recalc_sigpending_tsk(struct task_struct *t)
 		set_tsk_thread_flag(t, TIF_SIGPENDING);
 		return 1;
 	}
-	clear_tsk_thread_flag(t, TIF_SIGPENDING);
+	if (t == current)
+		clear_tsk_thread_flag(t, TIF_SIGPENDING);
 	return 0;
 }
 

  reply	other threads:[~2007-06-05  1:44 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-05  1:25 Benjamin Herrenschmidt
2007-06-05  1:44 ` Linus Torvalds [this message]
2007-06-05  2:10   ` Benjamin Herrenschmidt
2007-06-05  2:38     ` Davide Libenzi
2007-06-05  3:22       ` Benjamin Herrenschmidt
2007-06-05  6:09         ` Nicholas Miell
2007-06-05  7:27           ` Benjamin Herrenschmidt
2007-06-05 23:51             ` Nicholas Miell
2007-06-06  0:03               ` Benjamin Herrenschmidt
2007-06-06  0:11               ` Davide Libenzi
2007-06-06  0:15                 ` Nicholas Miell
2007-06-06  0:37                   ` Davide Libenzi
2007-06-06  0:58                     ` signalfd API issues (was Re: [PATCH/RFC] signal races/bugs, losing TIF_SIGPENDING and other woes) Nicholas Miell
2007-06-06  2:50                       ` Benjamin Herrenschmidt
2007-06-06  3:29                         ` Davide Libenzi
2007-06-06  3:37                           ` Linus Torvalds
2007-06-06  4:08                             ` Nicholas Miell
2007-06-06  4:18                               ` Benjamin Herrenschmidt
2007-06-06  4:35                             ` Davide Libenzi
2007-06-06  6:47                             ` Benjamin Herrenschmidt
2007-06-06 22:36                               ` Davide Libenzi
2007-06-06  3:52                           ` Benjamin Herrenschmidt
2007-06-06 12:52                         ` Jeff Dike
2007-06-06 22:43                           ` Paul Mackerras
2007-06-07  2:20                             ` Jeff Dike
2007-06-07  3:29                               ` Benjamin Herrenschmidt
2007-06-07 13:59                                 ` Jeff Dike
2007-06-07  3:21                           ` Benjamin Herrenschmidt
2007-06-05 15:52     ` [PATCH/RFC] signal races/bugs, losing TIF_SIGPENDING and other woes Davide Libenzi
2007-06-05 22:15       ` Benjamin Herrenschmidt
2007-06-05 22:50         ` Davide Libenzi
2007-06-05 22:59           ` Benjamin Herrenschmidt
2007-06-06  0:11             ` Davide Libenzi

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=alpine.LFD.0.98.0706041831400.23741@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulus@samba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®