diff options
author | Cedric Le Goater <clg@fr.ibm.com> | 2007-07-16 02:40:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-16 12:05:47 -0400 |
commit | acce292c82d4d82d35553b928df2b0597c3a9c78 (patch) | |
tree | 464288f40db9c254da214c400d0880ee50dc37f3 /kernel/user_namespace.c | |
parent | 7d69a1f4a72b18876c99c697692b78339d491568 (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/user_namespace.c')
-rw-r--r-- | kernel/user_namespace.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c new file mode 100644 index 00000000000..3d796420977 --- /dev/null +++ b/kernel/user_namespace.c | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * This program is free software; you can redistribute it and/or | ||
3 | * modify it under the terms of the GNU General Public License as | ||
4 | * published by the Free Software Foundation, version 2 of the | ||
5 | * License. | ||
6 | */ | ||
7 | |||
8 | #include <linux/module.h> | ||
9 | #include <linux/version.h> | ||
10 | #include <linux/nsproxy.h> | ||
11 | #include <linux/user_namespace.h> | ||
12 | |||
13 | struct user_namespace init_user_ns = { | ||
14 | .kref = { | ||
15 | .refcount = ATOMIC_INIT(2), | ||
16 | }, | ||
17 | .root_user = &root_user, | ||
18 | }; | ||
19 | |||
20 | EXPORT_SYMBOL_GPL(init_user_ns); | ||
21 | |||
22 | #ifdef CONFIG_USER_NS | ||
23 | |||
24 | struct user_namespace * copy_user_ns(int flags, struct user_namespace *old_ns) | ||
25 | { | ||
26 | struct user_namespace *new_ns; | ||
27 | |||
28 | BUG_ON(!old_ns); | ||
29 | get_user_ns(old_ns); | ||
30 | |||
31 | new_ns = old_ns; | ||
32 | return new_ns; | ||
33 | } | ||
34 | |||
35 | void free_user_ns(struct kref *kref) | ||
36 | { | ||
37 | struct user_namespace *ns; | ||
38 | |||
39 | ns = container_of(kref, struct user_namespace, kref); | ||
40 | kfree(ns); | ||
41 | } | ||
42 | |||
43 | #endif /* CONFIG_USER_NS */ | ||