Add FS_USERNS_FLAG to cgroup fs
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Fri, 29 Jan 2016 08:54:11 +0000 (02:54 -0600)
committerTejun Heo <tj@kernel.org>
Tue, 16 Feb 2016 18:04:59 +0000 (13:04 -0500)
allowing root in a non-init user namespace to mount it.  This should
now be safe, because

1. non-init-root cannot mount a previously unbound subsystem
2. the task doing the mount must be privileged with respect to the
   user namespace owning the cgroup namespace
3. the mounted subsystem will have its current cgroup as the root dentry.
   the permissions will be unchanged, so tasks will receive no new
   privilege over the cgroups which they did not have on the original
   mounts.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
kernel/cgroup.c

index 24989022ff62ea5f6476ae78a3b63fb93f9e33ad..afb1205fc789df0f532b77a1c319044e9339079c 100644 (file)
@@ -2227,12 +2227,14 @@ static struct file_system_type cgroup_fs_type = {
        .name = "cgroup",
        .mount = cgroup_mount,
        .kill_sb = cgroup_kill_sb,
+       .fs_flags = FS_USERNS_MOUNT,
 };
 
 static struct file_system_type cgroup2_fs_type = {
        .name = "cgroup2",
        .mount = cgroup_mount,
        .kill_sb = cgroup_kill_sb,
+       .fs_flags = FS_USERNS_MOUNT,
 };
 
 static char *cgroup_path_ns_locked(struct cgroup *cgrp, char *buf, size_t buflen,