Skip to contentSkip to conversation

a fixlet for cgroups-make-cgroup_path-rcu-safe.patch

PATCH New Li Zefan 1 participant 1 message Dec 22, 2008 cgroup

lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH 1/1 a fixlet for cgroups-make-cgroup_path-rcu-safe.patch

With cgroups-make-cgroup_path-rcu-safe.patch applied, I can trigger kernel panic easily using this test program:

	for ((; ;))
	{
		mount -t cgroup -o debug xxx /mnt
		mkdir /mnt/0
		rmdir /mnt/0
		umount /mnt
	}

It's caused by the deactive_super() in rcu callback.

This patch restores the original code that call deactive_super() in cgroup_diput().

Also remove duplicated comment in cgroup.h added by the patch.

---
 include/linux/cgroup.h |    6 ------
 kernel/cgroup.c        |   11 ++++++-----
 2 files changed, 6 insertions(+), 11 deletions(-)
include/linux/cgroup.h renamed from include/linux/cgroup.h.orig +0 -6
index 880528d..e267e62 100644
@@ -334,12 +334,6 @@ int cgroup_add_files(struct cgroup *cgrp,
 
 int cgroup_is_removed(const struct cgroup *cgrp);
 
-/*
- * cgroup_path() fills in a filesystem-like path for the given cgroup
- * into "buf", up to "buflen" characters. Should be called with
- * cgroup_mutex held, or else in an RCU section with an RCU-protected
- * cgroup reference
- */
 int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen);
 
 int cgroup_task_count(const struct cgroup *cgrp);
kernel/cgroup.c renamed from kernel/cgroup.c.orig +6 -5
index 5cfd005..d49e97d 100644
@@ -598,11 +598,6 @@ static void cgroup_call_pre_destroy(struct cgroup *cgrp)
 static void free_cgroup_rcu(struct rcu_head *obj)
 {
 	struct cgroup *cgrp = container_of(obj, struct cgroup, rcu_head);
-	/*
-	 * Drop the active superblock reference that we took when we
-	 * created the cgroup
-	 */
-	deactivate_super(cgrp->root->sb);
 
 	kfree(cgrp);
 }
@@ -632,6 +627,12 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode)
 		cgrp->root->number_of_cgroups--;
 		mutex_unlock(&cgroup_mutex);
 
+		/*
+		 * Drop the active superblock reference that we took when we
+		 * created the cgroup
+		 */
+		deactivate_super(cgrp->root->sb);
+
 		call_rcu(&cgrp->rcu_head, free_cgroup_rcu);
 	}
 	iput(inode);