aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2015-05-09 00:22:29 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-07-21 13:10:01 -0400
commitb5eb51f2ee063044401492650e9e01bb35974870 (patch)
tree111e5f73c54f26603d577e05c0d1726f6bc04b84 /fs/sysfs
parent8e7c56b6f14d1388d5aa2feb5b28dd6360199cef (diff)
mnt: Refactor the logic for mounting sysfs and proc in a user namespace
commit 1b852bceb0d111e510d1a15826ecc4a19358d512 upstream. Fresh mounts of proc and sysfs are a very special case that works very much like a bind mount. Unfortunately the current structure can not preserve the MNT_LOCK... mount flags. Therefore refactor the logic into a form that can be modified to preserve those lock bits. Add a new filesystem flag FS_USERNS_VISIBLE that requires some mount of the filesystem be fully visible in the current mount namespace, before the filesystem may be mounted. Move the logic for calling fs_fully_visible from proc and sysfs into fs/namespace.c where it has greater access to mount namespace state. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/sysfs')
-rw-r--r--fs/sysfs/mount.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 8a49486bf30c..1c6ac6fcee9f 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -31,9 +31,6 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type,
31 bool new_sb; 31 bool new_sb;
32 32
33 if (!(flags & MS_KERNMOUNT)) { 33 if (!(flags & MS_KERNMOUNT)) {
34 if (!capable(CAP_SYS_ADMIN) && !fs_fully_visible(fs_type))
35 return ERR_PTR(-EPERM);
36
37 if (!kobj_ns_current_may_mount(KOBJ_NS_TYPE_NET)) 34 if (!kobj_ns_current_may_mount(KOBJ_NS_TYPE_NET))
38 return ERR_PTR(-EPERM); 35 return ERR_PTR(-EPERM);
39 } 36 }
@@ -58,7 +55,7 @@ static struct file_system_type sysfs_fs_type = {
58 .name = "sysfs", 55 .name = "sysfs",
59 .mount = sysfs_mount, 56 .mount = sysfs_mount,
60 .kill_sb = sysfs_kill_sb, 57 .kill_sb = sysfs_kill_sb,
61 .fs_flags = FS_USERNS_MOUNT, 58 .fs_flags = FS_USERNS_VISIBLE | FS_USERNS_MOUNT,
62}; 59};
63 60
64int __init sysfs_init(void) 61int __init sysfs_init(void)