diff options
author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2010-06-14 20:22:42 -0400 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2010-08-02 01:34:28 -0400 |
commit | 82e0f001a4c1112dcff9cafa9812a33889ad9b8a (patch) | |
tree | 55c7e99f8773129b602f837f0c79f8d542021195 /security/tomoyo/domain.c | |
parent | 237ab459f12cb98eadd3fe7b85343e183a1076a4 (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/domain.c')
-rw-r--r-- | security/tomoyo/domain.c | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/security/tomoyo/domain.c b/security/tomoyo/domain.c index f774e73e0022..60297da6adcf 100644 --- a/security/tomoyo/domain.c +++ b/security/tomoyo/domain.c | |||
@@ -199,10 +199,11 @@ static int tomoyo_update_domain_initializer_entry(const char *domainname, | |||
199 | goto out; | 199 | goto out; |
200 | if (mutex_lock_interruptible(&tomoyo_policy_lock)) | 200 | if (mutex_lock_interruptible(&tomoyo_policy_lock)) |
201 | goto out; | 201 | goto out; |
202 | list_for_each_entry_rcu(ptr, &tomoyo_domain_initializer_list, list) { | 202 | list_for_each_entry_rcu(ptr, &tomoyo_domain_initializer_list, |
203 | head.list) { | ||
203 | if (!tomoyo_is_same_domain_initializer_entry(ptr, &e)) | 204 | if (!tomoyo_is_same_domain_initializer_entry(ptr, &e)) |
204 | continue; | 205 | continue; |
205 | ptr->is_deleted = is_delete; | 206 | ptr->head.is_deleted = is_delete; |
206 | error = 0; | 207 | error = 0; |
207 | break; | 208 | break; |
208 | } | 209 | } |
@@ -210,7 +211,7 @@ static int tomoyo_update_domain_initializer_entry(const char *domainname, | |||
210 | struct tomoyo_domain_initializer_entry *entry = | 211 | struct tomoyo_domain_initializer_entry *entry = |
211 | tomoyo_commit_ok(&e, sizeof(e)); | 212 | tomoyo_commit_ok(&e, sizeof(e)); |
212 | if (entry) { | 213 | if (entry) { |
213 | list_add_tail_rcu(&entry->list, | 214 | list_add_tail_rcu(&entry->head.list, |
214 | &tomoyo_domain_initializer_list); | 215 | &tomoyo_domain_initializer_list); |
215 | error = 0; | 216 | error = 0; |
216 | } | 217 | } |
@@ -243,8 +244,8 @@ bool tomoyo_read_domain_initializer_policy(struct tomoyo_io_buffer *head) | |||
243 | const char *domain = ""; | 244 | const char *domain = ""; |
244 | struct tomoyo_domain_initializer_entry *ptr; | 245 | struct tomoyo_domain_initializer_entry *ptr; |
245 | ptr = list_entry(pos, struct tomoyo_domain_initializer_entry, | 246 | ptr = list_entry(pos, struct tomoyo_domain_initializer_entry, |
246 | list); | 247 | head.list); |
247 | if (ptr->is_deleted) | 248 | if (ptr->head.is_deleted) |
248 | continue; | 249 | continue; |
249 | no = ptr->is_not ? "no_" : ""; | 250 | no = ptr->is_not ? "no_" : ""; |
250 | if (ptr->domainname) { | 251 | if (ptr->domainname) { |
@@ -308,8 +309,9 @@ static bool tomoyo_is_domain_initializer(const struct tomoyo_path_info * | |||
308 | struct tomoyo_domain_initializer_entry *ptr; | 309 | struct tomoyo_domain_initializer_entry *ptr; |
309 | bool flag = false; | 310 | bool flag = false; |
310 | 311 | ||
311 | list_for_each_entry_rcu(ptr, &tomoyo_domain_initializer_list, list) { | 312 | list_for_each_entry_rcu(ptr, &tomoyo_domain_initializer_list, |
312 | if (ptr->is_deleted) | 313 | head.list) { |
314 | if (ptr->head.is_deleted) | ||
313 | continue; | 315 | continue; |
314 | if (ptr->domainname) { | 316 | if (ptr->domainname) { |
315 | if (!ptr->is_last_name) { | 317 | if (!ptr->is_last_name) { |
@@ -409,10 +411,10 @@ static int tomoyo_update_domain_keeper_entry(const char *domainname, | |||
409 | goto out; | 411 | goto out; |
410 | if (mutex_lock_interruptible(&tomoyo_policy_lock)) | 412 | if (mutex_lock_interruptible(&tomoyo_policy_lock)) |
411 | goto out; | 413 | goto out; |
412 | list_for_each_entry_rcu(ptr, &tomoyo_domain_keeper_list, list) { | 414 | list_for_each_entry_rcu(ptr, &tomoyo_domain_keeper_list, head.list) { |
413 | if (!tomoyo_is_same_domain_keeper_entry(ptr, &e)) | 415 | if (!tomoyo_is_same_domain_keeper_entry(ptr, &e)) |
414 | continue; | 416 | continue; |
415 | ptr->is_deleted = is_delete; | 417 | ptr->head.is_deleted = is_delete; |
416 | error = 0; | 418 | error = 0; |
417 | break; | 419 | break; |
418 | } | 420 | } |
@@ -420,7 +422,7 @@ static int tomoyo_update_domain_keeper_entry(const char *domainname, | |||
420 | struct tomoyo_domain_keeper_entry *entry = | 422 | struct tomoyo_domain_keeper_entry *entry = |
421 | tomoyo_commit_ok(&e, sizeof(e)); | 423 | tomoyo_commit_ok(&e, sizeof(e)); |
422 | if (entry) { | 424 | if (entry) { |
423 | list_add_tail_rcu(&entry->list, | 425 | list_add_tail_rcu(&entry->head.list, |
424 | &tomoyo_domain_keeper_list); | 426 | &tomoyo_domain_keeper_list); |
425 | error = 0; | 427 | error = 0; |
426 | } | 428 | } |
@@ -475,8 +477,9 @@ bool tomoyo_read_domain_keeper_policy(struct tomoyo_io_buffer *head) | |||
475 | const char *from = ""; | 477 | const char *from = ""; |
476 | const char *program = ""; | 478 | const char *program = ""; |
477 | 479 | ||
478 | ptr = list_entry(pos, struct tomoyo_domain_keeper_entry, list); | 480 | ptr = list_entry(pos, struct tomoyo_domain_keeper_entry, |
479 | if (ptr->is_deleted) | 481 | head.list); |
482 | if (ptr->head.is_deleted) | ||
480 | continue; | 483 | continue; |
481 | no = ptr->is_not ? "no_" : ""; | 484 | no = ptr->is_not ? "no_" : ""; |
482 | if (ptr->program) { | 485 | if (ptr->program) { |
@@ -512,8 +515,8 @@ static bool tomoyo_is_domain_keeper(const struct tomoyo_path_info *domainname, | |||
512 | struct tomoyo_domain_keeper_entry *ptr; | 515 | struct tomoyo_domain_keeper_entry *ptr; |
513 | bool flag = false; | 516 | bool flag = false; |
514 | 517 | ||
515 | list_for_each_entry_rcu(ptr, &tomoyo_domain_keeper_list, list) { | 518 | list_for_each_entry_rcu(ptr, &tomoyo_domain_keeper_list, head.list) { |
516 | if (ptr->is_deleted) | 519 | if (ptr->head.is_deleted) |
517 | continue; | 520 | continue; |
518 | if (!ptr->is_last_name) { | 521 | if (!ptr->is_last_name) { |
519 | if (ptr->domainname != domainname) | 522 | if (ptr->domainname != domainname) |
@@ -591,10 +594,10 @@ static int tomoyo_update_aggregator_entry(const char *original_name, | |||
591 | goto out; | 594 | goto out; |
592 | if (mutex_lock_interruptible(&tomoyo_policy_lock)) | 595 | if (mutex_lock_interruptible(&tomoyo_policy_lock)) |
593 | goto out; | 596 | goto out; |
594 | list_for_each_entry_rcu(ptr, &tomoyo_aggregator_list, list) { | 597 | list_for_each_entry_rcu(ptr, &tomoyo_aggregator_list, head.list) { |
595 | if (!tomoyo_is_same_aggregator_entry(ptr, &e)) | 598 | if (!tomoyo_is_same_aggregator_entry(ptr, &e)) |
596 | continue; | 599 | continue; |
597 | ptr->is_deleted = is_delete; | 600 | ptr->head.is_deleted = is_delete; |
598 | error = 0; | 601 | error = 0; |
599 | break; | 602 | break; |
600 | } | 603 | } |
@@ -602,7 +605,7 @@ static int tomoyo_update_aggregator_entry(const char *original_name, | |||
602 | struct tomoyo_aggregator_entry *entry = | 605 | struct tomoyo_aggregator_entry *entry = |
603 | tomoyo_commit_ok(&e, sizeof(e)); | 606 | tomoyo_commit_ok(&e, sizeof(e)); |
604 | if (entry) { | 607 | if (entry) { |
605 | list_add_tail_rcu(&entry->list, | 608 | list_add_tail_rcu(&entry->head.list, |
606 | &tomoyo_aggregator_list); | 609 | &tomoyo_aggregator_list); |
607 | error = 0; | 610 | error = 0; |
608 | } | 611 | } |
@@ -631,8 +634,9 @@ bool tomoyo_read_aggregator_policy(struct tomoyo_io_buffer *head) | |||
631 | list_for_each_cookie(pos, head->read_var2, &tomoyo_aggregator_list) { | 634 | list_for_each_cookie(pos, head->read_var2, &tomoyo_aggregator_list) { |
632 | struct tomoyo_aggregator_entry *ptr; | 635 | struct tomoyo_aggregator_entry *ptr; |
633 | 636 | ||
634 | ptr = list_entry(pos, struct tomoyo_aggregator_entry, list); | 637 | ptr = list_entry(pos, struct tomoyo_aggregator_entry, |
635 | if (ptr->is_deleted) | 638 | head.list); |
639 | if (ptr->head.is_deleted) | ||
636 | continue; | 640 | continue; |
637 | done = tomoyo_io_printf(head, TOMOYO_KEYWORD_AGGREGATOR | 641 | done = tomoyo_io_printf(head, TOMOYO_KEYWORD_AGGREGATOR |
638 | "%s %s\n", ptr->original_name->name, | 642 | "%s %s\n", ptr->original_name->name, |
@@ -724,10 +728,10 @@ static int tomoyo_update_alias_entry(const char *original_name, | |||
724 | goto out; /* No patterns allowed. */ | 728 | goto out; /* No patterns allowed. */ |
725 | if (mutex_lock_interruptible(&tomoyo_policy_lock)) | 729 | if (mutex_lock_interruptible(&tomoyo_policy_lock)) |
726 | goto out; | 730 | goto out; |
727 | list_for_each_entry_rcu(ptr, &tomoyo_alias_list, list) { | 731 | list_for_each_entry_rcu(ptr, &tomoyo_alias_list, head.list) { |
728 | if (!tomoyo_is_same_alias_entry(ptr, &e)) | 732 | if (!tomoyo_is_same_alias_entry(ptr, &e)) |
729 | continue; | 733 | continue; |
730 | ptr->is_deleted = is_delete; | 734 | ptr->head.is_deleted = is_delete; |
731 | error = 0; | 735 | error = 0; |
732 | break; | 736 | break; |
733 | } | 737 | } |
@@ -735,7 +739,8 @@ static int tomoyo_update_alias_entry(const char *original_name, | |||
735 | struct tomoyo_alias_entry *entry = | 739 | struct tomoyo_alias_entry *entry = |
736 | tomoyo_commit_ok(&e, sizeof(e)); | 740 | tomoyo_commit_ok(&e, sizeof(e)); |
737 | if (entry) { | 741 | if (entry) { |
738 | list_add_tail_rcu(&entry->list, &tomoyo_alias_list); | 742 | list_add_tail_rcu(&entry->head.list, |
743 | &tomoyo_alias_list); | ||
739 | error = 0; | 744 | error = 0; |
740 | } | 745 | } |
741 | } | 746 | } |
@@ -763,8 +768,8 @@ bool tomoyo_read_alias_policy(struct tomoyo_io_buffer *head) | |||
763 | list_for_each_cookie(pos, head->read_var2, &tomoyo_alias_list) { | 768 | list_for_each_cookie(pos, head->read_var2, &tomoyo_alias_list) { |
764 | struct tomoyo_alias_entry *ptr; | 769 | struct tomoyo_alias_entry *ptr; |
765 | 770 | ||
766 | ptr = list_entry(pos, struct tomoyo_alias_entry, list); | 771 | ptr = list_entry(pos, struct tomoyo_alias_entry, head.list); |
767 | if (ptr->is_deleted) | 772 | if (ptr->head.is_deleted) |
768 | continue; | 773 | continue; |
769 | done = tomoyo_io_printf(head, TOMOYO_KEYWORD_ALIAS "%s %s\n", | 774 | done = tomoyo_io_printf(head, TOMOYO_KEYWORD_ALIAS "%s %s\n", |
770 | ptr->original_name->name, | 775 | ptr->original_name->name, |
@@ -901,8 +906,8 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm) | |||
901 | if (tomoyo_pathcmp(&rn, &sn)) { | 906 | if (tomoyo_pathcmp(&rn, &sn)) { |
902 | struct tomoyo_alias_entry *ptr; | 907 | struct tomoyo_alias_entry *ptr; |
903 | /* Is this program allowed to be called via symbolic links? */ | 908 | /* Is this program allowed to be called via symbolic links? */ |
904 | list_for_each_entry_rcu(ptr, &tomoyo_alias_list, list) { | 909 | list_for_each_entry_rcu(ptr, &tomoyo_alias_list, head.list) { |
905 | if (ptr->is_deleted || | 910 | if (ptr->head.is_deleted || |
906 | tomoyo_pathcmp(&rn, ptr->original_name) || | 911 | tomoyo_pathcmp(&rn, ptr->original_name) || |
907 | tomoyo_pathcmp(&sn, ptr->aliased_name)) | 912 | tomoyo_pathcmp(&sn, ptr->aliased_name)) |
908 | continue; | 913 | continue; |
@@ -917,8 +922,9 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm) | |||
917 | /* Check 'aggregator' directive. */ | 922 | /* Check 'aggregator' directive. */ |
918 | { | 923 | { |
919 | struct tomoyo_aggregator_entry *ptr; | 924 | struct tomoyo_aggregator_entry *ptr; |
920 | list_for_each_entry_rcu(ptr, &tomoyo_aggregator_list, list) { | 925 | list_for_each_entry_rcu(ptr, &tomoyo_aggregator_list, |
921 | if (ptr->is_deleted || | 926 | head.list) { |
927 | if (ptr->head.is_deleted || | ||
922 | !tomoyo_path_matches_pattern(&rn, | 928 | !tomoyo_path_matches_pattern(&rn, |
923 | ptr->original_name)) | 929 | ptr->original_name)) |
924 | continue; | 930 | continue; |