~ubuntu-branches/ubuntu/oneiric/apparmor/oneiric-security

« back to all changes in this revision

Viewing changes to kernel-patches/for-mainline/warn-info-messages.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
 
Index: b/security/apparmor/apparmor.h
2
 
===================================================================
3
 
--- a/security/apparmor/apparmor.h
4
 
+++ b/security/apparmor/apparmor.h
5
 
@@ -72,8 +72,14 @@ static inline int mediated_filesystem(st
6
 
                if (apparmor_debug)                                     \
7
 
                        printk(KERN_DEBUG "AppArmor: " fmt, ##args);    \
8
 
        } while (0)
9
 
-#define AA_INFO(fmt, args...)  printk(KERN_INFO "AppArmor: " fmt, ##args)
10
 
-#define AA_WARN(fmt, args...)  printk(KERN_WARNING "AppArmor: " fmt, ##args)
11
 
+#define AA_INFO(gfp, fmt, args...) \
12
 
+       do { \
13
 
+               printk(KERN_INFO "AppArmor: " fmt, ##args); \
14
 
+               aa_audit_message(NULL, gfp, 0, fmt, ##args); \
15
 
+       } while (0)
16
 
+#define AA_WARN(gfp, fmt, args...) \
17
 
+       aa_audit_message(NULL, gfp, 0, fmt, ##args);
18
 
+
19
 
 #define AA_ERROR(fmt, args...) printk(KERN_ERR "AppArmor: " fmt, ##args)
20
 
 
21
 
 /* basic AppArmor data structures */
22
 
Index: b/security/apparmor/apparmorfs.c
23
 
===================================================================
24
 
--- a/security/apparmor/apparmorfs.c
25
 
+++ b/security/apparmor/apparmorfs.c
26
 
@@ -166,7 +166,7 @@ static char *aa_simple_write_to_buffer(c
27
 
         */
28
 
        profile = aa_get_profile(current);
29
 
        if (profile) {
30
 
-               AA_WARN("REJECTING access to profile %s (%s(%d) "
31
 
+               AA_WARN(GFP_KERNEL, "REJECTING access to profile %s (%s(%d) "
32
 
                        "profile %s active %s)\n",
33
 
                        msg, current->comm, current->pid,
34
 
                        profile->parent->name, profile->name);
35
 
Index: b/security/apparmor/lsm.c
36
 
===================================================================
37
 
--- a/security/apparmor/lsm.c
38
 
+++ b/security/apparmor/lsm.c
39
 
@@ -628,7 +628,8 @@ static int apparmor_setprocattr(struct t
40
 
 
41
 
                /* Only the current process may change it's hat */
42
 
                if (current != task) {
43
 
-                       AA_WARN("%s: Attempt by foreign task %s(%d) "
44
 
+                       AA_WARN(GFP_KERNEL,
45
 
+                               "%s: Attempt by foreign task %s(%d) "
46
 
                                "[user %d] to changehat of task %s(%d)\n",
47
 
                                __FUNCTION__,
48
 
                                current->comm,
49
 
@@ -655,7 +656,8 @@ static int apparmor_setprocattr(struct t
50
 
                 */
51
 
 
52
 
                if (!capable(CAP_SYS_ADMIN)) {
53
 
-                       AA_WARN("%s: Unprivileged attempt by task %s(%d) "
54
 
+                       AA_WARN(GFP_KERNEL,
55
 
+                               "%s: Unprivileged attempt by task %s(%d) "
56
 
                                "[user %d] to assign profile to task %s(%d)\n",
57
 
                                __FUNCTION__,
58
 
                                current->comm,
59
 
@@ -679,7 +681,8 @@ static int apparmor_setprocattr(struct t
60
 
                                 */
61
 
                                error = size;
62
 
                } else {
63
 
-                       AA_WARN("%s: Attempt by confined task %s(%d) "
64
 
+                       AA_WARN(GFP_KERNEL,
65
 
+                               "%s: Attempt by confined task %s(%d) "
66
 
                                "[user %d] to assign profile to task %s(%d)\n",
67
 
                                __FUNCTION__,
68
 
                                current->comm,
69
 
@@ -693,8 +696,9 @@ static int apparmor_setprocattr(struct t
70
 
                aa_put_profile(profile);
71
 
        } else {
72
 
                /* unknown operation */
73
 
-               AA_WARN("%s: Unknown setprocattr command '%.*s' by task %s(%d) "
74
 
-                       "[user %d] for task %s(%d)\n",
75
 
+               AA_WARN(GFP_KERNEL,
76
 
+                       "%s: Unknown setprocattr command '%.*s' by task %s(%d)"
77
 
+                       " [user %d] for task %s(%d)\n",
78
 
                        __FUNCTION__,
79
 
                        size < 16 ? (int)size : 16,
80
 
                        cmd,
81
 
@@ -780,7 +784,7 @@ static int __init apparmor_init(void)
82
 
                goto register_security_out;
83
 
        }
84
 
 
85
 
-       AA_INFO("AppArmor initialized%s\n",
86
 
+       AA_INFO(GFP_KERNEL, "AppArmor initialized%s\n",
87
 
                apparmor_complain ? complainmsg : "");
88
 
        aa_audit_message(NULL, GFP_KERNEL, 0,
89
 
                "AppArmor initialized%s\n",
90
 
@@ -833,9 +837,10 @@ static void __exit apparmor_exit(void)
91
 
        destroy_apparmorfs();
92
 
 
93
 
        if (unregister_security(&apparmor_ops))
94
 
-               AA_WARN("Unable to properly unregister AppArmor\n");
95
 
+               AA_INFO(GFP_KERNEL, "Unable to properly unregister "
96
 
+                       "AppArmor\n");
97
 
 
98
 
-       AA_INFO("AppArmor protection removed\n");
99
 
+       AA_INFO(GFP_KERNEL, "AppArmor protection removed\n");
100
 
        aa_audit_message(NULL, GFP_KERNEL, 0,
101
 
                "AppArmor protection removed\n");
102
 
 }
103
 
Index: b/security/apparmor/main.c
104
 
===================================================================
105
 
--- a/security/apparmor/main.c
106
 
+++ b/security/apparmor/main.c
107
 
@@ -807,7 +807,7 @@ aa_register_find(struct aa_profile *prof
108
 
 
109
 
                        profile = aa_dup_profile(null_complain_profile);
110
 
                } else {
111
 
-                       AA_WARN("REJECTING exec(2) of image '%s'. "
112
 
+                       AA_WARN(GFP_KERNEL, "REJECTING exec(2) of image '%s'. "
113
 
                                "Profile mandatory and not found "
114
 
                                "(%s(%d) profile %s active %s)\n",
115
 
                                name,
116
 
@@ -844,7 +844,8 @@ int aa_register(struct linux_binprm *bpr
117
 
 
118
 
        filename = aa_get_name(filp->f_dentry, filp->f_vfsmnt, &buffer, 0);
119
 
        if (IS_ERR(filename)) {
120
 
-               AA_WARN("%s: Failed to get filename\n", __FUNCTION__);
121
 
+               AA_WARN(GFP_KERNEL, "%s: Failed to get filename\n",
122
 
+                       __FUNCTION__);
123
 
                return -ENOENT;
124
 
        }
125
 
 
126
 
@@ -907,7 +908,8 @@ repeat:
127
 
                        new_profile = aa_dup_profile(null_complain_profile);
128
 
                        exec_mode |= AA_EXEC_UNSAFE;
129
 
                } else {
130
 
-                       AA_WARN("%s: Rejecting exec(2) of image '%s'. "
131
 
+                       AA_WARN(GFP_KERNEL,
132
 
+                               "%s: Rejecting exec(2) of image '%s'. "
133
 
                                "Unable to determine exec qualifier "
134
 
                                "(%s (pid %d) profile %s active %s)\n",
135
 
                                __FUNCTION__,
136
 
@@ -1094,7 +1096,7 @@ int aa_change_hat(const char *hat_name, 
137
 
 
138
 
        /* Dump out above debugging in WARN mode if we are in AUDIT mode */
139
 
        if (APPARMOR_AUDIT(aa_task_context(current))) {
140
 
-               AA_WARN("%s: %s, 0x%llx (pid %d)\n",
141
 
+               AA_WARN(GFP_KERNEL, "%s: %s, 0x%llx (pid %d)\n",
142
 
                        __FUNCTION__, hat_name ? hat_name : "NULL",
143
 
                        hat_magic, current->pid);
144
 
        }
145
 
Index: b/security/apparmor/module_interface.c
146
 
===================================================================
147
 
--- a/security/apparmor/module_interface.c
148
 
+++ b/security/apparmor/module_interface.c
149
 
@@ -288,7 +288,7 @@ static struct aa_profile *aa_unpack_prof
150
 
        return profile;
151
 
 
152
 
 fail:
153
 
-       AA_WARN("Invalid profile %s\n",
154
 
+       AA_WARN(GFP_KERNEL, "Invalid profile %s\n",
155
 
                profile && profile->name ? profile->name : "unknown");
156
 
 
157
 
        if (profile)
158
 
@@ -329,13 +329,14 @@ static int aa_verify_header(struct aa_ex
159
 
 {
160
 
        /* get the interface version */
161
 
        if (!aa_is_u32(e, &e->version, "version")) {
162
 
-               AA_WARN("Interface version missing\n");
163
 
+               AA_WARN(GFP_KERNEL, "Interface version missing\n");
164
 
                return -EPROTONOSUPPORT;
165
 
        }
166
 
 
167
 
        /* check that the interface version is currently supported */
168
 
        if (e->version != 3) {
169
 
-               AA_WARN("Unsupported interface version (%d)\n", e->version);
170
 
+               AA_WARN(GFP_KERNEL,
171
 
+                       "Unsupported interface version (%d)\n", e->version);
172
 
                return -EPROTONOSUPPORT;
173
 
        }
174
 
        return 0;
175
 
Index: b/security/apparmor/procattr.c
176
 
===================================================================
177
 
--- a/security/apparmor/procattr.c
178
 
+++ b/security/apparmor/procattr.c
179
 
@@ -86,7 +86,8 @@ int aa_setprocattr_changehat(char *hatin
180
 
 
181
 
        magic = simple_strtoull(token, &hat, 16);
182
 
        if (hat == token || *hat != '^') {
183
 
-               AA_WARN("%s: Invalid input '%s'\n", __FUNCTION__, token);
184
 
+               AA_WARN(GFP_KERNEL, "%s: Invalid input '%s'\n",
185
 
+                       __FUNCTION__, token);
186
 
                goto out;
187
 
        }
188
 
 
189
 
@@ -97,7 +98,8 @@ int aa_setprocattr_changehat(char *hatin
190
 
                hat = NULL;
191
 
 
192
 
        if (!hat && !magic) {
193
 
-               AA_WARN("%s: Invalid input, NULL hat and NULL magic\n",
194
 
+               AA_WARN(GFP_KERNEL,
195
 
+                       "%s: Invalid input, NULL hat and NULL magic\n",
196
 
                        __FUNCTION__);
197
 
                goto out;
198
 
        }
199
 
@@ -145,7 +147,8 @@ repeat:
200
 
        if (strcmp(name_copy, "unconfined") != 0) {
201
 
                new_profile = aa_find_profile(name_copy);
202
 
                if (!new_profile) {
203
 
-                       AA_WARN("%s: Unable to switch task %s(%d) to profile"
204
 
+                       AA_WARN(GFP_KERNEL,
205
 
+                               "%s: Unable to switch task %s(%d) to profile"
206
 
                                "'%s'. No such profile.\n",
207
 
                                __FUNCTION__,
208
 
                                task->comm, task->pid,
209
 
@@ -167,7 +170,8 @@ repeat:
210
 
        }
211
 
 
212
 
        if (new_profile) {
213
 
-               AA_WARN("%s: Switching task %s(%d) "
214
 
+               AA_WARN(GFP_KERNEL,
215
 
+                       "%s: Switching task %s(%d) "
216
 
                        "profile %s active %s to new profile %s\n",
217
 
                        __FUNCTION__,
218
 
                        task->comm, task->pid,
219
 
@@ -177,14 +181,16 @@ repeat:
220
 
                        name_copy);
221
 
        } else {
222
 
                if (old_profile) {
223
 
-                       AA_WARN("%s: Unconfining task %s(%d) "
224
 
+                       AA_WARN(GFP_KERNEL,
225
 
+                               "%s: Unconfining task %s(%d) "
226
 
                                "profile %s active %s\n",
227
 
                                __FUNCTION__,
228
 
                                task->comm, task->pid,
229
 
                                old_profile->parent->name,
230
 
                                old_profile->name);
231
 
                } else {
232
 
-                       AA_WARN("%s: task %s(%d) "
233
 
+                       AA_WARN(GFP_KERNEL,
234
 
+                               "%s: task %s(%d) "
235
 
                                "is already unconfined\n",
236
 
                                __FUNCTION__, task->comm, task->pid);
237
 
                }