sched: Fix an RCU warning in print_task()
authorLi Zefan <lizf@cn.fujitsu.com>
Thu, 22 Apr 2010 09:30:40 +0000 (17:30 +0800)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Tue, 4 May 2010 16:25:01 +0000 (09:25 -0700)
commitb629317e66fb1c6066c550dded45ab85a936163c
treef618cd5bc21001144999a48bcb57c4bef725db06
parentfae9c791703606636c1220e47f6690660042ce7f
sched: Fix an RCU warning in print_task()

With CONFIG_PROVE_RCU=y, a warning can be triggered:

  $ cat /proc/sched_debug

...
kernel/cgroup.c:1649 invoked rcu_dereference_check() without protection!
...

Both cgroup_path() and task_group() should be called with either
rcu_read_lock or cgroup_mutex held.

The rcu_dereference_check() does include cgroup_lock_is_held(), so we
know that this lock is not held.  Therefore, in a CONFIG_PREEMPT kernel,
to say nothing of a CONFIG_PREEMPT_RT kernel, the original code could
have ended up copying a string out of the freelist.

This patch inserts RCU read-side primitives needed to prevent this
scenario.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
kernel/sched_debug.c