aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/file.c
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2010-06-14 20:22:42 -0400
committerJames Morris <jmorris@namei.org>2010-08-02 01:34:28 -0400
commit82e0f001a4c1112dcff9cafa9812a33889ad9b8a (patch)
tree55c7e99f8773129b602f837f0c79f8d542021195 /security/tomoyo/file.c
parent237ab459f12cb98eadd3fe7b85343e183a1076a4 (diff)
TOMOYO: Use common structure for list element.
Use common "struct list_head" + "bool" structure. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/tomoyo/file.c')
-rw-r--r--security/tomoyo/file.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/security/tomoyo/file.c b/security/tomoyo/file.c
index b826058c72e9..09436d11f298 100644
--- a/security/tomoyo/file.c
+++ b/security/tomoyo/file.c
@@ -277,10 +277,11 @@ static int tomoyo_update_globally_readable_entry(const char *filename,
277 return -ENOMEM; 277 return -ENOMEM;
278 if (mutex_lock_interruptible(&tomoyo_policy_lock)) 278 if (mutex_lock_interruptible(&tomoyo_policy_lock))
279 goto out; 279 goto out;
280 list_for_each_entry_rcu(ptr, &tomoyo_globally_readable_list, list) { 280 list_for_each_entry_rcu(ptr, &tomoyo_globally_readable_list,
281 head.list) {
281 if (ptr->filename != e.filename) 282 if (ptr->filename != e.filename)
282 continue; 283 continue;
283 ptr->is_deleted = is_delete; 284 ptr->head.is_deleted = is_delete;
284 error = 0; 285 error = 0;
285 break; 286 break;
286 } 287 }
@@ -288,7 +289,7 @@ static int tomoyo_update_globally_readable_entry(const char *filename,
288 struct tomoyo_globally_readable_file_entry *entry = 289 struct tomoyo_globally_readable_file_entry *entry =
289 tomoyo_commit_ok(&e, sizeof(e)); 290 tomoyo_commit_ok(&e, sizeof(e));
290 if (entry) { 291 if (entry) {
291 list_add_tail_rcu(&entry->list, 292 list_add_tail_rcu(&entry->head.list,
292 &tomoyo_globally_readable_list); 293 &tomoyo_globally_readable_list);
293 error = 0; 294 error = 0;
294 } 295 }
@@ -314,8 +315,9 @@ static bool tomoyo_is_globally_readable_file(const struct tomoyo_path_info *
314 struct tomoyo_globally_readable_file_entry *ptr; 315 struct tomoyo_globally_readable_file_entry *ptr;
315 bool found = false; 316 bool found = false;
316 317
317 list_for_each_entry_rcu(ptr, &tomoyo_globally_readable_list, list) { 318 list_for_each_entry_rcu(ptr, &tomoyo_globally_readable_list,
318 if (!ptr->is_deleted && 319 head.list) {
320 if (!ptr->head.is_deleted &&
319 tomoyo_path_matches_pattern(filename, ptr->filename)) { 321 tomoyo_path_matches_pattern(filename, ptr->filename)) {
320 found = true; 322 found = true;
321 break; 323 break;
@@ -358,8 +360,8 @@ bool tomoyo_read_globally_readable_policy(struct tomoyo_io_buffer *head)
358 struct tomoyo_globally_readable_file_entry *ptr; 360 struct tomoyo_globally_readable_file_entry *ptr;
359 ptr = list_entry(pos, 361 ptr = list_entry(pos,
360 struct tomoyo_globally_readable_file_entry, 362 struct tomoyo_globally_readable_file_entry,
361 list); 363 head.list);
362 if (ptr->is_deleted) 364 if (ptr->head.is_deleted)
363 continue; 365 continue;
364 done = tomoyo_io_printf(head, TOMOYO_KEYWORD_ALLOW_READ "%s\n", 366 done = tomoyo_io_printf(head, TOMOYO_KEYWORD_ALLOW_READ "%s\n",
365 ptr->filename->name); 367 ptr->filename->name);
@@ -424,10 +426,10 @@ static int tomoyo_update_file_pattern_entry(const char *pattern,
424 return error; 426 return error;
425 if (mutex_lock_interruptible(&tomoyo_policy_lock)) 427 if (mutex_lock_interruptible(&tomoyo_policy_lock))
426 goto out; 428 goto out;
427 list_for_each_entry_rcu(ptr, &tomoyo_pattern_list, list) { 429 list_for_each_entry_rcu(ptr, &tomoyo_pattern_list, head.list) {
428 if (e.pattern != ptr->pattern) 430 if (e.pattern != ptr->pattern)
429 continue; 431 continue;
430 ptr->is_deleted = is_delete; 432 ptr->head.is_deleted = is_delete;
431 error = 0; 433 error = 0;
432 break; 434 break;
433 } 435 }
@@ -435,7 +437,8 @@ static int tomoyo_update_file_pattern_entry(const char *pattern,
435 struct tomoyo_pattern_entry *entry = 437 struct tomoyo_pattern_entry *entry =
436 tomoyo_commit_ok(&e, sizeof(e)); 438 tomoyo_commit_ok(&e, sizeof(e));
437 if (entry) { 439 if (entry) {
438 list_add_tail_rcu(&entry->list, &tomoyo_pattern_list); 440 list_add_tail_rcu(&entry->head.list,
441 &tomoyo_pattern_list);
439 error = 0; 442 error = 0;
440 } 443 }
441 } 444 }
@@ -459,8 +462,8 @@ const char *tomoyo_file_pattern(const struct tomoyo_path_info *filename)
459 struct tomoyo_pattern_entry *ptr; 462 struct tomoyo_pattern_entry *ptr;
460 const struct tomoyo_path_info *pattern = NULL; 463 const struct tomoyo_path_info *pattern = NULL;
461 464
462 list_for_each_entry_rcu(ptr, &tomoyo_pattern_list, list) { 465 list_for_each_entry_rcu(ptr, &tomoyo_pattern_list, head.list) {
463 if (ptr->is_deleted) 466 if (ptr->head.is_deleted)
464 continue; 467 continue;
465 if (!tomoyo_path_matches_pattern(filename, ptr->pattern)) 468 if (!tomoyo_path_matches_pattern(filename, ptr->pattern))
466 continue; 469 continue;
@@ -508,8 +511,8 @@ bool tomoyo_read_file_pattern(struct tomoyo_io_buffer *head)
508 511
509 list_for_each_cookie(pos, head->read_var2, &tomoyo_pattern_list) { 512 list_for_each_cookie(pos, head->read_var2, &tomoyo_pattern_list) {
510 struct tomoyo_pattern_entry *ptr; 513 struct tomoyo_pattern_entry *ptr;
511 ptr = list_entry(pos, struct tomoyo_pattern_entry, list); 514 ptr = list_entry(pos, struct tomoyo_pattern_entry, head.list);
512 if (ptr->is_deleted) 515 if (ptr->head.is_deleted)
513 continue; 516 continue;
514 done = tomoyo_io_printf(head, TOMOYO_KEYWORD_FILE_PATTERN 517 done = tomoyo_io_printf(head, TOMOYO_KEYWORD_FILE_PATTERN
515 "%s\n", ptr->pattern->name); 518 "%s\n", ptr->pattern->name);
@@ -574,10 +577,10 @@ static int tomoyo_update_no_rewrite_entry(const char *pattern,
574 return error; 577 return error;
575 if (mutex_lock_interruptible(&tomoyo_policy_lock)) 578 if (mutex_lock_interruptible(&tomoyo_policy_lock))
576 goto out; 579 goto out;
577 list_for_each_entry_rcu(ptr, &tomoyo_no_rewrite_list, list) { 580 list_for_each_entry_rcu(ptr, &tomoyo_no_rewrite_list, head.list) {
578 if (ptr->pattern != e.pattern) 581 if (ptr->pattern != e.pattern)
579 continue; 582 continue;
580 ptr->is_deleted = is_delete; 583 ptr->head.is_deleted = is_delete;
581 error = 0; 584 error = 0;
582 break; 585 break;
583 } 586 }
@@ -585,7 +588,7 @@ static int tomoyo_update_no_rewrite_entry(const char *pattern,
585 struct tomoyo_no_rewrite_entry *entry = 588 struct tomoyo_no_rewrite_entry *entry =
586 tomoyo_commit_ok(&e, sizeof(e)); 589 tomoyo_commit_ok(&e, sizeof(e));
587 if (entry) { 590 if (entry) {
588 list_add_tail_rcu(&entry->list, 591 list_add_tail_rcu(&entry->head.list,
589 &tomoyo_no_rewrite_list); 592 &tomoyo_no_rewrite_list);
590 error = 0; 593 error = 0;
591 } 594 }
@@ -611,8 +614,8 @@ static bool tomoyo_is_no_rewrite_file(const struct tomoyo_path_info *filename)
611 struct tomoyo_no_rewrite_entry *ptr; 614 struct tomoyo_no_rewrite_entry *ptr;
612 bool found = false; 615 bool found = false;
613 616
614 list_for_each_entry_rcu(ptr, &tomoyo_no_rewrite_list, list) { 617 list_for_each_entry_rcu(ptr, &tomoyo_no_rewrite_list, head.list) {
615 if (ptr->is_deleted) 618 if (ptr->head.is_deleted)
616 continue; 619 continue;
617 if (!tomoyo_path_matches_pattern(filename, ptr->pattern)) 620 if (!tomoyo_path_matches_pattern(filename, ptr->pattern))
618 continue; 621 continue;
@@ -653,8 +656,9 @@ bool tomoyo_read_no_rewrite_policy(struct tomoyo_io_buffer *head)
653 656
654 list_for_each_cookie(pos, head->read_var2, &tomoyo_no_rewrite_list) { 657 list_for_each_cookie(pos, head->read_var2, &tomoyo_no_rewrite_list) {
655 struct tomoyo_no_rewrite_entry *ptr; 658 struct tomoyo_no_rewrite_entry *ptr;
656 ptr = list_entry(pos, struct tomoyo_no_rewrite_entry, list); 659 ptr = list_entry(pos, struct tomoyo_no_rewrite_entry,
657 if (ptr->is_deleted) 660 head.list);
661 if (ptr->head.is_deleted)
658 continue; 662 continue;
659 done = tomoyo_io_printf(head, TOMOYO_KEYWORD_DENY_REWRITE 663 done = tomoyo_io_printf(head, TOMOYO_KEYWORD_DENY_REWRITE
660 "%s\n", ptr->pattern->name); 664 "%s\n", ptr->pattern->name);