mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Davide Libenzi <davidel@xmailserver.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Oleg Nesterov <oleg@tv-sign.ru>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Nicholas Miell <nmiell@comcast.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Fix signalfd interaction with thread-private signals
Date: Tue, 19 Jun 2007 19:15:50 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0706191908000.16740@alien.or.mcafeemobile.com> (raw)
In-Reply-To: <1182302739.22337.9.camel@localhost.localdomain>

On Wed, 20 Jun 2007, Benjamin Herrenschmidt wrote:

> On Tue, 2007-06-19 at 16:49 -0700, Davide Libenzi wrote:
> 
> > Actually, I think signalfd is fine as is, with Ben's patch applied. 
> > Signalfd should only fetch shared signals, not specific ones (in any 
> > case).
> 
> The only advantage of that additional patch is that it will allow any
> thread to fetch its own private signals via signalfd, regardless of what
> context is attached to the signalfd in the first place.
> 
> Without the patch (with what's currently in Linus tree), a thread will
> only get its own private signals if it's also the thread that created
> the signalfd (and thus is attached to the signalfd "context").
> 
> I don't mind either way, up to you guys to decide what semantics you
> want.

Ok, why instead don't we go for something like the attached patch?
We exclude sync signals from signalfd, but we don't limit signalfd to 
shared signals. Ie, we should be able to fetch a signal sent with 
sys_tkill() to threads different from "current", that otherwise we would 
not be able to fetch.
Ben, sorry but my memory sucks ... the "notifier" thing was fine in that 
case, no?




- Davide



---
 fs/signalfd.c   |   10 +++++++++-
 kernel/signal.c |    6 +-----
 2 files changed, 10 insertions(+), 6 deletions(-)

Index: linux-2.6.mod/fs/signalfd.c
===================================================================
--- linux-2.6.mod.orig/fs/signalfd.c	2007-06-19 18:58:15.000000000 -0700
+++ linux-2.6.mod/fs/signalfd.c	2007-06-19 19:02:57.000000000 -0700
@@ -26,6 +26,14 @@
 #include <linux/anon_inodes.h>
 #include <linux/signalfd.h>
 
+/*
+ * Signals that a signalfd should never fetch.
+ */
+#define SIGNALFD_EXCLUDE_MASK (sigmask(SIGILL) | sigmask(SIGKILL) | \
+				       sigmask(SIGSTOP) | sigmask(SIGTRAP) | \
+				       sigmask(SIGFPE) | sigmask(SIGSEGV) | \
+				       sigmask(SIGBUS))
+
 struct signalfd_ctx {
 	struct list_head lnk;
 	wait_queue_head_t wqh;
@@ -320,7 +328,7 @@
 	if (sizemask != sizeof(sigset_t) ||
 	    copy_from_user(&sigmask, user_mask, sizeof(sigmask)))
 		return error = -EINVAL;
-	sigdelsetmask(&sigmask, sigmask(SIGKILL) | sigmask(SIGSTOP));
+	sigdelsetmask(&sigmask, SIGNALFD_EXCLUDE_MASK);
 	signotset(&sigmask);
 
 	if (ufd == -1) {
Index: linux-2.6.mod/kernel/signal.c
===================================================================
--- linux-2.6.mod.orig/kernel/signal.c	2007-06-19 18:55:07.000000000 -0700
+++ linux-2.6.mod/kernel/signal.c	2007-06-19 18:58:43.000000000 -0700
@@ -365,11 +365,7 @@
 {
 	int signr = 0;
 
-	/* We only dequeue private signals from ourselves, we don't let
-	 * signalfd steal them
-	 */
-	if (tsk == current)
-		signr = __dequeue_signal(&tsk->pending, mask, info);
+	signr = __dequeue_signal(&tsk->pending, mask, info);
 	if (!signr) {
 		signr = __dequeue_signal(&tsk->signal->shared_pending,
 					 mask, info);

  reply	other threads:[~2007-06-20  2:16 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-17  3:33 And now for something _totally_ different: Linux v2.6.22-rc5 Linus Torvalds
2007-06-17  7:15 ` Nicholas Miell
2007-06-17 17:01   ` Davide Libenzi
2007-06-17 19:26     ` Nicholas Miell
2007-06-17 23:49       ` Davide Libenzi
2007-06-18  0:08         ` Nicholas Miell
2007-06-18  0:20           ` Davide Libenzi
2007-06-18  0:43             ` Benjamin Herrenschmidt
2007-06-18  0:47               ` Davide Libenzi
2007-06-18 17:14               ` Linus Torvalds
2007-06-19  9:14                 ` Fix signalfd interaction with thread-private signals Oleg Nesterov
2007-06-19 12:09                   ` Benjamin Herrenschmidt
2007-06-19 14:06                     ` Oleg Nesterov
2007-06-19 19:53                       ` Davide Libenzi
2007-06-19 20:08                         ` Oleg Nesterov
2007-06-19 23:16                           ` Davide Libenzi
2007-06-19 23:24                       ` Benjamin Herrenschmidt
2007-06-20 11:14                         ` Oleg Nesterov
2007-06-20 17:38                           ` Linus Torvalds
2007-06-21  8:25                             ` Oleg Nesterov
2007-06-21 18:01                               ` Linus Torvalds
2007-06-21 18:23                                 ` Oleg Nesterov
2007-06-21 18:35                                   ` Linus Torvalds
2007-06-21 18:58                                     ` Oleg Nesterov
2007-06-21 23:30                                       ` Benjamin Herrenschmidt
2007-06-21 23:46                                         ` Linus Torvalds
2007-06-22  8:40                                         ` Oleg Nesterov
2007-06-22 11:41                                           ` Benjamin Herrenschmidt
2007-06-22 16:04                                             ` Oleg Nesterov
2007-06-22 22:33                                               ` Benjamin Herrenschmidt
2007-06-22 22:47                                                 ` Linus Torvalds
2007-06-22 23:00                                                   ` Davide Libenzi
2007-06-22 23:16                                                   ` Benjamin Herrenschmidt
2007-06-22 23:19                                                     ` Benjamin Herrenschmidt
2007-06-22 23:42                                                       ` Nicholas Miell
2007-06-23  0:12                                                         ` Davide Libenzi
2007-06-23  1:15                                                           ` Nicholas Miell
2007-06-23  6:05                                                           ` Benjamin Herrenschmidt
2007-06-23 22:54                                                             ` Nicholas Miell
2007-06-23 16:35                                                   ` Oleg Nesterov
2007-06-19 19:43                   ` Davide Libenzi
2007-06-19 19:59                     ` Oleg Nesterov
2007-06-19 23:49                   ` Davide Libenzi
2007-06-20  1:25                     ` Benjamin Herrenschmidt
2007-06-20  2:15                       ` Davide Libenzi [this message]
2007-06-20  3:46                         ` Benjamin Herrenschmidt
2007-06-20 15:54                           ` Davide Libenzi
2007-06-18 13:42         ` And now for something _totally_ different: Linux v2.6.22-rc5 Oleg Nesterov
2007-06-19 21:37 ` Mariusz Kozlowski
2007-06-19 21:48   ` Linus Torvalds
2007-06-19 22:31     ` Mariusz Kozlowski

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=Pine.LNX.4.64.0706191908000.16740@alien.or.mcafeemobile.com \
    --to=davidel@xmailserver.org \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nmiell@comcast.net \
    --cc=oleg@tv-sign.ru \
    --cc=torvalds@linux-foundation.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®