summaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorLi Zefan <lizefan@huawei.com>2014-06-04 10:48:15 +0200
committerTejun Heo <tj@kernel.org>2014-06-05 03:21:51 +0200
commit1f779fb28aa07350d72976d304591d216ca86f0e (patch)
treed172ba488c50cedbfd4f1d0f676b7a6512605d84 /kernel/cgroup.c
parentcgroup: disallow debug controller on the default hierarchy (diff)
downloadlinux-1f779fb28aa07350d72976d304591d216ca86f0e.tar.xz
linux-1f779fb28aa07350d72976d304591d216ca86f0e.zip
cgroup: don't destroy the default root
The default root is allocated and initialized at boot phase, so we shouldn't destroy the default root when it's umounted, otherwise it will lead to disaster. Just try mount and then umount the default root, and the kernel will crash immediately. v2: - No need to check for CSS_NO_REF in cgroup_get/put(). (Tejun) - Better call cgroup_put() for the default root in kill_sb(). (Tejun) - Add a comment. 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.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index a5f75ac4e793..3f46165829a4 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1780,8 +1780,11 @@ static void cgroup_kill_sb(struct super_block *sb)
* If @root doesn't have any mounts or children, start killing it.
* This prevents new mounts by disabling percpu_ref_tryget_live().
* cgroup_mount() may wait for @root's release.
+ *
+ * And don't kill the default root.
*/
- if (css_has_online_children(&root->cgrp.self))
+ if (css_has_online_children(&root->cgrp.self) ||
+ root == &cgrp_dfl_root)
cgroup_put(&root->cgrp);
else
percpu_ref_kill(&root->cgrp.self.refcnt);