All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Roland McGrath <roland@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH -mm 2/3] proc: make collect_sigign_sigcatch() rcu-safe
Date: Mon, 22 Mar 2010 19:41:33 +0100	[thread overview]
Message-ID: <20100322184133.GA3964@redhat.com> (raw)

Make collect_sigign_sigcatch() rcu-safe. The necessary changes are simple,
use rcu_dereference() to get ->sighand and check it is not NULL.

In theory, this ->sighand can be re-used under us (but it can't go away).
We could check task->sighand == sighand once again after the main loop
to prevent the race with exit/exec, but I don't think this is really
needed for fs/proc.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---

 fs/proc/array.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

--- 34-rc1/fs/proc/array.c~PROC_2_SIGCATCH_RCU	2010-03-22 17:04:44.000000000 +0100
+++ 34-rc1/fs/proc/array.c	2010-03-22 17:39:42.000000000 +0100
@@ -235,13 +235,18 @@ static void render_sigset_t(struct seq_f
 	seq_printf(m, "\n");
 }
 
+/* needs ->siglock or rcu_read_lock() */
 static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *ign,
 				    sigset_t *catch)
 {
+	struct sighand_struct *sighand = rcu_dereference(p->sighand);
 	struct k_sigaction *k;
 	int i;
 
-	k = p->sighand->action;
+	if (unlikely(!sighand))
+		return;
+
+	k = sighand->action;
 	for (i = 1; i <= _NSIG; ++i, ++k) {
 		if (k->sa.sa_handler == SIG_IGN)
 			sigaddset(ign, i);


             reply	other threads:[~2010-03-22 18:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-22 18:41 Oleg Nesterov [this message]
2010-04-09 19:53 ` [PATCH -mm 2/3] proc: make collect_sigign_sigcatch() rcu-safe Roland McGrath
2010-04-12 20:26   ` Oleg Nesterov

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=20100322184133.GA3964@redhat.com \
    --to=oleg@redhat.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roland@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.