aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cred.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/kernel/cred.c b/kernel/cred.c
index 174fa84eca30..f1e22556bc49 100644
--- a/kernel/cred.c
+++ b/kernel/cred.c
@@ -646,6 +646,9 @@ void __init cred_init(void)
646 */ 646 */
647struct cred *prepare_kernel_cred(struct task_struct *daemon) 647struct cred *prepare_kernel_cred(struct task_struct *daemon)
648{ 648{
649#ifdef CONFIG_KEYS
650 struct thread_group_cred *tgcred;
651#endif
649 const struct cred *old; 652 const struct cred *old;
650 struct cred *new; 653 struct cred *new;
651 654
@@ -653,6 +656,12 @@ struct cred *prepare_kernel_cred(struct task_struct *daemon)
653 if (!new) 656 if (!new)
654 return NULL; 657 return NULL;
655 658
659 tgcred = kmalloc(sizeof(*tgcred), GFP_KERNEL);
660 if (!tgcred) {
661 kmem_cache_free(cred_jar, new);
662 return NULL;
663 }
664
656 kdebug("prepare_kernel_cred() alloc %p", new); 665 kdebug("prepare_kernel_cred() alloc %p", new);
657 666
658 if (daemon) 667 if (daemon)
@@ -669,8 +678,11 @@ struct cred *prepare_kernel_cred(struct task_struct *daemon)
669 get_group_info(new->group_info); 678 get_group_info(new->group_info);
670 679
671#ifdef CONFIG_KEYS 680#ifdef CONFIG_KEYS
672 atomic_inc(&init_tgcred.usage); 681 atomic_set(&tgcred->usage, 1);
673 new->tgcred = &init_tgcred; 682 spin_lock_init(&tgcred->lock);
683 tgcred->process_keyring = NULL;
684 tgcred->session_keyring = NULL;
685 new->tgcred = tgcred;
674 new->request_key_auth = NULL; 686 new->request_key_auth = NULL;
675 new->thread_keyring = NULL; 687 new->thread_keyring = NULL;
676 new->jit_keyring = KEY_REQKEY_DEFL_THREAD_KEYRING; 688 new->jit_keyring = KEY_REQKEY_DEFL_THREAD_KEYRING;