aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/nsproxy.c
diff options
context:
space:
mode:
authorCedric Le Goater <clg@fr.ibm.com>2007-07-16 02:40:59 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-16 12:05:47 -0400
commitacce292c82d4d82d35553b928df2b0597c3a9c78 (patch)
tree464288f40db9c254da214c400d0880ee50dc37f3 /kernel/nsproxy.c
parent7d69a1f4a72b18876c99c697692b78339d491568 (diff)
user namespace: add the framework
Basically, it will allow a process to unshare its user_struct table, resetting at the same time its own user_struct and all the associated accounting. A new root user (uid == 0) is added to the user namespace upon creation. Such root users have full privileges and it seems that theses privileges should be controlled through some means (process capabilities ?) The unshare is not included in this patch. Changes since [try #4]: - Updated get_user_ns and put_user_ns to accept NULL, and get_user_ns to return the namespace. Changes since [try #3]: - moved struct user_namespace to files user_namespace.{c,h} Changes since [try #2]: - removed struct user_namespace* argument from find_user() Changes since [try #1]: - removed struct user_namespace* argument from find_user() - added a root_user per user namespace Signed-off-by: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Serge E. Hallyn <serue@us.ibm.com> Acked-by: Pavel Emelianov <xemul@openvz.org> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Kirill Korotaev <dev@sw.ru> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Chris Wright <chrisw@sous-sol.org> Cc: Stephen Smalley <sds@tycho.nsa.gov> Cc: James Morris <jmorris@namei.org> Cc: Andrew Morgan <agm@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/nsproxy.c')
-rw-r--r--kernel/nsproxy.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index e38bed75367d..895e3a3f2044 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -79,8 +79,15 @@ static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
79 if (IS_ERR(new_nsp->pid_ns)) 79 if (IS_ERR(new_nsp->pid_ns))
80 goto out_pid; 80 goto out_pid;
81 81
82 new_nsp->user_ns = copy_user_ns(flags, tsk->nsproxy->user_ns);
83 if (IS_ERR(new_nsp->user_ns))
84 goto out_user;
85
82 return new_nsp; 86 return new_nsp;
83 87
88out_user:
89 if (new_nsp->pid_ns)
90 put_pid_ns(new_nsp->pid_ns);
84out_pid: 91out_pid:
85 if (new_nsp->ipc_ns) 92 if (new_nsp->ipc_ns)
86 put_ipc_ns(new_nsp->ipc_ns); 93 put_ipc_ns(new_nsp->ipc_ns);
@@ -140,6 +147,8 @@ void free_nsproxy(struct nsproxy *ns)
140 put_ipc_ns(ns->ipc_ns); 147 put_ipc_ns(ns->ipc_ns);
141 if (ns->pid_ns) 148 if (ns->pid_ns)
142 put_pid_ns(ns->pid_ns); 149 put_pid_ns(ns->pid_ns);
150 if (ns->user_ns)
151 put_user_ns(ns->user_ns);
143 kfree(ns); 152 kfree(ns);
144} 153}
145 154