Skip to content

Commit

Permalink
bsd_acct: plain current->real_parent access is not always safe
Browse files Browse the repository at this point in the history
This is minor, but dereferencing even current real_parent is not safe on debug
kernels, since the memory, this points to, can be unmapped - RCU protection is
required.

Besides, the tgid field is deprecated and is to be replaced with task_tgid_xxx
call (the 2nd patch), so RCU will be required anyway.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Cc: "Paul E. McKenney" <paulmck@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Pavel Emelyanov authored and Linus Torvalds committed Mar 25, 2008
1 parent 4dd4b92 commit a846a19
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kernel/acct.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,9 @@ static void do_acct_process(struct file *file)
#endif
#if ACCT_VERSION==3
ac.ac_pid = current->tgid;
ac.ac_ppid = current->real_parent->tgid;
rcu_read_lock();
ac.ac_ppid = rcu_dereference(current->real_parent)->tgid;
rcu_read_unlock();
#endif

spin_lock_irq(&current->sighand->siglock);
Expand Down

0 comments on commit a846a19

Please sign in to comment.