Skip to content

Commit

Permalink
cgroups: forbid noprefix if mounting more than just cpuset subsystem
Browse files Browse the repository at this point in the history
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.

[[email protected]: fix shift for cpuset_subsys_id >= 32]
Signed-off-by: Li Zefan <[email protected]>
Cc: Paul Menage <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
Cc: Balbir Singh <[email protected]>
Acked-by: Dhaval Giani <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Li Zefan authored and torvalds committed Jun 18, 2009
1 parent 8ca739e commit f9ab5b5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,11 @@ static int parse_cgroupfs_options(char *data,
struct cgroup_sb_opts *opts)
{
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->flags = 0;
Expand Down Expand Up @@ -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 */
if (!opts->subsys_bits)
return -EINVAL;
Expand Down

0 comments on commit f9ab5b5

Please sign in to comment.