Skip to content

Commit

Permalink
fix the "remove task_ppid_nr_ns" commit
Browse files Browse the repository at this point in the history
Commit 84427ea (remove task_ppid_nr_ns)
moved 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 nothing 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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Jan 14, 2008
1 parent 4fd3670 commit a98fdce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/proc/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole)
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;

Expand Down Expand Up @@ -465,6 +464,7 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole)
}

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

0 comments on commit a98fdce

Please sign in to comment.