aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/file.c
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2010-02-02 16:43:06 -0500
committerJames Morris <jmorris@namei.org>2010-02-07 22:10:20 -0500
commitea13ddbad0eb4be9cdc406cd7e0804fa4011f6e4 (patch)
tree4068bb5baad6f6819242b36a00bf395a6db7f1e1 /security/tomoyo/file.c
parentf40a70861ace69001524644473cc389543b06c3c (diff)
TOMOYO: Extract bitfield
Since list elements are rounded up to kmalloc() size rather than sizeof(int), saving one byte by using bitfields is no longer helpful. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Acked-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/tomoyo/file.c')
-rw-r--r--security/tomoyo/file.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/security/tomoyo/file.c b/security/tomoyo/file.c
index 24af081f1af9..84c821a245ca 100644
--- a/security/tomoyo/file.c
+++ b/security/tomoyo/file.c
@@ -688,7 +688,7 @@ static int tomoyo_check_single_path_acl2(const struct tomoyo_domain_info *
688 688
689 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) { 689 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) {
690 struct tomoyo_single_path_acl_record *acl; 690 struct tomoyo_single_path_acl_record *acl;
691 if (tomoyo_acl_type2(ptr) != TOMOYO_TYPE_SINGLE_PATH_ACL) 691 if (ptr->type != TOMOYO_TYPE_SINGLE_PATH_ACL)
692 continue; 692 continue;
693 acl = container_of(ptr, struct tomoyo_single_path_acl_record, 693 acl = container_of(ptr, struct tomoyo_single_path_acl_record,
694 head); 694 head);
@@ -770,8 +770,7 @@ static int tomoyo_check_file_perm2(struct tomoyo_domain_info * const domain,
770 if (!filename) 770 if (!filename)
771 return 0; 771 return 0;
772 error = tomoyo_check_file_acl(domain, filename, perm); 772 error = tomoyo_check_file_acl(domain, filename, perm);
773 if (error && perm == 4 && 773 if (error && perm == 4 && !domain->ignore_global_allow_read
774 (domain->flags & TOMOYO_DOMAIN_FLAGS_IGNORE_GLOBAL_ALLOW_READ) == 0
775 && tomoyo_is_globally_readable_file(filename)) 774 && tomoyo_is_globally_readable_file(filename))
776 error = 0; 775 error = 0;
777 if (perm == 6) 776 if (perm == 6)
@@ -885,15 +884,12 @@ static int tomoyo_update_single_path_acl(const u8 type, const char *filename,
885 if (is_delete) 884 if (is_delete)
886 goto delete; 885 goto delete;
887 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) { 886 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) {
888 if (tomoyo_acl_type1(ptr) != TOMOYO_TYPE_SINGLE_PATH_ACL) 887 if (ptr->type != TOMOYO_TYPE_SINGLE_PATH_ACL)
889 continue; 888 continue;
890 acl = container_of(ptr, struct tomoyo_single_path_acl_record, 889 acl = container_of(ptr, struct tomoyo_single_path_acl_record,
891 head); 890 head);
892 if (acl->filename != saved_filename) 891 if (acl->filename != saved_filename)
893 continue; 892 continue;
894 /* Special case. Clear all bits if marked as deleted. */
895 if (ptr->type & TOMOYO_ACL_DELETED)
896 acl->perm = 0;
897 if (perm <= 0xFFFF) 893 if (perm <= 0xFFFF)
898 acl->perm |= perm; 894 acl->perm |= perm;
899 else 895 else
@@ -902,7 +898,6 @@ static int tomoyo_update_single_path_acl(const u8 type, const char *filename,
902 acl->perm |= 1 << TOMOYO_TYPE_READ_WRITE_ACL; 898 acl->perm |= 1 << TOMOYO_TYPE_READ_WRITE_ACL;
903 else if (acl->perm & (1 << TOMOYO_TYPE_READ_WRITE_ACL)) 899 else if (acl->perm & (1 << TOMOYO_TYPE_READ_WRITE_ACL))
904 acl->perm |= rw_mask; 900 acl->perm |= rw_mask;
905 ptr->type &= ~TOMOYO_ACL_DELETED;
906 error = 0; 901 error = 0;
907 goto out; 902 goto out;
908 } 903 }
@@ -927,7 +922,7 @@ static int tomoyo_update_single_path_acl(const u8 type, const char *filename,
927 delete: 922 delete:
928 error = -ENOENT; 923 error = -ENOENT;
929 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) { 924 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) {
930 if (tomoyo_acl_type2(ptr) != TOMOYO_TYPE_SINGLE_PATH_ACL) 925 if (ptr->type != TOMOYO_TYPE_SINGLE_PATH_ACL)
931 continue; 926 continue;
932 acl = container_of(ptr, struct tomoyo_single_path_acl_record, 927 acl = container_of(ptr, struct tomoyo_single_path_acl_record,
933 head); 928 head);
@@ -941,8 +936,6 @@ static int tomoyo_update_single_path_acl(const u8 type, const char *filename,
941 acl->perm &= ~(1 << TOMOYO_TYPE_READ_WRITE_ACL); 936 acl->perm &= ~(1 << TOMOYO_TYPE_READ_WRITE_ACL);
942 else if (!(acl->perm & (1 << TOMOYO_TYPE_READ_WRITE_ACL))) 937 else if (!(acl->perm & (1 << TOMOYO_TYPE_READ_WRITE_ACL)))
943 acl->perm &= ~rw_mask; 938 acl->perm &= ~rw_mask;
944 if (!acl->perm && !acl->perm_high)
945 ptr->type |= TOMOYO_ACL_DELETED;
946 error = 0; 939 error = 0;
947 break; 940 break;
948 } 941 }
@@ -989,18 +982,14 @@ static int tomoyo_update_double_path_acl(const u8 type, const char *filename1,
989 if (is_delete) 982 if (is_delete)
990 goto delete; 983 goto delete;
991 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) { 984 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) {
992 if (tomoyo_acl_type1(ptr) != TOMOYO_TYPE_DOUBLE_PATH_ACL) 985 if (ptr->type != TOMOYO_TYPE_DOUBLE_PATH_ACL)
993 continue; 986 continue;
994 acl = container_of(ptr, struct tomoyo_double_path_acl_record, 987 acl = container_of(ptr, struct tomoyo_double_path_acl_record,
995 head); 988 head);
996 if (acl->filename1 != saved_filename1 || 989 if (acl->filename1 != saved_filename1 ||
997 acl->filename2 != saved_filename2) 990 acl->filename2 != saved_filename2)
998 continue; 991 continue;
999 /* Special case. Clear all bits if marked as deleted. */
1000 if (ptr->type & TOMOYO_ACL_DELETED)
1001 acl->perm = 0;
1002 acl->perm |= perm; 992 acl->perm |= perm;
1003 ptr->type &= ~TOMOYO_ACL_DELETED;
1004 error = 0; 993 error = 0;
1005 goto out; 994 goto out;
1006 } 995 }
@@ -1021,7 +1010,7 @@ static int tomoyo_update_double_path_acl(const u8 type, const char *filename1,
1021 delete: 1010 delete:
1022 error = -ENOENT; 1011 error = -ENOENT;
1023 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) { 1012 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) {
1024 if (tomoyo_acl_type2(ptr) != TOMOYO_TYPE_DOUBLE_PATH_ACL) 1013 if (ptr->type != TOMOYO_TYPE_DOUBLE_PATH_ACL)
1025 continue; 1014 continue;
1026 acl = container_of(ptr, struct tomoyo_double_path_acl_record, 1015 acl = container_of(ptr, struct tomoyo_double_path_acl_record,
1027 head); 1016 head);
@@ -1029,8 +1018,6 @@ static int tomoyo_update_double_path_acl(const u8 type, const char *filename1,
1029 acl->filename2 != saved_filename2) 1018 acl->filename2 != saved_filename2)
1030 continue; 1019 continue;
1031 acl->perm &= ~perm; 1020 acl->perm &= ~perm;
1032 if (!acl->perm)
1033 ptr->type |= TOMOYO_ACL_DELETED;
1034 error = 0; 1021 error = 0;
1035 break; 1022 break;
1036 } 1023 }
@@ -1086,7 +1073,7 @@ static int tomoyo_check_double_path_acl(const struct tomoyo_domain_info *domain,
1086 return 0; 1073 return 0;
1087 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) { 1074 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) {
1088 struct tomoyo_double_path_acl_record *acl; 1075 struct tomoyo_double_path_acl_record *acl;
1089 if (tomoyo_acl_type2(ptr) != TOMOYO_TYPE_DOUBLE_PATH_ACL) 1076 if (ptr->type != TOMOYO_TYPE_DOUBLE_PATH_ACL)
1090 continue; 1077 continue;
1091 acl = container_of(ptr, struct tomoyo_double_path_acl_record, 1078 acl = container_of(ptr, struct tomoyo_double_path_acl_record,
1092 head); 1079 head);