Paul Menage 307257cf47 cgroups: fix a race between rmdir and remount
When a cgroup is removed, it's unlinked from its parent's children list,
but not actually freed until the last dentry on it is released (at which
point cgrp->root->number_of_cgroups is decremented).

Currently rebind_subsystems checks for the top cgroup's child list being
empty in order to rebind subsystems into or out of a hierarchy - this can
result in the set of subsystems bound to a hierarchy being
removed-but-not-freed cgroup.

The simplest fix for this is to forbid remounts that change the set of
subsystems on a hierarchy that has removed-but-not-freed cgroups.  This
bug can be reproduced via:

mkdir /mnt/cg
mount -t cgroup -o ns,freezer cgroup /mnt/cg
mkdir /mnt/cg/foo
sleep 1h < /mnt/cg/foo &
rmdir /mnt/cg/foo
mount -t cgroup -o remount,ns,devices,freezer cgroup /mnt/cg
kill $!

Though the above will cause oops in -mm only but not mainline, but the bug
can cause memory leak in mainline (and even oops)

Signed-off-by: Paul Menage <menage@google.com>
Reviewed-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-12-15 16:27:07 -08:00
..
2008-11-27 10:11:53 +01:00
2008-11-30 10:03:37 -08:00
2008-10-16 11:21:30 -07:00
2008-12-10 14:40:45 -08:00
2008-03-30 14:18:41 -07:00
2008-09-14 16:25:35 +02:00
2008-11-19 18:49:58 -08:00
2008-07-28 14:37:38 +02:00
2007-07-16 09:05:50 -07:00
2008-12-10 08:01:54 -08:00
2008-08-13 12:55:10 +02:00
2008-12-01 19:55:24 -08:00
2008-09-02 19:21:40 -07:00
2008-11-30 10:03:37 -08:00
2008-11-30 11:00:15 -08:00
2008-10-21 15:59:53 +02:00
2008-11-11 11:57:22 +01:00
2008-11-05 10:30:14 +01:00
2008-12-09 19:27:03 +01:00
2007-07-16 09:05:50 -07:00
2008-11-06 08:41:56 +01:00
2008-02-06 10:41:02 -08:00
2008-11-19 18:49:57 -08:00
2008-07-25 10:53:45 -07:00
2008-10-16 11:21:47 -07:00
2008-10-16 11:21:31 -07:00