aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorLi Zefan <lizefan@huawei.com>2014-04-17 01:53:08 -0400
committerTejun Heo <tj@kernel.org>2014-04-17 11:18:06 -0400
commite37a06f10994c2ba86f54d8f96734f2483a869b8 (patch)
tree6b53563f1b93588d1c40c52f0eecb049b20c5cff /kernel/cgroup.c
parentc9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff)
cgroup: fix the retry path of cgroup_mount()
If we hit the retry path, we'll call parse_cgroupfs_options() again, but the string we pass to it has been modified by the previous call to this function. This bug can be observed by: # mount -t cgroup -o name=foo,cpuset xxx /mnt && umount /mnt && \ mount -t cgroup -o name=foo,cpuset xxx /mnt mount: wrong fs type, bad option, bad superblock on xxx, missing codepage or helper program, or other error ... The second mount passed "name=foo,cpuset" to the parser, and then it hit the retry path and call the parser again, but this time the string passed to the parser is "name=foo". To fix this, we avoid calling parse_cgroupfs_options() again in this case. Signed-off-by: Li Zefan <lizefan@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 9fcdaa705b6c..11a03d67635a 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1495,7 +1495,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1495 */ 1495 */
1496 if (!use_task_css_set_links) 1496 if (!use_task_css_set_links)
1497 cgroup_enable_task_cg_lists(); 1497 cgroup_enable_task_cg_lists();
1498retry: 1498
1499 mutex_lock(&cgroup_tree_mutex); 1499 mutex_lock(&cgroup_tree_mutex);
1500 mutex_lock(&cgroup_mutex); 1500 mutex_lock(&cgroup_mutex);
1501 1501
@@ -1503,7 +1503,7 @@ retry:
1503 ret = parse_cgroupfs_options(data, &opts); 1503 ret = parse_cgroupfs_options(data, &opts);
1504 if (ret) 1504 if (ret)
1505 goto out_unlock; 1505 goto out_unlock;
1506 1506retry:
1507 /* look for a matching existing root */ 1507 /* look for a matching existing root */
1508 if (!opts.subsys_mask && !opts.none && !opts.name) { 1508 if (!opts.subsys_mask && !opts.none && !opts.name) {
1509 cgrp_dfl_root_visible = true; 1509 cgrp_dfl_root_visible = true;
@@ -1562,9 +1562,9 @@ retry:
1562 if (!atomic_inc_not_zero(&root->cgrp.refcnt)) { 1562 if (!atomic_inc_not_zero(&root->cgrp.refcnt)) {
1563 mutex_unlock(&cgroup_mutex); 1563 mutex_unlock(&cgroup_mutex);
1564 mutex_unlock(&cgroup_tree_mutex); 1564 mutex_unlock(&cgroup_tree_mutex);
1565 kfree(opts.release_agent);
1566 kfree(opts.name);
1567 msleep(10); 1565 msleep(10);
1566 mutex_lock(&cgroup_tree_mutex);
1567 mutex_lock(&cgroup_mutex);
1568 goto retry; 1568 goto retry;
1569 } 1569 }
1570 1570