diff options
Diffstat (limited to 'net/netlabel/netlabel_domainhash.c')
-rw-r--r-- | net/netlabel/netlabel_domainhash.c | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c index f56d7a8ac7b7..d64e2ae3b129 100644 --- a/net/netlabel/netlabel_domainhash.c +++ b/net/netlabel/netlabel_domainhash.c | |||
@@ -35,12 +35,14 @@ | |||
35 | #include <linux/skbuff.h> | 35 | #include <linux/skbuff.h> |
36 | #include <linux/spinlock.h> | 36 | #include <linux/spinlock.h> |
37 | #include <linux/string.h> | 37 | #include <linux/string.h> |
38 | #include <linux/audit.h> | ||
38 | #include <net/netlabel.h> | 39 | #include <net/netlabel.h> |
39 | #include <net/cipso_ipv4.h> | 40 | #include <net/cipso_ipv4.h> |
40 | #include <asm/bug.h> | 41 | #include <asm/bug.h> |
41 | 42 | ||
42 | #include "netlabel_mgmt.h" | 43 | #include "netlabel_mgmt.h" |
43 | #include "netlabel_domainhash.h" | 44 | #include "netlabel_domainhash.h" |
45 | #include "netlabel_user.h" | ||
44 | 46 | ||
45 | struct netlbl_domhsh_tbl { | 47 | struct netlbl_domhsh_tbl { |
46 | struct list_head *tbl; | 48 | struct list_head *tbl; |
@@ -186,6 +188,7 @@ int netlbl_domhsh_init(u32 size) | |||
186 | /** | 188 | /** |
187 | * netlbl_domhsh_add - Adds a entry to the domain hash table | 189 | * netlbl_domhsh_add - Adds a entry to the domain hash table |
188 | * @entry: the entry to add | 190 | * @entry: the entry to add |
191 | * @audit_secid: the LSM secid to use in the audit message | ||
189 | * | 192 | * |
190 | * Description: | 193 | * Description: |
191 | * Adds a new entry to the domain hash table and handles any updates to the | 194 | * Adds a new entry to the domain hash table and handles any updates to the |
@@ -193,10 +196,12 @@ int netlbl_domhsh_init(u32 size) | |||
193 | * negative on failure. | 196 | * negative on failure. |
194 | * | 197 | * |
195 | */ | 198 | */ |
196 | int netlbl_domhsh_add(struct netlbl_dom_map *entry) | 199 | int netlbl_domhsh_add(struct netlbl_dom_map *entry, u32 audit_secid) |
197 | { | 200 | { |
198 | int ret_val; | 201 | int ret_val; |
199 | u32 bkt; | 202 | u32 bkt; |
203 | struct audit_buffer *audit_buf; | ||
204 | char *audit_domain; | ||
200 | 205 | ||
201 | switch (entry->type) { | 206 | switch (entry->type) { |
202 | case NETLBL_NLTYPE_UNLABELED: | 207 | case NETLBL_NLTYPE_UNLABELED: |
@@ -236,6 +241,26 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry) | |||
236 | spin_unlock(&netlbl_domhsh_def_lock); | 241 | spin_unlock(&netlbl_domhsh_def_lock); |
237 | } else | 242 | } else |
238 | ret_val = -EINVAL; | 243 | ret_val = -EINVAL; |
244 | if (ret_val == 0) { | ||
245 | if (entry->domain != NULL) | ||
246 | audit_domain = entry->domain; | ||
247 | else | ||
248 | audit_domain = "(default)"; | ||
249 | audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_ADD, | ||
250 | audit_secid); | ||
251 | audit_log_format(audit_buf, " domain=%s", audit_domain); | ||
252 | switch (entry->type) { | ||
253 | case NETLBL_NLTYPE_UNLABELED: | ||
254 | audit_log_format(audit_buf, " protocol=unlbl"); | ||
255 | break; | ||
256 | case NETLBL_NLTYPE_CIPSOV4: | ||
257 | audit_log_format(audit_buf, | ||
258 | " protocol=cipsov4 doi=%u", | ||
259 | entry->type_def.cipsov4->doi); | ||
260 | break; | ||
261 | } | ||
262 | audit_log_end(audit_buf); | ||
263 | } | ||
239 | rcu_read_unlock(); | 264 | rcu_read_unlock(); |
240 | 265 | ||
241 | if (ret_val != 0) { | 266 | if (ret_val != 0) { |
@@ -254,6 +279,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry) | |||
254 | /** | 279 | /** |
255 | * netlbl_domhsh_add_default - Adds the default entry to the domain hash table | 280 | * netlbl_domhsh_add_default - Adds the default entry to the domain hash table |
256 | * @entry: the entry to add | 281 | * @entry: the entry to add |
282 | * @audit_secid: the LSM secid to use in the audit message | ||
257 | * | 283 | * |
258 | * Description: | 284 | * Description: |
259 | * Adds a new default entry to the domain hash table and handles any updates | 285 | * Adds a new default entry to the domain hash table and handles any updates |
@@ -261,14 +287,15 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry) | |||
261 | * negative on failure. | 287 | * negative on failure. |
262 | * | 288 | * |
263 | */ | 289 | */ |
264 | int netlbl_domhsh_add_default(struct netlbl_dom_map *entry) | 290 | int netlbl_domhsh_add_default(struct netlbl_dom_map *entry, u32 audit_secid) |
265 | { | 291 | { |
266 | return netlbl_domhsh_add(entry); | 292 | return netlbl_domhsh_add(entry, audit_secid); |
267 | } | 293 | } |
268 | 294 | ||
269 | /** | 295 | /** |
270 | * netlbl_domhsh_remove - Removes an entry from the domain hash table | 296 | * netlbl_domhsh_remove - Removes an entry from the domain hash table |
271 | * @domain: the domain to remove | 297 | * @domain: the domain to remove |
298 | * @audit_secid: the LSM secid to use in the audit message | ||
272 | * | 299 | * |
273 | * Description: | 300 | * Description: |
274 | * Removes an entry from the domain hash table and handles any updates to the | 301 | * Removes an entry from the domain hash table and handles any updates to the |
@@ -276,10 +303,12 @@ int netlbl_domhsh_add_default(struct netlbl_dom_map *entry) | |||
276 | * negative on failure. | 303 | * negative on failure. |
277 | * | 304 | * |
278 | */ | 305 | */ |
279 | int netlbl_domhsh_remove(const char *domain) | 306 | int netlbl_domhsh_remove(const char *domain, u32 audit_secid) |
280 | { | 307 | { |
281 | int ret_val = -ENOENT; | 308 | int ret_val = -ENOENT; |
282 | struct netlbl_dom_map *entry; | 309 | struct netlbl_dom_map *entry; |
310 | struct audit_buffer *audit_buf; | ||
311 | char *audit_domain; | ||
283 | 312 | ||
284 | rcu_read_lock(); | 313 | rcu_read_lock(); |
285 | if (domain != NULL) | 314 | if (domain != NULL) |
@@ -316,8 +345,18 @@ int netlbl_domhsh_remove(const char *domain) | |||
316 | ret_val = -ENOENT; | 345 | ret_val = -ENOENT; |
317 | spin_unlock(&netlbl_domhsh_def_lock); | 346 | spin_unlock(&netlbl_domhsh_def_lock); |
318 | } | 347 | } |
319 | if (ret_val == 0) | 348 | if (ret_val == 0) { |
349 | if (entry->domain != NULL) | ||
350 | audit_domain = entry->domain; | ||
351 | else | ||
352 | audit_domain = "(default)"; | ||
353 | audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_DEL, | ||
354 | audit_secid); | ||
355 | audit_log_format(audit_buf, " domain=%s", audit_domain); | ||
356 | audit_log_end(audit_buf); | ||
357 | |||
320 | call_rcu(&entry->rcu, netlbl_domhsh_free_entry); | 358 | call_rcu(&entry->rcu, netlbl_domhsh_free_entry); |
359 | } | ||
321 | 360 | ||
322 | remove_return: | 361 | remove_return: |
323 | rcu_read_unlock(); | 362 | rcu_read_unlock(); |
@@ -326,6 +365,7 @@ remove_return: | |||
326 | 365 | ||
327 | /** | 366 | /** |
328 | * netlbl_domhsh_remove_default - Removes the default entry from the table | 367 | * netlbl_domhsh_remove_default - Removes the default entry from the table |
368 | * @audit_secid: the LSM secid to use in the audit message | ||
329 | * | 369 | * |
330 | * Description: | 370 | * Description: |
331 | * Removes/resets the default entry for the domain hash table and handles any | 371 | * Removes/resets the default entry for the domain hash table and handles any |
@@ -333,9 +373,9 @@ remove_return: | |||
333 | * success, non-zero on failure. | 373 | * success, non-zero on failure. |
334 | * | 374 | * |
335 | */ | 375 | */ |
336 | int netlbl_domhsh_remove_default(void) | 376 | int netlbl_domhsh_remove_default(u32 audit_secid) |
337 | { | 377 | { |
338 | return netlbl_domhsh_remove(NULL); | 378 | return netlbl_domhsh_remove(NULL, audit_secid); |
339 | } | 379 | } |
340 | 380 | ||
341 | /** | 381 | /** |