diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-06-17 19:26:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-18 16:03:46 -0400 |
commit | f9ab5b5b0f5be506640321d710b0acd3dca6154a (patch) | |
tree | abd8e17febed8507b4c0f96a88d2711fccb31b2b | |
parent | 8ca739e3694b83cdf22be0f6eff063e721deb1e4 (diff) |
cgroups: forbid noprefix if mounting more than just cpuset subsystem
The 'noprefix' option was introduced for backwards-compatibility of
cpuset, but actually it can be used when mounting other subsystems.
This results in possibility of name collision, and now the collision can
really happen, because we have 'stat' file in both memory and cpuacct
subsystem:
# mount -t cgroup -o noprefix,memory,cpuacct xxx /mnt
Cgroup will happily mount the 2 subsystems, but only 'stat' file of memory
subsys can be seen.
We don't want users to use nopreifx, and also want to avoid name
collision, so we change to allow noprefix only if mounting just the cpuset
subsystem.
[akpm@linux-foundation.org: fix shift for cpuset_subsys_id >= 32]
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Paul Menage <menage@google.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | kernel/cgroup.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 3fb789f6df94..3737a682cdf5 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -843,6 +843,11 @@ static int parse_cgroupfs_options(char *data, | |||
843 | struct cgroup_sb_opts *opts) | 843 | struct cgroup_sb_opts *opts) |
844 | { | 844 | { |
845 | char *token, *o = data ?: "all"; | 845 | char *token, *o = data ?: "all"; |
846 | unsigned long mask = (unsigned long)-1; | ||
847 | |||
848 | #ifdef CONFIG_CPUSETS | ||
849 | mask = ~(1UL << cpuset_subsys_id); | ||
850 | #endif | ||
846 | 851 | ||
847 | opts->subsys_bits = 0; | 852 | opts->subsys_bits = 0; |
848 | opts->flags = 0; | 853 | opts->flags = 0; |
@@ -887,6 +892,15 @@ static int parse_cgroupfs_options(char *data, | |||
887 | } | 892 | } |
888 | } | 893 | } |
889 | 894 | ||
895 | /* | ||
896 | * Option noprefix was introduced just for backward compatibility | ||
897 | * with the old cpuset, so we allow noprefix only if mounting just | ||
898 | * the cpuset subsystem. | ||
899 | */ | ||
900 | if (test_bit(ROOT_NOPREFIX, &opts->flags) && | ||
901 | (opts->subsys_bits & mask)) | ||
902 | return -EINVAL; | ||
903 | |||
890 | /* We can't have an empty hierarchy */ | 904 | /* We can't have an empty hierarchy */ |
891 | if (!opts->subsys_bits) | 905 | if (!opts->subsys_bits) |
892 | return -EINVAL; | 906 | return -EINVAL; |