]> Pileus Git - ~andy/linux/blobdiff - fs/sysfs/mount.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm...
[~andy/linux] / fs / sysfs / mount.c
index fd7ce7a39f91acfa9304fd80e9ff5a6e7e1139cc..834ec2cdb7a37e070b7e5ed04ec684ba46cb2093 100644 (file)
@@ -112,8 +112,15 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type,
        struct super_block *sb;
        int error;
 
-       if (!(flags & MS_KERNMOUNT) && !current_user_ns()->may_mount_sysfs)
-               return ERR_PTR(-EPERM);
+       if (!(flags & MS_KERNMOUNT)) {
+               if (!capable(CAP_SYS_ADMIN) && !fs_fully_visible(fs_type))
+                       return ERR_PTR(-EPERM);
+
+               for (type = KOBJ_NS_TYPE_NONE; type < KOBJ_NS_TYPES; type++) {
+                       if (!kobj_ns_current_may_mount(type))
+                               return ERR_PTR(-EPERM);
+               }
+       }
 
        info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (!info)