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

« back to all changes in this revision

Viewing changes to kernel-patches/for-mainline/replace-activeptr.diff

  • 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
 
Remove get_task_activeptr_rcu() and get_activeptr_rcu().  Remove the
2
 
tiny optimization in aa_simple_write_to_buffer(): I bet it doesn't
3
 
matter at all.
4
 
 
5
 
Index: b/security/apparmor/inline.h
6
 
===================================================================
7
 
--- a/security/apparmor/inline.h
8
 
+++ b/security/apparmor/inline.h
9
 
@@ -34,38 +34,17 @@ static inline void put_aa_profile(struct
10
 
                kref_put(&BASE_PROFILE(p)->count, free_aa_profile_kref);
11
 
 }
12
 
 
13
 
-/**
14
 
- * get_task_activeptr_rcu - get pointer to @tsk's active profile.
15
 
- * @tsk: task to get active profile from
16
 
- *
17
 
- * Requires rcu_read_lock is held
18
 
- */
19
 
-static inline struct aa_profile *get_task_activeptr_rcu(struct task_struct *tsk)
20
 
-{
21
 
-       struct aa_task_context *cxt = aa_task_context(tsk);
22
 
-       struct aa_profile *active = NULL;
23
 
-
24
 
-       if (cxt)
25
 
-               active = (struct aa_profile *) rcu_dereference(cxt->active);
26
 
-
27
 
-       return active;
28
 
-}
29
 
-
30
 
-/**
31
 
- * get_activeptr_rcu - get pointer to current task's active profile
32
 
- * Requires rcu_read_lock is held
33
 
- */
34
 
-static inline struct aa_profile *get_activeptr_rcu(void)
35
 
-{
36
 
-       return get_task_activeptr_rcu(current);
37
 
-}
38
 
-
39
 
 static inline struct aa_profile *aa_get_profile(struct task_struct *task)
40
 
 {
41
 
-       struct aa_profile *active;
42
 
+       struct aa_task_context *cxt;
43
 
+       struct aa_profile *active = NULL;
44
 
 
45
 
        rcu_read_lock();
46
 
-       active = aa_dup_profile(get_task_activeptr_rcu(task));
47
 
+       cxt = aa_task_context(task);
48
 
+       if (cxt) {
49
 
+               active = (struct aa_profile *)rcu_dereference(cxt->active);
50
 
+               aa_dup_profile(active);
51
 
+       }
52
 
        rcu_read_unlock();
53
 
 
54
 
        return active;
55
 
Index: b/security/apparmor/apparmorfs.c
56
 
===================================================================
57
 
--- a/security/apparmor/apparmorfs.c
58
 
+++ b/security/apparmor/apparmorfs.c
59
 
@@ -164,18 +164,17 @@ static char *aa_simple_write_to_buffer(c
60
 
         * No sane person would add rules allowing this to a profile
61
 
         * but we enforce the restriction anyways.
62
 
         */
63
 
-       rcu_read_lock();
64
 
-       active = get_activeptr_rcu();
65
 
+       active = aa_get_profile(current);
66
 
        if (active) {
67
 
                AA_WARN("REJECTING access to profile %s (%s(%d) "
68
 
                        "profile %s active %s)\n",
69
 
                        msg, current->comm, current->pid,
70
 
                        BASE_PROFILE(active)->name, active->name);
71
 
+               put_aa_profile(active);
72
 
 
73
 
                data = ERR_PTR(-EPERM);
74
 
                goto out;
75
 
        }
76
 
-       rcu_read_unlock();
77
 
 
78
 
        data = vmalloc(alloc_size);
79
 
        if (data == NULL) {