]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mnt: Move the FS_USERNS_MOUNT check into sget_userns
authorEric W. Biederman <ebiederm@xmission.com>
Mon, 6 Jun 2016 20:48:04 +0000 (15:48 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Thu, 23 Jun 2016 20:41:55 +0000 (15:41 -0500)
Allowing a filesystem to be mounted by other than root in the initial
user namespace is a filesystem property not a mount namespace property
and as such should be checked in filesystem specific code.  Move the
FS_USERNS_MOUNT test into super.c:sget_userns().

Acked-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
fs/namespace.c
fs/super.c

index 1a69aa7869758348213850862b7f4b9d75d841ef..2e13f6cfe5dfd8ade0baded787f7b6250ed46841 100644 (file)
@@ -2397,10 +2397,6 @@ static int do_new_mount(struct path *path, const char *fstype, int flags,
                return -ENODEV;
 
        if (user_ns != &init_user_ns) {
-               if (!(type->fs_flags & FS_USERNS_MOUNT)) {
-                       put_filesystem(type);
-                       return -EPERM;
-               }
                /* Only in special cases allow devices from mounts
                 * created outside the initial user namespace.
                 */
index 874c7e3ebb8f184e401a9737371e0315e2d22259..78790ada71915d539a204d6652913e98b3442ad7 100644 (file)
@@ -466,6 +466,10 @@ struct super_block *sget_userns(struct file_system_type *type,
        struct super_block *old;
        int err;
 
+       if (!(flags & MS_KERNMOUNT) &&
+           !(type->fs_flags & FS_USERNS_MOUNT) &&
+           !capable(CAP_SYS_ADMIN))
+               return ERR_PTR(-EPERM);
 retry:
        spin_lock(&sb_lock);
        if (test) {