提交 f9ab5b5b 编写于 作者: L Li Zefan 提交者: Linus Torvalds

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: NLi Zefan <lizf@cn.fujitsu.com>
Cc: Paul Menage <menage@google.com>
Acked-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: NDhaval Giani <dhaval@linux.vnet.ibm.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 8ca739e3
...@@ -843,6 +843,11 @@ static int parse_cgroupfs_options(char *data, ...@@ -843,6 +843,11 @@ static int parse_cgroupfs_options(char *data,
struct cgroup_sb_opts *opts) struct cgroup_sb_opts *opts)
{ {
char *token, *o = data ?: "all"; char *token, *o = data ?: "all";
unsigned long mask = (unsigned long)-1;
#ifdef CONFIG_CPUSETS
mask = ~(1UL << cpuset_subsys_id);
#endif
opts->subsys_bits = 0; opts->subsys_bits = 0;
opts->flags = 0; opts->flags = 0;
...@@ -887,6 +892,15 @@ static int parse_cgroupfs_options(char *data, ...@@ -887,6 +892,15 @@ static int parse_cgroupfs_options(char *data,
} }
} }
/*
* Option noprefix was introduced just for backward compatibility
* with the old cpuset, so we allow noprefix only if mounting just
* the cpuset subsystem.
*/
if (test_bit(ROOT_NOPREFIX, &opts->flags) &&
(opts->subsys_bits & mask))
return -EINVAL;
/* We can't have an empty hierarchy */ /* We can't have an empty hierarchy */
if (!opts->subsys_bits) if (!opts->subsys_bits)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册