mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-14 06:35:12 +00:00
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>
This commit is contained in:
parent
430af8ad9d
commit
bad3466034
1 changed files with 6 additions and 2 deletions
|
@ -2995,6 +2995,8 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
|
||||||
kernfs_type(kn) != KERNFS_DIR)
|
kernfs_type(kn) != KERNFS_DIR)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
mutex_lock(&cgroup_mutex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We aren't being called from kernfs and there's no guarantee on
|
* We aren't being called from kernfs and there's no guarantee on
|
||||||
* @kn->priv's validity. For this and css_tryget_from_dir(),
|
* @kn->priv's validity. For this and css_tryget_from_dir(),
|
||||||
|
@ -3002,10 +3004,12 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
|
||||||
*/
|
*/
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
cgrp = rcu_dereference(kn->priv);
|
cgrp = rcu_dereference(kn->priv);
|
||||||
if (!cgrp) {
|
if (!cgrp || cgroup_is_dead(cgrp)) {
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
mutex_unlock(&cgroup_mutex);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
rcu_read_unlock();
|
||||||
|
|
||||||
css_task_iter_start(&cgrp->dummy_css, &it);
|
css_task_iter_start(&cgrp->dummy_css, &it);
|
||||||
while ((tsk = css_task_iter_next(&it))) {
|
while ((tsk = css_task_iter_next(&it))) {
|
||||||
|
@ -3030,7 +3034,7 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
|
||||||
}
|
}
|
||||||
css_task_iter_end(&it);
|
css_task_iter_end(&it);
|
||||||
|
|
||||||
rcu_read_unlock();
|
mutex_unlock(&cgroup_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue