diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2015-05-09 00:22:29 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-07-21 13:10:01 -0400 |
commit | b5eb51f2ee063044401492650e9e01bb35974870 (patch) | |
tree | 111e5f73c54f26603d577e05c0d1726f6bc04b84 /fs/proc | |
parent | 8e7c56b6f14d1388d5aa2feb5b28dd6360199cef (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/proc')
-rw-r--r-- | fs/proc/root.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/fs/proc/root.c b/fs/proc/root.c index 3d987dfdef83..68feb0f70e63 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c | |||
@@ -112,9 +112,6 @@ static struct dentry *proc_mount(struct file_system_type *fs_type, | |||
112 | ns = task_active_pid_ns(current); | 112 | ns = task_active_pid_ns(current); |
113 | options = data; | 113 | options = data; |
114 | 114 | ||
115 | if (!capable(CAP_SYS_ADMIN) && !fs_fully_visible(fs_type)) | ||
116 | return ERR_PTR(-EPERM); | ||
117 | |||
118 | /* Does the mounter have privilege over the pid namespace? */ | 115 | /* Does the mounter have privilege over the pid namespace? */ |
119 | if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN)) | 116 | if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN)) |
120 | return ERR_PTR(-EPERM); | 117 | return ERR_PTR(-EPERM); |
@@ -159,7 +156,7 @@ static struct file_system_type proc_fs_type = { | |||
159 | .name = "proc", | 156 | .name = "proc", |
160 | .mount = proc_mount, | 157 | .mount = proc_mount, |
161 | .kill_sb = proc_kill_sb, | 158 | .kill_sb = proc_kill_sb, |
162 | .fs_flags = FS_USERNS_MOUNT, | 159 | .fs_flags = FS_USERNS_VISIBLE | FS_USERNS_MOUNT, |
163 | }; | 160 | }; |
164 | 161 | ||
165 | void __init proc_root_init(void) | 162 | void __init proc_root_init(void) |