• Home
  • Raw
  • Download

Lines Matching refs:cred

43 struct cred init_cred = {
68 static inline void set_cred_subscribers(struct cred *cred, int n) in set_cred_subscribers() argument
71 atomic_set(&cred->subscribers, n); in set_cred_subscribers()
75 static inline int read_cred_subscribers(const struct cred *cred) in read_cred_subscribers() argument
78 return atomic_read(&cred->subscribers); in read_cred_subscribers()
84 static inline void alter_cred_subscribers(const struct cred *_cred, int n) in alter_cred_subscribers()
87 struct cred *cred = (struct cred *) _cred; in alter_cred_subscribers() local
89 atomic_add(n, &cred->subscribers); in alter_cred_subscribers()
98 struct cred *cred = container_of(rcu, struct cred, rcu); in put_cred_rcu() local
100 kdebug("put_cred_rcu(%p)", cred); in put_cred_rcu()
103 if (cred->magic != CRED_MAGIC_DEAD || in put_cred_rcu()
104 atomic_read(&cred->usage) != 0 || in put_cred_rcu()
105 read_cred_subscribers(cred) != 0) in put_cred_rcu()
108 cred, cred->magic, cred->put_addr, in put_cred_rcu()
109 atomic_read(&cred->usage), in put_cred_rcu()
110 read_cred_subscribers(cred)); in put_cred_rcu()
112 if (atomic_read(&cred->usage) != 0) in put_cred_rcu()
114 cred, atomic_read(&cred->usage)); in put_cred_rcu()
117 security_cred_free(cred); in put_cred_rcu()
118 key_put(cred->session_keyring); in put_cred_rcu()
119 key_put(cred->process_keyring); in put_cred_rcu()
120 key_put(cred->thread_keyring); in put_cred_rcu()
121 key_put(cred->request_key_auth); in put_cred_rcu()
122 if (cred->group_info) in put_cred_rcu()
123 put_group_info(cred->group_info); in put_cred_rcu()
124 free_uid(cred->user); in put_cred_rcu()
125 if (cred->ucounts) in put_cred_rcu()
126 put_ucounts(cred->ucounts); in put_cred_rcu()
127 put_user_ns(cred->user_ns); in put_cred_rcu()
128 kmem_cache_free(cred_jar, cred); in put_cred_rcu()
137 void __put_cred(struct cred *cred) in __put_cred() argument
139 kdebug("__put_cred(%p{%d,%d})", cred, in __put_cred()
140 atomic_read(&cred->usage), in __put_cred()
141 read_cred_subscribers(cred)); in __put_cred()
143 BUG_ON(atomic_read(&cred->usage) != 0); in __put_cred()
145 BUG_ON(read_cred_subscribers(cred) != 0); in __put_cred()
146 cred->magic = CRED_MAGIC_DEAD; in __put_cred()
147 cred->put_addr = __builtin_return_address(0); in __put_cred()
149 BUG_ON(cred == current->cred); in __put_cred()
150 BUG_ON(cred == current->real_cred); in __put_cred()
152 if (cred->non_rcu) in __put_cred()
153 put_cred_rcu(&cred->rcu); in __put_cred()
155 call_rcu(&cred->rcu, put_cred_rcu); in __put_cred()
164 struct cred *cred; in exit_creds() local
166 kdebug("exit_creds(%u,%p,%p,{%d,%d})", tsk->pid, tsk->real_cred, tsk->cred, in exit_creds()
167 atomic_read(&tsk->cred->usage), in exit_creds()
168 read_cred_subscribers(tsk->cred)); in exit_creds()
170 cred = (struct cred *) tsk->real_cred; in exit_creds()
172 validate_creds(cred); in exit_creds()
173 alter_cred_subscribers(cred, -1); in exit_creds()
174 put_cred(cred); in exit_creds()
176 cred = (struct cred *) tsk->cred; in exit_creds()
177 tsk->cred = NULL; in exit_creds()
178 validate_creds(cred); in exit_creds()
179 alter_cred_subscribers(cred, -1); in exit_creds()
180 put_cred(cred); in exit_creds()
186 trace_android_rvh_exit_creds(tsk, cred); in exit_creds()
199 const struct cred *get_task_cred(struct task_struct *task) in get_task_cred()
201 const struct cred *cred; in get_task_cred() local
206 cred = __task_cred((task)); in get_task_cred()
207 BUG_ON(!cred); in get_task_cred()
208 } while (!get_cred_rcu(cred)); in get_task_cred()
211 return cred; in get_task_cred()
219 struct cred *cred_alloc_blank(void) in cred_alloc_blank()
221 struct cred *new; in cred_alloc_blank()
255 struct cred *prepare_creds(void) in prepare_creds()
258 const struct cred *old; in prepare_creds()
259 struct cred *new; in prepare_creds()
269 old = task->cred; in prepare_creds()
270 memcpy(new, old, sizeof(struct cred)); in prepare_creds()
310 struct cred *prepare_exec_creds(void) in prepare_exec_creds()
312 struct cred *new; in prepare_exec_creds()
345 struct cred *new; in copy_creds()
354 !p->cred->thread_keyring && in copy_creds()
358 p->real_cred = get_cred(p->cred); in copy_creds()
359 get_cred(p->cred); in copy_creds()
360 alter_cred_subscribers(p->cred, 2); in copy_creds()
362 p->cred, atomic_read(&p->cred->usage), in copy_creds()
363 read_cred_subscribers(p->cred)); in copy_creds()
400 p->cred = p->real_cred = get_cred(new); in copy_creds()
411 static bool cred_cap_issubset(const struct cred *set, const struct cred *subset) in cred_cap_issubset()
450 int commit_creds(struct cred *new) in commit_creds()
453 const struct cred *old = task->real_cred; in commit_creds()
459 BUG_ON(task->cred != old); in commit_creds()
504 rcu_assign_pointer(task->cred, new); in commit_creds()
537 void abort_creds(struct cred *new) in abort_creds()
558 const struct cred *override_creds(const struct cred *new) in override_creds()
560 const struct cred *old = current->cred; in override_creds()
580 get_new_cred((struct cred *)new); in override_creds()
582 rcu_assign_pointer(current->cred, new); in override_creds()
600 void revert_creds(const struct cred *old) in revert_creds()
602 const struct cred *override = current->cred; in revert_creds()
611 rcu_assign_pointer(current->cred, old); in revert_creds()
632 int cred_fscmp(const struct cred *a, const struct cred *b) in cred_fscmp()
672 int set_cred_ucounts(struct cred *new) in set_cred_ucounts()
698 cred_jar = kmem_cache_create("cred_jar", sizeof(struct cred), 0, in cred_init()
718 struct cred *prepare_kernel_cred(struct task_struct *daemon) in prepare_kernel_cred()
720 const struct cred *old; in prepare_kernel_cred()
721 struct cred *new; in prepare_kernel_cred()
781 int set_security_override(struct cred *new, u32 secid) in set_security_override()
797 int set_security_override_from_ctx(struct cred *new, const char *secctx) in set_security_override_from_ctx()
819 int set_create_files_as(struct cred *new, struct inode *inode) in set_create_files_as()
831 bool creds_are_invalid(const struct cred *cred) in creds_are_invalid() argument
833 if (cred->magic != CRED_MAGIC) in creds_are_invalid()
842 static void dump_invalid_creds(const struct cred *cred, const char *label, in dump_invalid_creds() argument
846 label, cred, in dump_invalid_creds()
847 cred == &init_cred ? "[init]" : "", in dump_invalid_creds()
848 cred == tsk->real_cred ? "[real]" : "", in dump_invalid_creds()
849 cred == tsk->cred ? "[eff]" : ""); in dump_invalid_creds()
851 cred->magic, cred->put_addr); in dump_invalid_creds()
853 atomic_read(&cred->usage), in dump_invalid_creds()
854 read_cred_subscribers(cred)); in dump_invalid_creds()
856 from_kuid_munged(&init_user_ns, cred->uid), in dump_invalid_creds()
857 from_kuid_munged(&init_user_ns, cred->euid), in dump_invalid_creds()
858 from_kuid_munged(&init_user_ns, cred->suid), in dump_invalid_creds()
859 from_kuid_munged(&init_user_ns, cred->fsuid)); in dump_invalid_creds()
861 from_kgid_munged(&init_user_ns, cred->gid), in dump_invalid_creds()
862 from_kgid_munged(&init_user_ns, cred->egid), in dump_invalid_creds()
863 from_kgid_munged(&init_user_ns, cred->sgid), in dump_invalid_creds()
864 from_kgid_munged(&init_user_ns, cred->fsgid)); in dump_invalid_creds()
866 printk(KERN_ERR "CRED: ->security is %p\n", cred->security); in dump_invalid_creds()
867 if ((unsigned long) cred->security >= PAGE_SIZE && in dump_invalid_creds()
868 (((unsigned long) cred->security & 0xffffff00) != in dump_invalid_creds()
871 ((u32*)cred->security)[0], in dump_invalid_creds()
872 ((u32*)cred->security)[1]); in dump_invalid_creds()
879 void __noreturn __invalid_creds(const struct cred *cred, const char *file, unsigned line) in __invalid_creds() argument
883 dump_invalid_creds(cred, "Specified", current); in __invalid_creds()
894 if (tsk->cred == tsk->real_cred) { in __validate_process_creds()
895 if (unlikely(read_cred_subscribers(tsk->cred) < 2 || in __validate_process_creds()
896 creds_are_invalid(tsk->cred))) in __validate_process_creds()
900 read_cred_subscribers(tsk->cred) < 1 || in __validate_process_creds()
902 creds_are_invalid(tsk->cred))) in __validate_process_creds()
912 if (tsk->cred != tsk->real_cred) in __validate_process_creds()
913 dump_invalid_creds(tsk->cred, "Effective", tsk); in __validate_process_creds()
926 tsk->real_cred, tsk->cred, in validate_creds_for_do_exit()
927 atomic_read(&tsk->cred->usage), in validate_creds_for_do_exit()
928 read_cred_subscribers(tsk->cred)); in validate_creds_for_do_exit()