diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2013-03-24 14:28:27 -0700 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2013-03-27 07:50:08 -0700 |
commit | 87a8ebd637dafc255070f503909a053cf0d98d3f (patch) | |
tree | 0bc879f9118c3333c73dfd15223a79e6219f64fd /fs/namespace.c | |
parent | a636b702ed1805e988ad3d8ff8b52c060f8b341c (diff) | |
download | op-kernel-dev-87a8ebd637dafc255070f503909a053cf0d98d3f.zip op-kernel-dev-87a8ebd637dafc255070f503909a053cf0d98d3f.tar.gz |
userns: Restrict when proc and sysfs can be mounted
Only allow unprivileged mounts of proc and sysfs if they are already
mounted when the user namespace is created.
proc and sysfs are interesting because they have content that is
per namespace, and so fresh mounts are needed when new namespaces
are created while at the same time proc and sysfs have content that
is shared between every instance.
Respect the policy of who may see the shared content of proc and sysfs
by only allowing new mounts if there was an existing mount at the time
the user namespace was created.
In practice there are only two interesting cases: proc and sysfs are
mounted at their usual places, proc and sysfs are not mounted at all
(some form of mount namespace jail).
Cc: stable@vger.kernel.org
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r-- | fs/namespace.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 968d4c5..d581e45 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2763,6 +2763,27 @@ bool current_chrooted(void) return chrooted; } +void update_mnt_policy(struct user_namespace *userns) +{ + struct mnt_namespace *ns = current->nsproxy->mnt_ns; + struct mount *mnt; + + down_read(&namespace_sem); + list_for_each_entry(mnt, &ns->list, mnt_list) { + switch (mnt->mnt.mnt_sb->s_magic) { + case SYSFS_MAGIC: + userns->may_mount_sysfs = true; + break; + case PROC_SUPER_MAGIC: + userns->may_mount_proc = true; + break; + } + if (userns->may_mount_sysfs && userns->may_mount_proc) + break; + } + up_read(&namespace_sem); +} + static void *mntns_get(struct task_struct *task) { struct mnt_namespace *ns = NULL; |