Skip to content

Commit

Permalink
cls_cgroup: Fix rcu lockdep warning
Browse files Browse the repository at this point in the history
Dave reported an rcu lockdep warning on 2.6.35.4 kernel

task->cgroups and task->cgroups->subsys[i] are protected by RCU.
So we avoid accessing invalid pointers here. This might happen,
for example, when you are deref-ing those pointers while someone
move @task from one cgroup to another.

Reported-by: Dave Jones <davej@redhat.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Li Zefan authored and David S. Miller committed Sep 3, 2010
1 parent 323f30b commit 3fb5a99
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/net/cls_cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ struct cgroup_cls_state
#ifdef CONFIG_NET_CLS_CGROUP
static inline u32 task_cls_classid(struct task_struct *p)
{
int classid;

if (in_interrupt())
return 0;

return container_of(task_subsys_state(p, net_cls_subsys_id),
struct cgroup_cls_state, css)->classid;
rcu_read_lock();
classid = container_of(task_subsys_state(p, net_cls_subsys_id),
struct cgroup_cls_state, css)->classid;
rcu_read_unlock();

return classid;
}
#else
extern int net_cls_subsys_id;
Expand Down

0 comments on commit 3fb5a99

Please sign in to comment.