aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cred.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2011-11-17 00:52:53 -0500
committerEric W. Biederman <ebiederm@xmission.com>2012-04-07 19:55:52 -0400
commit0093ccb68f3753c0ba4d74c89d7e0f444b8d6123 (patch)
treea6fc0ea2a6dfc338fa8fc7126005f40109ef8dce /kernel/cred.c
parentc4a4d603796c727b9555867571f89483be9c565e (diff)
cred: Refcount the user_ns pointed to by the cred.
struct user_struct will shortly loose it's user_ns reference so make the cred user_ns reference a proper reference complete with reference counting. Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'kernel/cred.c')
-rw-r--r--kernel/cred.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/kernel/cred.c b/kernel/cred.c
index 97b36eeca4c9..7a0d80669886 100644
--- a/kernel/cred.c
+++ b/kernel/cred.c
@@ -148,6 +148,7 @@ static void put_cred_rcu(struct rcu_head *rcu)
148 if (cred->group_info) 148 if (cred->group_info)
149 put_group_info(cred->group_info); 149 put_group_info(cred->group_info);
150 free_uid(cred->user); 150 free_uid(cred->user);
151 put_user_ns(cred->user_ns);
151 kmem_cache_free(cred_jar, cred); 152 kmem_cache_free(cred_jar, cred);
152} 153}
153 154
@@ -303,6 +304,7 @@ struct cred *prepare_creds(void)
303 set_cred_subscribers(new, 0); 304 set_cred_subscribers(new, 0);
304 get_group_info(new->group_info); 305 get_group_info(new->group_info);
305 get_uid(new->user); 306 get_uid(new->user);
307 get_user_ns(new->user_ns);
306 308
307#ifdef CONFIG_KEYS 309#ifdef CONFIG_KEYS
308 key_get(new->thread_keyring); 310 key_get(new->thread_keyring);
@@ -412,11 +414,6 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags)
412 goto error_put; 414 goto error_put;
413 } 415 }
414 416
415 /* cache user_ns in cred. Doesn't need a refcount because it will
416 * stay pinned by cred->user
417 */
418 new->user_ns = new->user->user_ns;
419
420#ifdef CONFIG_KEYS 417#ifdef CONFIG_KEYS
421 /* new threads get their own thread keyrings if their parent already 418 /* new threads get their own thread keyrings if their parent already
422 * had one */ 419 * had one */
@@ -676,6 +673,7 @@ struct cred *prepare_kernel_cred(struct task_struct *daemon)
676 atomic_set(&new->usage, 1); 673 atomic_set(&new->usage, 1);
677 set_cred_subscribers(new, 0); 674 set_cred_subscribers(new, 0);
678 get_uid(new->user); 675 get_uid(new->user);
676 get_user_ns(new->user_ns);
679 get_group_info(new->group_info); 677 get_group_info(new->group_info);
680 678
681#ifdef CONFIG_KEYS 679#ifdef CONFIG_KEYS