Lines Matching refs:new
170 struct cred *new; in cred_alloc_blank() local
172 new = kmem_cache_zalloc(cred_jar, GFP_KERNEL); in cred_alloc_blank()
173 if (!new) in cred_alloc_blank()
176 atomic_long_set(&new->usage, 1); in cred_alloc_blank()
177 if (security_cred_alloc_blank(new, GFP_KERNEL_ACCOUNT) < 0) in cred_alloc_blank()
180 return new; in cred_alloc_blank()
183 abort_creds(new); in cred_alloc_blank()
205 struct cred *new; in prepare_creds() local
207 new = kmem_cache_alloc(cred_jar, GFP_KERNEL); in prepare_creds()
208 if (!new) in prepare_creds()
211 kdebug("prepare_creds() alloc %p", new); in prepare_creds()
214 memcpy(new, old, sizeof(struct cred)); in prepare_creds()
216 new->non_rcu = 0; in prepare_creds()
217 atomic_long_set(&new->usage, 1); in prepare_creds()
218 get_group_info(new->group_info); in prepare_creds()
219 get_uid(new->user); in prepare_creds()
220 get_user_ns(new->user_ns); in prepare_creds()
223 key_get(new->session_keyring); in prepare_creds()
224 key_get(new->process_keyring); in prepare_creds()
225 key_get(new->thread_keyring); in prepare_creds()
226 key_get(new->request_key_auth); in prepare_creds()
230 new->security = NULL; in prepare_creds()
233 new->ucounts = get_ucounts(new->ucounts); in prepare_creds()
234 if (!new->ucounts) in prepare_creds()
237 if (security_prepare_creds(new, old, GFP_KERNEL_ACCOUNT) < 0) in prepare_creds()
240 return new; in prepare_creds()
243 abort_creds(new); in prepare_creds()
254 struct cred *new; in prepare_exec_creds() local
256 new = prepare_creds(); in prepare_exec_creds()
257 if (!new) in prepare_exec_creds()
258 return new; in prepare_exec_creds()
262 key_put(new->thread_keyring); in prepare_exec_creds()
263 new->thread_keyring = NULL; in prepare_exec_creds()
266 key_put(new->process_keyring); in prepare_exec_creds()
267 new->process_keyring = NULL; in prepare_exec_creds()
270 new->suid = new->fsuid = new->euid; in prepare_exec_creds()
271 new->sgid = new->fsgid = new->egid; in prepare_exec_creds()
273 return new; in prepare_exec_creds()
287 struct cred *new; in copy_creds() local
308 new = prepare_creds(); in copy_creds()
309 if (!new) in copy_creds()
313 ret = create_user_ns(new); in copy_creds()
316 ret = set_cred_ucounts(new); in copy_creds()
324 if (new->thread_keyring) { in copy_creds()
325 key_put(new->thread_keyring); in copy_creds()
326 new->thread_keyring = NULL; in copy_creds()
328 install_thread_keyring_to_cred(new); in copy_creds()
335 key_put(new->process_keyring); in copy_creds()
336 new->process_keyring = NULL; in copy_creds()
340 p->cred = p->real_cred = get_cred(new); in copy_creds()
345 put_cred(new); in copy_creds()
388 int commit_creds(struct cred *new) in commit_creds() argument
393 kdebug("commit_creds(%p{%ld})", new, in commit_creds()
394 atomic_long_read(&new->usage)); in commit_creds()
397 BUG_ON(atomic_long_read(&new->usage) < 1); in commit_creds()
399 get_cred(new); /* we will require a ref for the subj creds too */ in commit_creds()
402 if (!uid_eq(old->euid, new->euid) || in commit_creds()
403 !gid_eq(old->egid, new->egid) || in commit_creds()
404 !uid_eq(old->fsuid, new->fsuid) || in commit_creds()
405 !gid_eq(old->fsgid, new->fsgid) || in commit_creds()
406 !cred_cap_issubset(old, new)) { in commit_creds()
423 if (!uid_eq(new->fsuid, old->fsuid)) in commit_creds()
424 key_fsuid_changed(new); in commit_creds()
425 if (!gid_eq(new->fsgid, old->fsgid)) in commit_creds()
426 key_fsgid_changed(new); in commit_creds()
432 if (new->user != old->user || new->user_ns != old->user_ns) in commit_creds()
433 inc_rlimit_ucounts(new->ucounts, UCOUNT_RLIMIT_NPROC, 1); in commit_creds()
434 rcu_assign_pointer(task->real_cred, new); in commit_creds()
435 rcu_assign_pointer(task->cred, new); in commit_creds()
436 if (new->user != old->user || new->user_ns != old->user_ns) in commit_creds()
440 if (!uid_eq(new->uid, old->uid) || in commit_creds()
441 !uid_eq(new->euid, old->euid) || in commit_creds()
442 !uid_eq(new->suid, old->suid) || in commit_creds()
443 !uid_eq(new->fsuid, old->fsuid)) in commit_creds()
446 if (!gid_eq(new->gid, old->gid) || in commit_creds()
447 !gid_eq(new->egid, old->egid) || in commit_creds()
448 !gid_eq(new->sgid, old->sgid) || in commit_creds()
449 !gid_eq(new->fsgid, old->fsgid)) in commit_creds()
466 void abort_creds(struct cred *new) in abort_creds() argument
468 kdebug("abort_creds(%p{%ld})", new, in abort_creds()
469 atomic_long_read(&new->usage)); in abort_creds()
471 BUG_ON(atomic_long_read(&new->usage) < 1); in abort_creds()
472 put_cred(new); in abort_creds()
483 const struct cred *override_creds(const struct cred *new) in override_creds() argument
487 kdebug("override_creds(%p{%ld})", new, in override_creds()
488 atomic_long_read(&new->usage)); in override_creds()
498 get_new_cred((struct cred *)new); in override_creds()
499 rcu_assign_pointer(current->cred, new); in override_creds()
580 int set_cred_ucounts(struct cred *new) in set_cred_ucounts() argument
582 struct ucounts *new_ucounts, *old_ucounts = new->ucounts; in set_cred_ucounts()
588 if (old_ucounts->ns == new->user_ns && uid_eq(old_ucounts->uid, new->uid)) in set_cred_ucounts()
591 if (!(new_ucounts = alloc_ucounts(new->user_ns, new->uid))) in set_cred_ucounts()
594 new->ucounts = new_ucounts; in set_cred_ucounts()
629 struct cred *new; in prepare_kernel_cred() local
634 new = kmem_cache_alloc(cred_jar, GFP_KERNEL); in prepare_kernel_cred()
635 if (!new) in prepare_kernel_cred()
638 kdebug("prepare_kernel_cred() alloc %p", new); in prepare_kernel_cred()
642 *new = *old; in prepare_kernel_cred()
643 new->non_rcu = 0; in prepare_kernel_cred()
644 atomic_long_set(&new->usage, 1); in prepare_kernel_cred()
645 get_uid(new->user); in prepare_kernel_cred()
646 get_user_ns(new->user_ns); in prepare_kernel_cred()
647 get_group_info(new->group_info); in prepare_kernel_cred()
650 new->session_keyring = NULL; in prepare_kernel_cred()
651 new->process_keyring = NULL; in prepare_kernel_cred()
652 new->thread_keyring = NULL; in prepare_kernel_cred()
653 new->request_key_auth = NULL; in prepare_kernel_cred()
654 new->jit_keyring = KEY_REQKEY_DEFL_THREAD_KEYRING; in prepare_kernel_cred()
658 new->security = NULL; in prepare_kernel_cred()
660 new->ucounts = get_ucounts(new->ucounts); in prepare_kernel_cred()
661 if (!new->ucounts) in prepare_kernel_cred()
664 if (security_prepare_creds(new, old, GFP_KERNEL_ACCOUNT) < 0) in prepare_kernel_cred()
668 return new; in prepare_kernel_cred()
671 put_cred(new); in prepare_kernel_cred()
685 int set_security_override(struct cred *new, u32 secid) in set_security_override() argument
687 return security_kernel_act_as(new, secid); in set_security_override()
701 int set_security_override_from_ctx(struct cred *new, const char *secctx) in set_security_override_from_ctx() argument
710 return set_security_override(new, secid); in set_security_override_from_ctx()
723 int set_create_files_as(struct cred *new, struct inode *inode) in set_create_files_as() argument
727 new->fsuid = inode->i_uid; in set_create_files_as()
728 new->fsgid = inode->i_gid; in set_create_files_as()
729 return security_kernel_create_files_as(new, inode); in set_create_files_as()