Skip to contentSkip to conversation

cgroup: don't destroy the default root

PATCH Applied Li Zefan 2 participants 2 messages Jun 4, 2014 – Jun 5, 2014 cgroup

lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH v2 1/1 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.

---
 kernel/cgroup.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/cgroup.c +4 -1
index a5f75ac..3f46165 100644
@@ -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);
Signature · 1 line
1.8.0.2
maintainer Applied
#1 lore raw
Quoted 7 lines · Li Zefan

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.

Quoted 6 lines

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.

Applied to cgroup/for-3.16.

Thanks.

Signature · 1 line
tejun