diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2015-05-08 23:22:29 -0500 |
---|---|---|
committer | Luis Henriques <luis.henriques@canonical.com> | 2015-07-09 14:36:04 +0100 |
commit | 6d4ba4fa0bc1f54deb019205cd05bf0edaac66e1 (patch) | |
tree | f51dd260aacf56d4ded36f564afad5f949da54bd /fs/sysfs | |
parent | b4147b603361a71458adbb10f09e2606f47e14f4 (diff) | |
download | linux-stable-6d4ba4fa0bc1f54deb019205cd05bf0edaac66e1.tar.gz linux-stable-6d4ba4fa0bc1f54deb019205cd05bf0edaac66e1.tar.bz2 linux-stable-6d4ba4fa0bc1f54deb019205cd05bf0edaac66e1.zip |
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: Luis Henriques <luis.henriques@canonical.com>
Diffstat (limited to 'fs/sysfs')
-rw-r--r-- | fs/sysfs/mount.c | 5 |
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, bool new_sb; if (!(flags & MS_KERNMOUNT)) { - if (!capable(CAP_SYS_ADMIN) && !fs_fully_visible(fs_type)) - return ERR_PTR(-EPERM); - if (!kobj_ns_current_may_mount(KOBJ_NS_TYPE_NET)) return ERR_PTR(-EPERM); } @@ -58,7 +55,7 @@ static struct file_system_type sysfs_fs_type = { .name = "sysfs", .mount = sysfs_mount, .kill_sb = sysfs_kill_sb, - .fs_flags = FS_USERNS_MOUNT, + .fs_flags = FS_USERNS_VISIBLE | FS_USERNS_MOUNT, }; int __init sysfs_init(void) |