All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cgroups: fix lock inconsistency in cgroup_clone()
@ 2009-01-20  6:43 Li Zefan
  2009-01-21 10:05 ` Paul Menage
       [not found] ` <497572AA.8020101-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Li Zefan @ 2009-01-20  6:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Paul Menage, LKML, Linux Containers

I fixed a bug in cgroup_clone() in Linus' tree (commit 7b574b7), without
noticing there was a cleanup patch in -mm tree that should be rebased
(now commit 104cbd5), thus resulted in lock inconsistency.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---

for 2.6.29

---
 kernel/cgroup.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index c298310..a5826f3 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2991,20 +2991,21 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
 		mutex_unlock(&cgroup_mutex);
 		return 0;
 	}
-	task_lock(tsk);
-	cg = tsk->cgroups;
-	parent = task_cgroup(tsk, subsys->subsys_id);
 
 	/* Pin the hierarchy */
-	if (!atomic_inc_not_zero(&parent->root->sb->s_active)) {
+	if (!atomic_inc_not_zero(&root->sb->s_active)) {
 		/* We race with the final deactivate_super() */
 		mutex_unlock(&cgroup_mutex);
 		return 0;
 	}
 
 	/* Keep the cgroup alive */
+	task_lock(tsk);
+	parent = task_cgroup(tsk, subsys->subsys_id);
+	cg = tsk->cgroups;
 	get_css_set(cg);
 	task_unlock(tsk);
+
 	mutex_unlock(&cgroup_mutex);
 
 	/* Now do the VFS work to create a cgroup */
@@ -3043,7 +3044,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
 		mutex_unlock(&inode->i_mutex);
 		put_css_set(cg);
 
-		deactivate_super(parent->root->sb);
+		deactivate_super(root->sb);
 		/* The cgroup is still accessible in the VFS, but
 		 * we're not going to try to rmdir() it at this
 		 * point. */
@@ -3069,7 +3070,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
 	mutex_lock(&cgroup_mutex);
 	put_css_set(cg);
 	mutex_unlock(&cgroup_mutex);
-	deactivate_super(parent->root->sb);
+	deactivate_super(root->sb);
 	return ret;
 }
 
-- 
1.5.4.rc3



^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH] cgroups: fix lock inconsistency in cgroup_clone()
@ 2009-01-20  6:43 Li Zefan
  0 siblings, 0 replies; 4+ messages in thread
From: Li Zefan @ 2009-01-20  6:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Containers, Paul Menage, LKML

I fixed a bug in cgroup_clone() in Linus' tree (commit 7b574b7), without
noticing there was a cleanup patch in -mm tree that should be rebased
(now commit 104cbd5), thus resulted in lock inconsistency.

Signed-off-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
---

for 2.6.29

---
 kernel/cgroup.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index c298310..a5826f3 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2991,20 +2991,21 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
 		mutex_unlock(&cgroup_mutex);
 		return 0;
 	}
-	task_lock(tsk);
-	cg = tsk->cgroups;
-	parent = task_cgroup(tsk, subsys->subsys_id);
 
 	/* Pin the hierarchy */
-	if (!atomic_inc_not_zero(&parent->root->sb->s_active)) {
+	if (!atomic_inc_not_zero(&root->sb->s_active)) {
 		/* We race with the final deactivate_super() */
 		mutex_unlock(&cgroup_mutex);
 		return 0;
 	}
 
 	/* Keep the cgroup alive */
+	task_lock(tsk);
+	parent = task_cgroup(tsk, subsys->subsys_id);
+	cg = tsk->cgroups;
 	get_css_set(cg);
 	task_unlock(tsk);
+
 	mutex_unlock(&cgroup_mutex);
 
 	/* Now do the VFS work to create a cgroup */
@@ -3043,7 +3044,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
 		mutex_unlock(&inode->i_mutex);
 		put_css_set(cg);
 
-		deactivate_super(parent->root->sb);
+		deactivate_super(root->sb);
 		/* The cgroup is still accessible in the VFS, but
 		 * we're not going to try to rmdir() it at this
 		 * point. */
@@ -3069,7 +3070,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
 	mutex_lock(&cgroup_mutex);
 	put_css_set(cg);
 	mutex_unlock(&cgroup_mutex);
-	deactivate_super(parent->root->sb);
+	deactivate_super(root->sb);
 	return ret;
 }
 
-- 
1.5.4.rc3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-21 10:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-20  6:43 [PATCH] cgroups: fix lock inconsistency in cgroup_clone() Li Zefan
2009-01-21 10:05 ` Paul Menage
     [not found] ` <497572AA.8020101-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-01-21 10:05   ` Paul Menage
  -- strict thread matches above, loose matches on Subject: below --
2009-01-20  6:43 Li Zefan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.