Skip to contentSkip to conversation

cls_cgroup: Fix rcu lockdep warning

PATCH Applied Li Zefan 2 participants 2 messages Sep 3, 2010

Subsystems (2)
lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH v2 1/1 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.

---
 include/net/cls_cgroup.h |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
include/net/cls_cgroup.h +8 -2
index dd1fdb8..a4dc5b0 100644
@@ -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;
Signature · 1 line
1.6.3
maintainer Applied
#1 lore raw

From: Li Zefan <[email protected]>
Date: Fri, 03 Sep 2010 09:42:43 +0800

Quoted 9 lines

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.

Applied, thanks.