diff options
| author | Al Viro <viro@ZenIV.linux.org.uk> | 2011-08-07 13:55:11 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-08-07 16:42:35 -0400 |
| commit | 3295514841c2112d94451ba5deaf54f5afb78ea9 (patch) | |
| tree | 6df351cb1febbcd011d24fcf99d1b08167c68d5e | |
| parent | 7813b94a54987571082ff19e9d87eabbfec23b4e (diff) | |
fix rcu annotations noise in cred.h
task->cred is declared as __rcu, and access to other tasks' ->cred is,
indeed, protected. Access to current->cred does not need rcu_dereference()
at all, since only the task itself can change its ->cred. sparse, of
course, has no way of knowing that...
Add force-cast in current_cred(), make current_fsuid() et.al. use it.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | include/linux/cred.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/include/linux/cred.h b/include/linux/cred.h index 48e82af1159b..98f46efbe2d2 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h | |||
| @@ -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 | (*(__force struct cred **)¤t->cred) |
| 272 | 273 | ||
| 273 | /** | 274 | /** |
| 274 | * __task_cred - Access a task's objective credentials | 275 | * __task_cred - Access a task's objective credentials |
| @@ -307,7 +308,7 @@ static inline void put_cred(const struct cred *_cred) | |||
| 307 | ({ \ | 308 | ({ \ |
| 308 | struct user_struct *__u; \ | 309 | struct user_struct *__u; \ |
| 309 | struct cred *__cred; \ | 310 | 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 | }) |
| @@ -322,7 +323,7 @@ static inline void put_cred(const struct cred *_cred) | |||
| 322 | ({ \ | 323 | ({ \ |
| 323 | struct group_info *__groups; \ | 324 | struct group_info *__groups; \ |
| 324 | struct cred *__cred; \ | 325 | 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)) |
