* [PATCH 1/3] cgroup: fix locking in cgroupstats_build()
@ 2014-02-14 8:54 Li Zefan
2014-02-14 8:55 ` [PATCH 2/3] cgroup: fix memory leak in cgroup_mount() Li Zefan
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Li Zefan @ 2014-02-14 8:54 UTC (permalink / raw)
To: Tejun Heo; +Cc: LKML, Cgroups
css_set_lock has been converted to css_set_rwsem, and rwsem can't
nested inside rcu_read_lock.
Signed-off-by: Li Zefan <lizefan@huawei.com>
---
kernel/cgroup.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index af4ecc3..0e794ca 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2997,6 +2997,8 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
kernfs_type(kn) != KERNFS_DIR)
return -EINVAL;
+ mutex_lock(&cgroup_mutex);
+
/*
* We aren't being called from kernfs and there's no guarantee on
* @kn->priv's validity. For this and css_tryget_from_dir(),
@@ -3004,10 +3006,12 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
*/
rcu_read_lock();
cgrp = rcu_dereference(kn->priv);
- if (!cgrp) {
+ if (!cgrp || cgroup_is_dead(cgrp)) {
rcu_read_unlock();
+ mutex_unlock(&cgroup_mutex);
return -ENOENT;
}
+ rcu_read_unlock();
css_task_iter_start(&cgrp->dummy_css, &it);
while ((tsk = css_task_iter_next(&it))) {
@@ -3032,7 +3036,7 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
}
css_task_iter_end(&it);
- rcu_read_unlock();
+ mutex_unlock(&cgroup_mutex);
return 0;
}
--
1.8.0.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] cgroup: fix memory leak in cgroup_mount()
2014-02-14 8:54 [PATCH 1/3] cgroup: fix locking in cgroupstats_build() Li Zefan
@ 2014-02-14 8:55 ` Li Zefan
2014-02-14 8:56 ` [PATCH 3/3] cgroup: deal with dummp_top in cgroup_name() and cgroup_path() Li Zefan
2014-02-14 15:57 ` Tejun Heo
2 siblings, 0 replies; 5+ messages in thread
From: Li Zefan @ 2014-02-14 8:55 UTC (permalink / raw)
To: Tejun Heo; +Cc: LKML, Cgroups
We should free the memory allocated in parse_cgroupfs_options() before
calling this function again.
Signed-off-by: Li Zefan <lizefan@huawei.com>
---
kernel/cgroup.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 0e794ca..37d94a2 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1540,6 +1540,8 @@ retry:
if (!atomic_inc_not_zero(&root->top_cgroup.refcnt)) {
mutex_unlock(&cgroup_mutex);
mutex_unlock(&cgroup_tree_mutex);
+ kfree(opts.release_agent);
+ kfree(opts.name);
msleep(10);
goto retry;
}
--
1.8.0.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] cgroup: deal with dummp_top in cgroup_name() and cgroup_path()
2014-02-14 8:54 [PATCH 1/3] cgroup: fix locking in cgroupstats_build() Li Zefan
2014-02-14 8:55 ` [PATCH 2/3] cgroup: fix memory leak in cgroup_mount() Li Zefan
@ 2014-02-14 8:56 ` Li Zefan
2014-02-14 15:57 ` Tejun Heo
2 siblings, 0 replies; 5+ messages in thread
From: Li Zefan @ 2014-02-14 8:56 UTC (permalink / raw)
To: Tejun Heo; +Cc: LKML, Cgroups
My kernel fails to boot, because blkcg calls cgroup_path() while
cgroupfs is not mounted.
Fix both cgroup_name() and cgroup_path().
Signed-off-by: Li Zefan <lizefan@huawei.com>
---
include/linux/cgroup.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index ef0b3af..8c283a9 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -487,13 +487,21 @@ struct cgroup_subsys_state *seq_css(struct seq_file *seq);
static inline int cgroup_name(struct cgroup *cgrp, char *buf, size_t buflen)
{
- return kernfs_name(cgrp->kn, buf, buflen);
+ /* dummy_top doesn't have a kn associated */
+ if (cgrp->kn)
+ return kernfs_name(cgrp->kn, buf, buflen);
+ else
+ return strlcpy(buf, "/", buflen);
}
static inline char * __must_check cgroup_path(struct cgroup *cgrp, char *buf,
size_t buflen)
{
- return kernfs_path(cgrp->kn, buf, buflen);
+ /* dummy_top doesn't have a kn associated */
+ if (cgrp->kn)
+ return kernfs_path(cgrp->kn, buf, buflen);
+ strlcpy(buf, "/", buflen);
+ return (buflen <= 2) ? NULL : buf;
}
static inline void pr_cont_cgroup_name(struct cgroup *cgrp)
--
1.8.0.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] cgroup: fix locking in cgroupstats_build()
@ 2014-02-14 15:57 ` Tejun Heo
0 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2014-02-14 15:57 UTC (permalink / raw)
To: Li Zefan; +Cc: LKML, Cgroups
On Fri, Feb 14, 2014 at 04:54:28PM +0800, Li Zefan wrote:
> css_set_lock has been converted to css_set_rwsem, and rwsem can't
> nested inside rcu_read_lock.
>
> Signed-off-by: Li Zefan <lizefan@huawei.com>
Applied 1-3 to cgroup/for-3.15.
Thanks!
--
tejun
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] cgroup: fix locking in cgroupstats_build()
@ 2014-02-14 15:57 ` Tejun Heo
0 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2014-02-14 15:57 UTC (permalink / raw)
To: Li Zefan; +Cc: LKML, Cgroups
On Fri, Feb 14, 2014 at 04:54:28PM +0800, Li Zefan wrote:
> css_set_lock has been converted to css_set_rwsem, and rwsem can't
> nested inside rcu_read_lock.
>
> Signed-off-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Applied 1-3 to cgroup/for-3.15.
Thanks!
--
tejun
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-02-14 15:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-14 8:54 [PATCH 1/3] cgroup: fix locking in cgroupstats_build() Li Zefan
2014-02-14 8:55 ` [PATCH 2/3] cgroup: fix memory leak in cgroup_mount() Li Zefan
2014-02-14 8:56 ` [PATCH 3/3] cgroup: deal with dummp_top in cgroup_name() and cgroup_path() Li Zefan
2014-02-14 15:57 ` [PATCH 1/3] cgroup: fix locking in cgroupstats_build() Tejun Heo
2014-02-14 15:57 ` Tejun Heo
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.