aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/cred.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/cred.h')
-rw-r--r--include/linux/cred.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/include/linux/cred.h b/include/linux/cred.h
index f240f2fa0197..40308969ed00 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -16,7 +16,7 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/key.h> 17#include <linux/key.h>
18#include <linux/selinux.h> 18#include <linux/selinux.h>
19#include <asm/atomic.h> 19#include <linux/atomic.h>
20 20
21struct user_struct; 21struct user_struct;
22struct cred; 22struct cred;
@@ -265,10 +265,11 @@ static inline void put_cred(const struct cred *_cred)
265/** 265/**
266 * current_cred - Access the current task's subjective credentials 266 * current_cred - Access the current task's subjective credentials
267 * 267 *
268 * Access the subjective credentials of the current task. 268 * Access the subjective credentials of the current task. RCU-safe,
269 * since nobody else can modify it.
269 */ 270 */
270#define current_cred() \ 271#define current_cred() \
271 (current->cred) 272 rcu_dereference_protected(current->cred, 1)
272 273
273/** 274/**
274 * __task_cred - Access a task's objective credentials 275 * __task_cred - Access a task's objective credentials
@@ -306,8 +307,8 @@ static inline void put_cred(const struct cred *_cred)
306#define get_current_user() \ 307#define get_current_user() \
307({ \ 308({ \
308 struct user_struct *__u; \ 309 struct user_struct *__u; \
309 struct cred *__cred; \ 310 const struct cred *__cred; \
310 __cred = (struct cred *) current_cred(); \ 311 __cred = current_cred(); \
311 __u = get_uid(__cred->user); \ 312 __u = get_uid(__cred->user); \
312 __u; \ 313 __u; \
313}) 314})
@@ -321,8 +322,8 @@ static inline void put_cred(const struct cred *_cred)
321#define get_current_groups() \ 322#define get_current_groups() \
322({ \ 323({ \
323 struct group_info *__groups; \ 324 struct group_info *__groups; \
324 struct cred *__cred; \ 325 const struct cred *__cred; \
325 __cred = (struct cred *) current_cred(); \ 326 __cred = current_cred(); \
326 __groups = get_group_info(__cred->group_info); \ 327 __groups = get_group_info(__cred->group_info); \
327 __groups; \ 328 __groups; \
328}) 329})
@@ -341,7 +342,7 @@ static inline void put_cred(const struct cred *_cred)
341 342
342#define current_cred_xxx(xxx) \ 343#define current_cred_xxx(xxx) \
343({ \ 344({ \
344 current->cred->xxx; \ 345 current_cred()->xxx; \
345}) 346})
346 347
347#define current_uid() (current_cred_xxx(uid)) 348#define current_uid() (current_cred_xxx(uid))