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

« back to all changes in this revision

Viewing changes to kernel-patches/for-mainline/aa_task_context.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
 
Replace AA_TASK_CONTEXT(task->security) with aa_task_context(task):
2
 
this is type safe. Use an inline function instead of a macro.
3
 
 
4
 
AA_PROFILE() is unused.
5
 
 
6
 
Index: b/security/apparmor/apparmor.h
7
 
===================================================================
8
 
--- a/security/apparmor/apparmor.h
9
 
+++ b/security/apparmor/apparmor.h
10
 
@@ -145,8 +145,10 @@ struct aa_task_context {
11
 
 
12
 
 typedef int (*aa_iter) (struct aa_task_context *, void *);
13
 
 
14
 
-#define AA_TASK_CONTEXT(sec)   ((struct aa_task_context*)(sec))
15
 
-#define AA_PROFILE(sec)                ((struct aa_profile*)(sec))
16
 
+static inline struct aa_task_context *aa_task_context(struct task_struct *task)
17
 
+{
18
 
+       return (struct aa_task_context *)task->security;
19
 
+}
20
 
 
21
 
 /* Lock protecting access to 'struct aa_task_context' accesses */
22
 
 extern spinlock_t cxt_lock;
23
 
Index: b/security/apparmor/inline.h
24
 
===================================================================
25
 
--- a/security/apparmor/inline.h
26
 
+++ b/security/apparmor/inline.h
27
 
@@ -42,7 +42,7 @@ static inline void put_aa_profile(struct
28
 
  */
29
 
 static inline struct aa_profile *get_task_activeptr_rcu(struct task_struct *tsk)
30
 
 {
31
 
-       struct aa_task_context *cxt = AA_TASK_CONTEXT(tsk->security);
32
 
+       struct aa_task_context *cxt = aa_task_context(tsk);
33
 
        struct aa_profile *active = NULL;
34
 
 
35
 
        if (cxt)
36
 
Index: b/security/apparmor/main.c
37
 
===================================================================
38
 
--- a/security/apparmor/main.c
39
 
+++ b/security/apparmor/main.c
40
 
@@ -646,7 +646,7 @@ int aa_capability(struct aa_profile *act
41
 
 {
42
 
        int error = cap_raised(active->capabilities, cap) ? 0 : -EPERM;
43
 
        struct aa_audit sa;
44
 
-       struct aa_task_context *cxt = AA_TASK_CONTEXT(current->security);
45
 
+       struct aa_task_context *cxt = aa_task_context(current);
46
 
 
47
 
        /* test if cap has alread been logged */
48
 
        if (cap_raised(cxt->caps_logged, cap)) {
49
 
@@ -732,7 +732,7 @@ int aa_link(struct aa_profile *active,
50
 
 
51
 
 int aa_fork(struct task_struct *p)
52
 
 {
53
 
-       struct aa_task_context *cxt = AA_TASK_CONTEXT(current->security);
54
 
+       struct aa_task_context *cxt = aa_task_context(current);
55
 
        struct aa_task_context *newcxt = NULL;
56
 
 
57
 
        AA_DEBUG("%s\n", __FUNCTION__);
58
 
@@ -962,7 +962,7 @@ apply_profile:
59
 
                 *   having to hold a lock around all this code.
60
 
                 */
61
 
 
62
 
-               if (!active && !(cxt = AA_TASK_CONTEXT(current->security))) {
63
 
+               if (!active && !(cxt = aa_task_context(current))) {
64
 
                        lazy_cxt = alloc_aa_task_context(current);
65
 
                        if (!lazy_cxt) {
66
 
                                AA_ERROR("%s: Failed to allocate aa_task_context\n",
67
 
@@ -974,7 +974,7 @@ apply_profile:
68
 
 
69
 
                spin_lock_irqsave(&cxt_lock, flags);
70
 
 
71
 
-               cxt = AA_TASK_CONTEXT(current->security);
72
 
+               cxt = aa_task_context(current);
73
 
                if (lazy_cxt) {
74
 
                        if (cxt) {
75
 
                                /* raced by setprofile - created cxt */
76
 
@@ -1061,7 +1061,7 @@ out:
77
 
  */
78
 
 void aa_release(struct task_struct *p)
79
 
 {
80
 
-       struct aa_task_context *cxt = AA_TASK_CONTEXT(p->security);
81
 
+       struct aa_task_context *cxt = aa_task_context(p);
82
 
        if (cxt) {
83
 
                p->security = NULL;
84
 
 
85
 
@@ -1141,7 +1141,7 @@ static inline int do_change_hat(const ch
86
 
  */
87
 
 int aa_change_hat(const char *hat_name, u32 hat_magic)
88
 
 {
89
 
-       struct aa_task_context *cxt = AA_TASK_CONTEXT(current->security);
90
 
+       struct aa_task_context *cxt = aa_task_context(current);
91
 
        int error = 0;
92
 
 
93
 
        AA_DEBUG("%s: %p, 0x%x (pid %d)\n",
94
 
Index: b/security/apparmor/procattr.c
95
 
===================================================================
96
 
--- a/security/apparmor/procattr.c
97
 
+++ b/security/apparmor/procattr.c
98
 
@@ -223,7 +223,7 @@ int aa_setprocattr_setprofile(struct tas
99
 
 
100
 
        spin_lock_irqsave(&cxt_lock, flags);
101
 
 
102
 
-       cxt = AA_TASK_CONTEXT(p->security);
103
 
+       cxt = aa_task_context(p);
104
 
 
105
 
        /* switch to unconstrained */
106
 
        if (!profile) {
107
 
@@ -268,11 +268,11 @@ int aa_setprocattr_setprofile(struct tas
108
 
                        }
109
 
 
110
 
                        spin_lock_irqsave(&cxt_lock, flags);
111
 
-                       if (!AA_TASK_CONTEXT(p->security)) {
112
 
+                       if (!aa_task_context(p)) {
113
 
                                p->security = cxt;
114
 
                        } else { /* race */
115
 
                                free_aa_task_context(cxt);
116
 
-                               cxt = AA_TASK_CONTEXT(p->security);
117
 
+                               cxt = aa_task_context(p);
118
 
                        }
119
 
                }
120