aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/user_namespace.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/user_namespace.c')
-rw-r--r--kernel/user_namespace.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 8b650837083e..a54f26f82eb2 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -21,6 +21,7 @@
21#include <linux/uaccess.h> 21#include <linux/uaccess.h>
22#include <linux/ctype.h> 22#include <linux/ctype.h>
23#include <linux/projid.h> 23#include <linux/projid.h>
24#include <linux/fs_struct.h>
24 25
25static struct kmem_cache *user_ns_cachep __read_mostly; 26static struct kmem_cache *user_ns_cachep __read_mostly;
26 27
@@ -60,6 +61,15 @@ int create_user_ns(struct cred *new)
60 kgid_t group = new->egid; 61 kgid_t group = new->egid;
61 int ret; 62 int ret;
62 63
64 /*
65 * Verify that we can not violate the policy of which files
66 * may be accessed that is specified by the root directory,
67 * by verifing that the root directory is at the root of the
68 * mount namespace which allows all files to be accessed.
69 */
70 if (current_chrooted())
71 return -EPERM;
72
63 /* The creator needs a mapping in the parent user namespace 73 /* The creator needs a mapping in the parent user namespace
64 * or else we won't be able to reasonably tell userspace who 74 * or else we won't be able to reasonably tell userspace who
65 * created a user_namespace. 75 * created a user_namespace.
@@ -86,6 +96,8 @@ int create_user_ns(struct cred *new)
86 96
87 set_cred_user_ns(new, ns); 97 set_cred_user_ns(new, ns);
88 98
99 update_mnt_policy(ns);
100
89 return 0; 101 return 0;
90} 102}
91 103
@@ -837,6 +849,9 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
837 if (atomic_read(&current->mm->mm_users) > 1) 849 if (atomic_read(&current->mm->mm_users) > 1)
838 return -EINVAL; 850 return -EINVAL;
839 851
852 if (current->fs->users != 1)
853 return -EINVAL;
854
840 if (!ns_capable(user_ns, CAP_SYS_ADMIN)) 855 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
841 return -EPERM; 856 return -EPERM;
842 857