Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH 1/2] cgroups: Fix to return errno in a failure path

0 views
Skip to first unread message

Li Zefan

unread,
Jan 26, 2010, 3:20:03 AM1/26/10
to
In cgroup_create(), if alloc_css_id() returns failure, the errno
is not propagated to userspace, so mkdir will fail silently.

To trigger this bug, we mount blkio (or memory subsystem), and
create more then 65534 cgroups. (The number of cgroups is limited
to 65535 if a subsystem has use_id == 1)

# mount -t cgroup -o blkio xxx /mnt
# for ((i = 0; i < 65534; i++)); do mkdir /mnt/$i; done
# mkdir /mnt/65534
(should return ENOSPC)
#

Signed-off-by: Li Zefan <li...@cn.fujitsu.com>
---
cgroup.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

--- a/kernel/cgroup.c.orig 2010-01-19 16:37:37.000000000 +0800
+++ a/kernel/cgroup.c 2010-01-19 16:39:07.000000000 +0800
@@ -3279,14 +3279,17 @@ static long cgroup_create(struct cgroup

for_each_subsys(root, ss) {
struct cgroup_subsys_state *css = ss->create(ss, cgrp);
+
if (IS_ERR(css)) {
err = PTR_ERR(css);
goto err_destroy;
}
init_cgroup_css(css, ss, cgrp);
- if (ss->use_id)
- if (alloc_css_id(ss, parent, cgrp))
+ if (ss->use_id) {
+ err = alloc_css_id(ss, parent, cgrp);
+ if (err)
goto err_destroy;
+ }
/* At error, ->destroy() callback has to free assigned ID. */
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Serge E. Hallyn

unread,
Jan 26, 2010, 10:00:02 AM1/26/10
to
Quoting Li Zefan (li...@cn.fujitsu.com):
> In cgroup_create(), if alloc_css_id() returns failure, the errno
> is not propagated to userspace, so mkdir will fail silently.
>
> To trigger this bug, we mount blkio (or memory subsystem), and
> create more then 65534 cgroups. (The number of cgroups is limited
> to 65535 if a subsystem has use_id == 1)
>
> # mount -t cgroup -o blkio xxx /mnt
> # for ((i = 0; i < 65534; i++)); do mkdir /mnt/$i; done
> # mkdir /mnt/65534
> (should return ENOSPC)
> #
>
> Signed-off-by: Li Zefan <li...@cn.fujitsu.com>

Yup.

Acked-by: Serge Hallyn <se...@us.ibm.com>

> ---
> cgroup.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> --- a/kernel/cgroup.c.orig 2010-01-19 16:37:37.000000000 +0800
> +++ a/kernel/cgroup.c 2010-01-19 16:39:07.000000000 +0800
> @@ -3279,14 +3279,17 @@ static long cgroup_create(struct cgroup
>
> for_each_subsys(root, ss) {
> struct cgroup_subsys_state *css = ss->create(ss, cgrp);
> +
> if (IS_ERR(css)) {
> err = PTR_ERR(css);
> goto err_destroy;
> }
> init_cgroup_css(css, ss, cgrp);
> - if (ss->use_id)
> - if (alloc_css_id(ss, parent, cgrp))
> + if (ss->use_id) {
> + err = alloc_css_id(ss, parent, cgrp);
> + if (err)
> goto err_destroy;
> + }
> /* At error, ->destroy() callback has to free assigned ID. */
> }
>

> _______________________________________________
> Containers mailing list
> Conta...@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/containers

Paul Menage

unread,
Jan 26, 2010, 6:10:02 PM1/26/10
to
On Tue, Jan 26, 2010 at 12:16 AM, Li Zefan <li...@cn.fujitsu.com> wrote:
>
> Signed-off-by: Li Zefan <li...@cn.fujitsu.com>

Acked-by: Paul Menage <men...@google.com>

KAMEZAWA Hiroyuki

unread,
Jan 26, 2010, 7:10:04 PM1/26/10
to
On Tue, 26 Jan 2010 15:01:26 -0800
Paul Menage <men...@google.com> wrote:

> On Tue, Jan 26, 2010 at 12:16 AM, Li Zefan <li...@cn.fujitsu.com> wrote:
> >
> > Signed-off-by: Li Zefan <li...@cn.fujitsu.com>
>
> Acked-by: Paul Menage <men...@google.com>
>

Thank you.

Acked-by: KAMEZAWA Hiroyuki <kamezaw...@jp.fujitsu.com>

0 new messages