[PATCH] cpuset: Add missing rcu read locks

From: Sasha Levin
Date: Thu Feb 27 2014 - 09:21:32 EST


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.

Signed-off-by: Sasha Levin <sasha.levin@xxxxxxxxxx>
---
kernel/cpuset.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index be9c1da..64bd8a4 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -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);

--
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/