Skip to contentSkip to conversation

cpuset: Add missing rcu read locks

PATCH In review Sasha Levin 2 participants 2 messages Feb 27, 2014 – Mar 3, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpuset: Add missing rcu read locks

We call task_cs() which ends up going into cgroup code without having rcu read lock. Fix it by grabbing the lock before retrival of task_cs() and usage of the result.

---
 kernel/cpuset.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/cpuset.c +4 -0
index be9c1da..64bd8a4 100644
@@ -2240,8 +2240,10 @@ void cpuset_cpus_allowed(struct task_struct *tsk, struct cpumask *pmask)
 
 	mutex_lock(&callback_mutex);
 	task_lock(tsk);
+	rcu_read_lock();
 	cpus_cs = effective_cpumask_cpuset(task_cs(tsk));
 	guarantee_online_cpus(cpus_cs, pmask);
+	rcu_read_unlock();
 	task_unlock(tsk);
 	mutex_unlock(&callback_mutex);
 }
@@ -2296,8 +2298,10 @@ nodemask_t cpuset_mems_allowed(struct task_struct *tsk)
 
 	mutex_lock(&callback_mutex);
 	task_lock(tsk);
+	rcu_read_lock();
 	mems_cs = effective_nodemask_cpuset(task_cs(tsk));
 	guarantee_online_mems(mems_cs, &mask);
+	rcu_read_unlock();
 	task_unlock(tsk);
 	mutex_unlock(&callback_mutex);
 
Signature · 1 line
1.7.2.5
#1 lore raw
Quoted 4 lines · Sasha Levin

We call task_cs() which ends up going into cgroup code without having rcu read lock. Fix it by grabbing the lock before retrival of task_cs() and usage of the result.

Thanks for the patch.

Fengguang already reported it, and I've made a patch for it, but I was fixing two bugs for 3.14 and then waiting for them to be applied.

There're other places that rcu_read_lock() should be used, and we need to remove task_lock().