diff options
Diffstat (limited to 'include/linux/cred.h')
-rw-r--r-- | include/linux/cred.h | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/include/linux/cred.h b/include/linux/cred.h index 52507c3e1387..4d2c39573f36 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h | |||
@@ -153,10 +153,10 @@ struct cred { | |||
153 | extern void __put_cred(struct cred *); | 153 | extern void __put_cred(struct cred *); |
154 | extern void exit_creds(struct task_struct *); | 154 | extern void exit_creds(struct task_struct *); |
155 | extern int copy_creds(struct task_struct *, unsigned long); | 155 | extern int copy_creds(struct task_struct *, unsigned long); |
156 | extern const struct cred *get_task_cred(struct task_struct *); | ||
156 | extern struct cred *cred_alloc_blank(void); | 157 | extern struct cred *cred_alloc_blank(void); |
157 | extern struct cred *prepare_creds(void); | 158 | extern struct cred *prepare_creds(void); |
158 | extern struct cred *prepare_exec_creds(void); | 159 | extern struct cred *prepare_exec_creds(void); |
159 | extern struct cred *prepare_usermodehelper_creds(void); | ||
160 | extern int commit_creds(struct cred *); | 160 | extern int commit_creds(struct cred *); |
161 | extern void abort_creds(struct cred *); | 161 | extern void abort_creds(struct cred *); |
162 | extern const struct cred *override_creds(const struct cred *); | 162 | extern const struct cred *override_creds(const struct cred *); |
@@ -274,33 +274,18 @@ static inline void put_cred(const struct cred *_cred) | |||
274 | * @task: The task to query | 274 | * @task: The task to query |
275 | * | 275 | * |
276 | * Access the objective credentials of a task. The caller must hold the RCU | 276 | * Access the objective credentials of a task. The caller must hold the RCU |
277 | * readlock. | 277 | * readlock or the task must be dead and unable to change its own credentials. |
278 | * | 278 | * |
279 | * The caller must make sure task doesn't go away, either by holding a ref on | 279 | * The result of this function should not be passed directly to get_cred(); |
280 | * task or by holding tasklist_lock to prevent it from being unlinked. | 280 | * rather get_task_cred() should be used instead. |
281 | */ | 281 | */ |
282 | #define __task_cred(task) \ | 282 | #define __task_cred(task) \ |
283 | ((const struct cred *)(rcu_dereference_check((task)->real_cred, rcu_read_lock_held() || lockdep_tasklist_lock_is_held()))) | 283 | ({ \ |
284 | 284 | const struct task_struct *__t = (task); \ | |
285 | /** | 285 | rcu_dereference_check(__t->real_cred, \ |
286 | * get_task_cred - Get another task's objective credentials | 286 | rcu_read_lock_held() || \ |
287 | * @task: The task to query | 287 | task_is_dead(__t)); \ |
288 | * | 288 | }) |
289 | * Get the objective credentials of a task, pinning them so that they can't go | ||
290 | * away. Accessing a task's credentials directly is not permitted. | ||
291 | * | ||
292 | * The caller must make sure task doesn't go away, either by holding a ref on | ||
293 | * task or by holding tasklist_lock to prevent it from being unlinked. | ||
294 | */ | ||
295 | #define get_task_cred(task) \ | ||
296 | ({ \ | ||
297 | struct cred *__cred; \ | ||
298 | rcu_read_lock(); \ | ||
299 | __cred = (struct cred *) __task_cred((task)); \ | ||
300 | get_cred(__cred); \ | ||
301 | rcu_read_unlock(); \ | ||
302 | __cred; \ | ||
303 | }) | ||
304 | 289 | ||
305 | /** | 290 | /** |
306 | * get_current_cred - Get the current task's subjective credentials | 291 | * get_current_cred - Get the current task's subjective credentials |