mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fix the "remove task_ppid_nr_ns" commit
@ 2008-01-14 21:02 Oleg Nesterov
  2008-01-14 21:22 ` Roland McGrath
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Nesterov @ 2008-01-14 21:02 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Andrew Morton, Eric W. Biederman, Roland McGrath, linux-kernel

The commit 84427eaef1fb91704c7112bdb598c810003b99f3 (remove task_ppid_nr_ns)
moves the task_tgid_nr_ns(task->real_parent) outside of lock_task_sighand().
This is wrong, ->real_parent could be freed/reused.

Both ->parent/real_parent point to nothnig after __exit_signal() because we
remove the child from ->children list, and thus the child can't be reparented
when its parent exits.

rcu_read_lock() protects ->parent/real_parent, but _only_ if we know it was
valid before we take rcu lock.

Revert this part of the patch.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- t/fs/proc/array.c~ppid_fix	2008-01-14 23:45:35.000000000 +0300
+++ t/fs/proc/array.c	2008-01-14 23:59:27.000000000 +0300
@@ -426,7 +426,6 @@ static int do_task_stat(struct task_stru
 	cgtime = gtime = cputime_zero;
 
 	rcu_read_lock();
-	ppid = task_tgid_nr_ns(task->real_parent, ns);
 	if (lock_task_sighand(task, &flags)) {
 		struct signal_struct *sig = task->signal;
 
@@ -465,6 +464,7 @@ static int do_task_stat(struct task_stru
 		}
 
 		sid = task_session_nr_ns(task, ns);
+		ppid = task_tgid_nr_ns(task->real_parent, ns);
 		pgid = task_pgrp_nr_ns(task, ns);
 
 		unlock_task_sighand(task, &flags);


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

* Re: [PATCH] fix the "remove task_ppid_nr_ns" commit
  2008-01-14 21:02 [PATCH] fix the "remove task_ppid_nr_ns" commit Oleg Nesterov
@ 2008-01-14 21:22 ` Roland McGrath
  0 siblings, 0 replies; 2+ messages in thread
From: Roland McGrath @ 2008-01-14 21:22 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Linus Torvalds, Andrew Morton, Eric W. Biederman, linux-kernel

This preserves the parts of my change that mattered, is correctly more
conservative than my change was, and is fine with me.

Thanks,
Roland

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

end of thread, other threads:[~2008-01-14 21:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-14 21:02 [PATCH] fix the "remove task_ppid_nr_ns" commit Oleg Nesterov
2008-01-14 21:22 ` Roland McGrath

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®