diff options
Diffstat (limited to 'kernel/cred.c')
-rw-r--r-- | kernel/cred.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/kernel/cred.c b/kernel/cred.c index a2d5504fbcc2..9a3e22641fe7 100644 --- a/kernel/cred.c +++ b/kernel/cred.c | |||
@@ -22,10 +22,6 @@ | |||
22 | #define kdebug(FMT, ...) \ | 22 | #define kdebug(FMT, ...) \ |
23 | printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__) | 23 | printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__) |
24 | #else | 24 | #else |
25 | static inline __attribute__((format(printf, 1, 2))) | ||
26 | void no_printk(const char *fmt, ...) | ||
27 | { | ||
28 | } | ||
29 | #define kdebug(FMT, ...) \ | 25 | #define kdebug(FMT, ...) \ |
30 | no_printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__) | 26 | no_printk("[%-5.5s%5u] "FMT"\n", current->comm, current->pid ,##__VA_ARGS__) |
31 | #endif | 27 | #endif |
@@ -209,6 +205,31 @@ void exit_creds(struct task_struct *tsk) | |||
209 | } | 205 | } |
210 | } | 206 | } |
211 | 207 | ||
208 | /** | ||
209 | * get_task_cred - Get another task's objective credentials | ||
210 | * @task: The task to query | ||
211 | * | ||
212 | * Get the objective credentials of a task, pinning them so that they can't go | ||
213 | * away. Accessing a task's credentials directly is not permitted. | ||
214 | * | ||
215 | * The caller must also make sure task doesn't get deleted, either by holding a | ||
216 | * ref on task or by holding tasklist_lock to prevent it from being unlinked. | ||
217 | */ | ||
218 | const struct cred *get_task_cred(struct task_struct *task) | ||
219 | { | ||
220 | const struct cred *cred; | ||
221 | |||
222 | rcu_read_lock(); | ||
223 | |||
224 | do { | ||
225 | cred = __task_cred((task)); | ||
226 | BUG_ON(!cred); | ||
227 | } while (!atomic_inc_not_zero(&((struct cred *)cred)->usage)); | ||
228 | |||
229 | rcu_read_unlock(); | ||
230 | return cred; | ||
231 | } | ||
232 | |||
212 | /* | 233 | /* |
213 | * Allocate blank credentials, such that the credentials can be filled in at a | 234 | * Allocate blank credentials, such that the credentials can be filled in at a |
214 | * later date without risk of ENOMEM. | 235 | * later date without risk of ENOMEM. |