]> Pileus Git - ~andy/linux/commitdiff
cpuset: fix a race condition in __cpuset_node_allowed_softwall()
authorLi Zefan <lizefan@huawei.com>
Thu, 27 Feb 2014 10:19:36 +0000 (18:19 +0800)
committerTejun Heo <tj@kernel.org>
Thu, 27 Feb 2014 14:39:54 +0000 (09:39 -0500)
It's not safe to access task's cpuset after releasing task_lock().
Holding callback_mutex won't help.

Cc: <stable@vger.kernel.org>
Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cpuset.c

index dba9e4aef69aefce92aa7f0cc1a31996c2da64d9..e6b1b66afe526acfa2a9ecbfc5bad9da76e8d9b4 100644 (file)
@@ -2482,9 +2482,9 @@ int __cpuset_node_allowed_softwall(int node, gfp_t gfp_mask)
 
        task_lock(current);
        cs = nearest_hardwall_ancestor(task_cs(current));
+       allowed = node_isset(node, cs->mems_allowed);
        task_unlock(current);
 
-       allowed = node_isset(node, cs->mems_allowed);
        mutex_unlock(&callback_mutex);
        return allowed;
 }