~ubuntu-branches/ubuntu/wily/apparmor/wily

« back to all changes in this revision

Viewing changes to kernel-patches/for-mainline/rcu-locking-docs.txt

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2011-04-27 10:38:07 UTC
  • mfrom: (5.1.118 natty)
  • Revision ID: james.westby@ubuntu.com-20110427103807-ym3rhwys6o84ith0
Tags: 2.6.1-2
debian/copyright: clarify for some full organization names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Index: linux-2.6-apparmor/security/apparmor/locking.txt
2
 
===================================================================
3
 
--- linux-2.6-apparmor.orig/security/apparmor/locking.txt
4
 
+++ linux-2.6-apparmor/security/apparmor/locking.txt
5
 
@@ -15,15 +15,11 @@ Which lock protects what?
6
 
        >-----------------------+-------------------------------<
7
 
        | profile_list,         | profile_list_lock             |
8
 
        +-----------------------+-------------------------------+
9
 
+       | aa_profile            | (reference count)             |
10
 
+       +-----------------------+-------------------------------+
11
 
        | aa_profile->          | aa_profile->lock              |
12
 
        |   isstale,            |                               |
13
 
        |   task_contexts       |                               |
14
 
-       | aa_profile->count     | RCU                           |
15
 
-       +-----------------------+-------------------------------+
16
 
-       | aa_task_context->     |                               |
17
 
-       |   profile             | read: RCU                     |
18
 
-       |                       | write: aa_profile->lock +     |
19
 
-       |                       |        task_lock()            |
20
 
        +-----------------------+-------------------------------+
21
 
        | task_struct->security | read: RCU                     |
22
 
        |                       | write: task_lock()            |
23
 
@@ -39,8 +35,12 @@ When moving a task context from one prof
24
 
 profile locks with lock_both_profiles(). This ensures that both locks
25
 
 are always taken in the same order, and so we won't deadlock.
26
 
 
27
 
-Since aa_task_struct->profile is RCU protected, it can change under a
28
 
-reader at any time. Therefore, we should grab the pointer and use the
29
 
-cached result, but we can only do this after all blocking operations (or
30
 
-else the pointer could just change again). The ->profile pointer may
31
 
-change or become NULL at any time; we must be careful about this.
32
 
+Since task_struct->security is RCU protected the aa_task_struct it
33
 
+references is only guarenteed to exist for the rcu cycle.  Where
34
 
+aa_task_context->profile is needed in blocking operations the
35
 
+profile's reference count is incremented and the profile reference
36
 
+is used.
37
 
+
38
 
+Profiles on profile_list are never stale: when a profile becomes stale,
39
 
+it is removed from profile_list at the same time (under profile_list_lock
40
 
+and aa_profile->lock).