aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/cls_cgroup.h
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2010-09-02 11:42:43 -0400
committerDavid S. Miller <davem@davemloft.net>2010-09-03 12:55:24 -0400
commit3fb5a991916091a908d53608a5899240039fb51e (patch)
treefa8e5855de904daffba92bd177fa57ee85641521 /include/net/cls_cgroup.h
parent323f30b361b2e6febb9065ab4a1a5298acb66ac1 (diff)
cls_cgroup: Fix rcu lockdep warning
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>
Diffstat (limited to 'include/net/cls_cgroup.h')
-rw-r--r--include/net/cls_cgroup.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/net/cls_cgroup.h b/include/net/cls_cgroup.h
index 726cc3536409..ef6c24a529e1 100644
--- a/include/net/cls_cgroup.h
+++ b/include/net/cls_cgroup.h
@@ -27,11 +27,17 @@ struct cgroup_cls_state
27#ifdef CONFIG_NET_CLS_CGROUP 27#ifdef CONFIG_NET_CLS_CGROUP
28static inline u32 task_cls_classid(struct task_struct *p) 28static inline u32 task_cls_classid(struct task_struct *p)
29{ 29{
30 int classid;
31
30 if (in_interrupt()) 32 if (in_interrupt())
31 return 0; 33 return 0;
32 34
33 return container_of(task_subsys_state(p, net_cls_subsys_id), 35 rcu_read_lock();
34 struct cgroup_cls_state, css)->classid; 36 classid = container_of(task_subsys_state(p, net_cls_subsys_id),
37 struct cgroup_cls_state, css)->classid;
38 rcu_read_unlock();
39
40 return classid;
35} 41}
36#else 42#else
37extern int net_cls_subsys_id; 43extern int net_cls_subsys_id;