diff options
author | Li Zefan <lizefan@huawei.com> | 2014-02-14 03:54:28 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-02-14 10:52:39 -0500 |
commit | bad34660344f37db8b55ce8bc139bddc7d83af1b (patch) | |
tree | 21fbb75b3761a8f9c6d902780209089d6f059fb4 /kernel | |
parent | 430af8ad9dad82d775d688155e1db1da385d3e7a (diff) |
cgroup: fix locking in cgroupstats_build()
css_set_lock has been converted to css_set_rwsem, and rwsem can't nest
inside rcu_read_lock.
Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cgroup.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 15dcae74b510..5606c0f08d95 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -2995,6 +2995,8 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry) | |||
2995 | kernfs_type(kn) != KERNFS_DIR) | 2995 | kernfs_type(kn) != KERNFS_DIR) |
2996 | return -EINVAL; | 2996 | return -EINVAL; |
2997 | 2997 | ||
2998 | mutex_lock(&cgroup_mutex); | ||
2999 | |||
2998 | /* | 3000 | /* |
2999 | * We aren't being called from kernfs and there's no guarantee on | 3001 | * We aren't being called from kernfs and there's no guarantee on |
3000 | * @kn->priv's validity. For this and css_tryget_from_dir(), | 3002 | * @kn->priv's validity. For this and css_tryget_from_dir(), |
@@ -3002,10 +3004,12 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry) | |||
3002 | */ | 3004 | */ |
3003 | rcu_read_lock(); | 3005 | rcu_read_lock(); |
3004 | cgrp = rcu_dereference(kn->priv); | 3006 | cgrp = rcu_dereference(kn->priv); |
3005 | if (!cgrp) { | 3007 | if (!cgrp || cgroup_is_dead(cgrp)) { |
3006 | rcu_read_unlock(); | 3008 | rcu_read_unlock(); |
3009 | mutex_unlock(&cgroup_mutex); | ||
3007 | return -ENOENT; | 3010 | return -ENOENT; |
3008 | } | 3011 | } |
3012 | rcu_read_unlock(); | ||
3009 | 3013 | ||
3010 | css_task_iter_start(&cgrp->dummy_css, &it); | 3014 | css_task_iter_start(&cgrp->dummy_css, &it); |
3011 | while ((tsk = css_task_iter_next(&it))) { | 3015 | while ((tsk = css_task_iter_next(&it))) { |
@@ -3030,7 +3034,7 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry) | |||
3030 | } | 3034 | } |
3031 | css_task_iter_end(&it); | 3035 | css_task_iter_end(&it); |
3032 | 3036 | ||
3033 | rcu_read_unlock(); | 3037 | mutex_unlock(&cgroup_mutex); |
3034 | return 0; | 3038 | return 0; |
3035 | } | 3039 | } |
3036 | 3040 | ||