diff options
Diffstat (limited to 'kernel/user_namespace.c')
| -rw-r--r-- | kernel/user_namespace.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index f82730adea00..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); |
| @@ -45,7 +46,16 @@ static struct user_namespace *clone_user_ns(struct user_namespace *old_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 | ||
