diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-07-26 07:02:49 -0400 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-11-20 07:17:43 -0500 |
commit | bcf58e725ddc45d31addbc6627d4f0edccc824c1 (patch) | |
tree | e6dff2fbed40f26d8c45f78e23a7476527573bf1 /kernel/utsname.c | |
parent | 142e1d1d5f088e7a38659daca6e84a730967774a (diff) |
userns: Make create_new_namespaces take a user_ns parameter
Modify create_new_namespaces to explicitly take a user namespace
parameter, instead of implicitly through the task_struct.
This allows an implementation of unshare(CLONE_NEWUSER) where
the new user namespace is not stored onto the current task_struct
until after all of the namespaces are created.
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'kernel/utsname.c')
-rw-r--r-- | kernel/utsname.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/utsname.c b/kernel/utsname.c index 4a9362f9325d..fdc619eb61ef 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c | |||
@@ -32,7 +32,7 @@ static struct uts_namespace *create_uts_ns(void) | |||
32 | * @old_ns: namespace to clone | 32 | * @old_ns: namespace to clone |
33 | * Return NULL on error (failure to kmalloc), new ns otherwise | 33 | * Return NULL on error (failure to kmalloc), new ns otherwise |
34 | */ | 34 | */ |
35 | static struct uts_namespace *clone_uts_ns(struct task_struct *tsk, | 35 | static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns, |
36 | struct uts_namespace *old_ns) | 36 | struct uts_namespace *old_ns) |
37 | { | 37 | { |
38 | struct uts_namespace *ns; | 38 | struct uts_namespace *ns; |
@@ -43,7 +43,7 @@ static struct uts_namespace *clone_uts_ns(struct task_struct *tsk, | |||
43 | 43 | ||
44 | down_read(&uts_sem); | 44 | down_read(&uts_sem); |
45 | memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); | 45 | memcpy(&ns->name, &old_ns->name, sizeof(ns->name)); |
46 | ns->user_ns = get_user_ns(task_cred_xxx(tsk, user_ns)); | 46 | ns->user_ns = get_user_ns(user_ns); |
47 | up_read(&uts_sem); | 47 | up_read(&uts_sem); |
48 | return ns; | 48 | return ns; |
49 | } | 49 | } |
@@ -55,9 +55,8 @@ static struct uts_namespace *clone_uts_ns(struct task_struct *tsk, | |||
55 | * versa. | 55 | * versa. |
56 | */ | 56 | */ |
57 | struct uts_namespace *copy_utsname(unsigned long flags, | 57 | struct uts_namespace *copy_utsname(unsigned long flags, |
58 | struct task_struct *tsk) | 58 | struct user_namespace *user_ns, struct uts_namespace *old_ns) |
59 | { | 59 | { |
60 | struct uts_namespace *old_ns = tsk->nsproxy->uts_ns; | ||
61 | struct uts_namespace *new_ns; | 60 | struct uts_namespace *new_ns; |
62 | 61 | ||
63 | BUG_ON(!old_ns); | 62 | BUG_ON(!old_ns); |
@@ -66,7 +65,7 @@ struct uts_namespace *copy_utsname(unsigned long flags, | |||
66 | if (!(flags & CLONE_NEWUTS)) | 65 | if (!(flags & CLONE_NEWUTS)) |
67 | return old_ns; | 66 | return old_ns; |
68 | 67 | ||
69 | new_ns = clone_uts_ns(tsk, old_ns); | 68 | new_ns = clone_uts_ns(user_ns, old_ns); |
70 | 69 | ||
71 | put_uts_ns(old_ns); | 70 | put_uts_ns(old_ns); |
72 | return new_ns; | 71 | return new_ns; |