From: Li Zefan Date: Thu, 2 Sep 2010 15:42:43 +0000 (+0000) Subject: cls_cgroup: Fix rcu lockdep warning X-Git-Tag: v2.6.36-rc4~6^2~23 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=3fb5a991916091a908d53608a5899240039fb51e;p=~emulex%2Finfiniband.git 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 Signed-off-by: Li Zefan Signed-off-by: David S. Miller --- diff --git a/include/net/cls_cgroup.h b/include/net/cls_cgroup.h index 726cc353640..ef6c24a529e 100644 --- a/include/net/cls_cgroup.h +++ b/include/net/cls_cgroup.h @@ -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;