aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/user.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/user.c')
-rw-r--r--kernel/user.c27
1 files changed, 3 insertions, 24 deletions
diff --git a/kernel/user.c b/kernel/user.c
index debce602bfdd..865ecf57a096 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -53,10 +53,6 @@ struct user_struct root_user = {
53 .files = ATOMIC_INIT(0), 53 .files = ATOMIC_INIT(0),
54 .sigpending = ATOMIC_INIT(0), 54 .sigpending = ATOMIC_INIT(0),
55 .locked_shm = 0, 55 .locked_shm = 0,
56#ifdef CONFIG_KEYS
57 .uid_keyring = &root_user_keyring,
58 .session_keyring = &root_session_keyring,
59#endif
60#ifdef CONFIG_USER_SCHED 56#ifdef CONFIG_USER_SCHED
61 .tg = &init_task_group, 57 .tg = &init_task_group,
62#endif 58#endif
@@ -388,7 +384,7 @@ void free_uid(struct user_struct *up)
388 local_irq_restore(flags); 384 local_irq_restore(flags);
389} 385}
390 386
391struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid) 387struct user_struct *alloc_uid(struct user_namespace *ns, uid_t uid)
392{ 388{
393 struct hlist_head *hashent = uidhashentry(ns, uid); 389 struct hlist_head *hashent = uidhashentry(ns, uid);
394 struct user_struct *up, *new; 390 struct user_struct *up, *new;
@@ -403,29 +399,15 @@ struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid)
403 spin_unlock_irq(&uidhash_lock); 399 spin_unlock_irq(&uidhash_lock);
404 400
405 if (!up) { 401 if (!up) {
406 new = kmem_cache_alloc(uid_cachep, GFP_KERNEL); 402 new = kmem_cache_zalloc(uid_cachep, GFP_KERNEL);
407 if (!new) 403 if (!new)
408 goto out_unlock; 404 goto out_unlock;
409 405
410 new->uid = uid; 406 new->uid = uid;
411 atomic_set(&new->__count, 1); 407 atomic_set(&new->__count, 1);
412 atomic_set(&new->processes, 0);
413 atomic_set(&new->files, 0);
414 atomic_set(&new->sigpending, 0);
415#ifdef CONFIG_INOTIFY_USER
416 atomic_set(&new->inotify_watches, 0);
417 atomic_set(&new->inotify_devs, 0);
418#endif
419#ifdef CONFIG_POSIX_MQUEUE
420 new->mq_bytes = 0;
421#endif
422 new->locked_shm = 0;
423
424 if (alloc_uid_keyring(new, current) < 0)
425 goto out_free_user;
426 408
427 if (sched_create_user(new) < 0) 409 if (sched_create_user(new) < 0)
428 goto out_put_keys; 410 goto out_free_user;
429 411
430 if (uids_user_create(new)) 412 if (uids_user_create(new))
431 goto out_destoy_sched; 413 goto out_destoy_sched;
@@ -459,9 +441,6 @@ struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid)
459 441
460out_destoy_sched: 442out_destoy_sched:
461 sched_destroy_user(new); 443 sched_destroy_user(new);
462out_put_keys:
463 key_put(new->uid_keyring);
464 key_put(new->session_keyring);
465out_free_user: 444out_free_user:
466 kmem_cache_free(uid_cachep, new); 445 kmem_cache_free(uid_cachep, new);
467out_unlock: 446out_unlock: