diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-01-29 17:25:21 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-29 21:04:45 -0500 |
commit | 1404f06565ee89e0ce04d4a5859c00b0e3a0dc8d (patch) | |
tree | e2f294ed420461e0032e03143f06634b883dc06e /kernel | |
parent | 945048ca36173315afa2f0c53bed21ba01a588c1 (diff) |
cgroups: fix lock inconsistency in cgroup_clone()
I fixed a bug in cgroup_clone() in Linus' tree in commit 7b574b7
("cgroups: fix a race between cgroup_clone and umount") without noticing
there was a cleanup patch in -mm tree that should be rebased (now commit
104cbd5, "cgroups: use task_lock() for access tsk->cgroups safe in
cgroup_clone()"), thus resulted in lock inconsistency.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Paul Menage <menage@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cgroup.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 2ae7cb47dbfa..0066092de19a 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -2993,20 +2993,21 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys, | |||
2993 | mutex_unlock(&cgroup_mutex); | 2993 | mutex_unlock(&cgroup_mutex); |
2994 | return 0; | 2994 | return 0; |
2995 | } | 2995 | } |
2996 | task_lock(tsk); | ||
2997 | cg = tsk->cgroups; | ||
2998 | parent = task_cgroup(tsk, subsys->subsys_id); | ||
2999 | 2996 | ||
3000 | /* Pin the hierarchy */ | 2997 | /* Pin the hierarchy */ |
3001 | if (!atomic_inc_not_zero(&parent->root->sb->s_active)) { | 2998 | if (!atomic_inc_not_zero(&root->sb->s_active)) { |
3002 | /* We race with the final deactivate_super() */ | 2999 | /* We race with the final deactivate_super() */ |
3003 | mutex_unlock(&cgroup_mutex); | 3000 | mutex_unlock(&cgroup_mutex); |
3004 | return 0; | 3001 | return 0; |
3005 | } | 3002 | } |
3006 | 3003 | ||
3007 | /* Keep the cgroup alive */ | 3004 | /* Keep the cgroup alive */ |
3005 | task_lock(tsk); | ||
3006 | parent = task_cgroup(tsk, subsys->subsys_id); | ||
3007 | cg = tsk->cgroups; | ||
3008 | get_css_set(cg); | 3008 | get_css_set(cg); |
3009 | task_unlock(tsk); | 3009 | task_unlock(tsk); |
3010 | |||
3010 | mutex_unlock(&cgroup_mutex); | 3011 | mutex_unlock(&cgroup_mutex); |
3011 | 3012 | ||
3012 | /* Now do the VFS work to create a cgroup */ | 3013 | /* Now do the VFS work to create a cgroup */ |
@@ -3045,7 +3046,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys, | |||
3045 | mutex_unlock(&inode->i_mutex); | 3046 | mutex_unlock(&inode->i_mutex); |
3046 | put_css_set(cg); | 3047 | put_css_set(cg); |
3047 | 3048 | ||
3048 | deactivate_super(parent->root->sb); | 3049 | deactivate_super(root->sb); |
3049 | /* The cgroup is still accessible in the VFS, but | 3050 | /* The cgroup is still accessible in the VFS, but |
3050 | * we're not going to try to rmdir() it at this | 3051 | * we're not going to try to rmdir() it at this |
3051 | * point. */ | 3052 | * point. */ |
@@ -3071,7 +3072,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys, | |||
3071 | mutex_lock(&cgroup_mutex); | 3072 | mutex_lock(&cgroup_mutex); |
3072 | put_css_set(cg); | 3073 | put_css_set(cg); |
3073 | mutex_unlock(&cgroup_mutex); | 3074 | mutex_unlock(&cgroup_mutex); |
3074 | deactivate_super(parent->root->sb); | 3075 | deactivate_super(root->sb); |
3075 | return ret; | 3076 | return ret; |
3076 | } | 3077 | } |
3077 | 3078 | ||