aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/credentials.txt
diff options
context:
space:
mode:
authorSerge E. Hallyn <serue@us.ibm.com>2010-04-26 06:58:49 -0400
committerJames Morris <jmorris@namei.org>2010-04-26 18:49:03 -0400
commitb03df87d119f50715891dcc09e487f6ae5c029f1 (patch)
tree69ef56146350a2f7d7bc7743e856490cc14bb7a5 /Documentation/credentials.txt
parent98ec4373bab1d839f794e9a4edc29f77eb9d897e (diff)
CRED: Holding a spinlock does not imply the holding of RCU read lock
Change the credentials documentation to make it clear that the RCU read lock must be explicitly held when accessing credentials pointers in some other task than current. Holding a spinlock does not implicitly hold the RCU read lock. Signed-off-by: Serge Hallyn <serue@us.ibm.com> Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'Documentation/credentials.txt')
-rw-r--r--Documentation/credentials.txt14
1 files changed, 5 insertions, 9 deletions
diff --git a/Documentation/credentials.txt b/Documentation/credentials.txt
index df03169782ea..a2db35287003 100644
--- a/Documentation/credentials.txt
+++ b/Documentation/credentials.txt
@@ -408,9 +408,6 @@ This should be used inside the RCU read lock, as in the following example:
408 ... 408 ...
409 } 409 }
410 410
411A function need not get RCU read lock to use __task_cred() if it is holding a
412spinlock at the time as this implicitly holds the RCU read lock.
413
414Should it be necessary to hold another task's credentials for a long period of 411Should it be necessary to hold another task's credentials for a long period of
415time, and possibly to sleep whilst doing so, then the caller should get a 412time, and possibly to sleep whilst doing so, then the caller should get a
416reference on them using: 413reference on them using:
@@ -426,17 +423,16 @@ credentials, hiding the RCU magic from the caller:
426 uid_t task_uid(task) Task's real UID 423 uid_t task_uid(task) Task's real UID
427 uid_t task_euid(task) Task's effective UID 424 uid_t task_euid(task) Task's effective UID
428 425
429If the caller is holding a spinlock or the RCU read lock at the time anyway, 426If the caller is holding the RCU read lock at the time anyway, then:
430then:
431 427
432 __task_cred(task)->uid 428 __task_cred(task)->uid
433 __task_cred(task)->euid 429 __task_cred(task)->euid
434 430
435should be used instead. Similarly, if multiple aspects of a task's credentials 431should be used instead. Similarly, if multiple aspects of a task's credentials
436need to be accessed, RCU read lock or a spinlock should be used, __task_cred() 432need to be accessed, RCU read lock should be used, __task_cred() called, the
437called, the result stored in a temporary pointer and then the credential 433result stored in a temporary pointer and then the credential aspects called
438aspects called from that before dropping the lock. This prevents the 434from that before dropping the lock. This prevents the potentially expensive
439potentially expensive RCU magic from being invoked multiple times. 435RCU magic from being invoked multiple times.
440 436
441Should some other single aspect of another task's credentials need to be 437Should some other single aspect of another task's credentials need to be
442accessed, then this can be used: 438accessed, then this can be used: