diff options
Diffstat (limited to 'kernel/user_namespace.c')
-rw-r--r-- | kernel/user_namespace.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 532858fa5b88..0d9c51d67333 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c | |||
@@ -19,6 +19,7 @@ static struct user_namespace *clone_user_ns(struct user_namespace *old_ns) | |||
19 | { | 19 | { |
20 | struct user_namespace *ns; | 20 | struct user_namespace *ns; |
21 | struct user_struct *new_user; | 21 | struct user_struct *new_user; |
22 | struct cred *new; | ||
22 | int n; | 23 | int n; |
23 | 24 | ||
24 | ns = kmalloc(sizeof(struct user_namespace), GFP_KERNEL); | 25 | ns = kmalloc(sizeof(struct user_namespace), GFP_KERNEL); |
@@ -38,14 +39,23 @@ static struct user_namespace *clone_user_ns(struct user_namespace *old_ns) | |||
38 | } | 39 | } |
39 | 40 | ||
40 | /* Reset current->user with a new one */ | 41 | /* Reset current->user with a new one */ |
41 | new_user = alloc_uid(ns, current->uid); | 42 | new_user = alloc_uid(ns, current_uid()); |
42 | if (!new_user) { | 43 | if (!new_user) { |
43 | free_uid(ns->root_user); | 44 | free_uid(ns->root_user); |
44 | kfree(ns); | 45 | kfree(ns); |
45 | return ERR_PTR(-ENOMEM); | 46 | return ERR_PTR(-ENOMEM); |
46 | } | 47 | } |
47 | 48 | ||
48 | switch_uid(new_user); | 49 | /* Install the new user */ |
50 | new = prepare_creds(); | ||
51 | if (!new) { | ||
52 | free_uid(new_user); | ||
53 | free_uid(ns->root_user); | ||
54 | kfree(ns); | ||
55 | } | ||
56 | free_uid(new->user); | ||
57 | new->user = new_user; | ||
58 | commit_creds(new); | ||
49 | return ns; | 59 | return ns; |
50 | } | 60 | } |
51 | 61 | ||