public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -mm 2/3] proc: make collect_sigign_sigcatch() rcu-safe
@ 2010-03-22 18:41 Oleg Nesterov
  2010-04-09 19:53 ` Roland McGrath
  0 siblings, 1 reply; 3+ messages in thread
From: Oleg Nesterov @ 2010-03-22 18:41 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Alexey Dobriyan, Eric W. Biederman, Roland McGrath, linux-kernel

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);


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -mm 2/3] proc: make collect_sigign_sigcatch() rcu-safe
  2010-03-22 18:41 [PATCH -mm 2/3] proc: make collect_sigign_sigcatch() rcu-safe Oleg Nesterov
@ 2010-04-09 19:53 ` Roland McGrath
  2010-04-12 20:26   ` Oleg Nesterov
  0 siblings, 1 reply; 3+ messages in thread
From: Roland McGrath @ 2010-04-09 19:53 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Andrew Morton, Alexey Dobriyan, Eric W. Biederman, linux-kernel

> 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.

In v2.6.34-rc3-500-g0eddb51 this isn't possible because the calls from
task_sig() and do_task_stat() are under siglock.  Is that locking removed
by another pending change?


Thanks,
Roland

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -mm 2/3] proc: make collect_sigign_sigcatch() rcu-safe
  2010-04-09 19:53 ` Roland McGrath
@ 2010-04-12 20:26   ` Oleg Nesterov
  0 siblings, 0 replies; 3+ messages in thread
From: Oleg Nesterov @ 2010-04-12 20:26 UTC (permalink / raw)
  To: Roland McGrath
  Cc: Andrew Morton, Alexey Dobriyan, Eric W. Biederman, linux-kernel

On 04/09, Roland McGrath wrote:
>
> > 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.
>
> In v2.6.34-rc3-500-g0eddb51 this isn't possible because the calls from
> task_sig() and do_task_stat() are under siglock.

Yes sure. If it is called under ->siglock we have no races we should
worry about.

> Is that locking removed
> by another pending change?

Yes, the next 3/3 patch.

Oleg.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-12 20:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-22 18:41 [PATCH -mm 2/3] proc: make collect_sigign_sigcatch() rcu-safe Oleg Nesterov
2010-04-09 19:53 ` Roland McGrath
2010-04-12 20:26   ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox