diff options
author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2010-06-12 07:46:22 -0400 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2010-08-02 01:34:28 -0400 |
commit | 237ab459f12cb98eadd3fe7b85343e183a1076a4 (patch) | |
tree | f2835e2945016beb4e29b6a2ed8f9d372dc1b412 /security/tomoyo/common.h | |
parent | 927942aabbbe506bf9bc70a16dc5460ecc64c148 (diff) |
TOMOYO: Use callback for updating entries.
Use common "struct list_head" + "bool" + "u8" structure and
use common code for elements using that 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/common.h')
-rw-r--r-- | security/tomoyo/common.h | 82 |
1 files changed, 24 insertions, 58 deletions
diff --git a/security/tomoyo/common.h b/security/tomoyo/common.h index c777c594a00b..539b9a28b739 100644 --- a/security/tomoyo/common.h +++ b/security/tomoyo/common.h | |||
@@ -112,6 +112,8 @@ enum tomoyo_path_acl_index { | |||
112 | TOMOYO_MAX_PATH_OPERATION | 112 | TOMOYO_MAX_PATH_OPERATION |
113 | }; | 113 | }; |
114 | 114 | ||
115 | #define TOMOYO_RW_MASK ((1 << TOMOYO_TYPE_READ) | (1 << TOMOYO_TYPE_WRITE)) | ||
116 | |||
115 | enum tomoyo_path_number3_acl_index { | 117 | enum tomoyo_path_number3_acl_index { |
116 | TOMOYO_TYPE_MKBLOCK, | 118 | TOMOYO_TYPE_MKBLOCK, |
117 | TOMOYO_TYPE_MKCHAR, | 119 | TOMOYO_TYPE_MKCHAR, |
@@ -289,17 +291,19 @@ struct tomoyo_number_group_member { | |||
289 | * | 291 | * |
290 | * (1) "list" which is linked to the ->acl_info_list of | 292 | * (1) "list" which is linked to the ->acl_info_list of |
291 | * "struct tomoyo_domain_info" | 293 | * "struct tomoyo_domain_info" |
292 | * (2) "type" which tells type of the entry (either | 294 | * (2) "is_deleted" is a bool which is true if this domain is marked as |
293 | * "struct tomoyo_path_acl" or "struct tomoyo_path2_acl"). | 295 | * "deleted", false otherwise. |
296 | * (3) "type" which tells type of the entry. | ||
294 | * | 297 | * |
295 | * Packing "struct tomoyo_acl_info" allows | 298 | * Packing "struct tomoyo_acl_info" allows |
296 | * "struct tomoyo_path_acl" to embed "u8" + "u16" and | 299 | * "struct tomoyo_path_acl" to embed "u16" and "struct tomoyo_path2_acl" |
297 | * "struct tomoyo_path2_acl" to embed "u8" | 300 | * "struct tomoyo_path_number_acl" "struct tomoyo_path_number3_acl" to embed |
298 | * without enlarging their structure size. | 301 | * "u8" without enlarging their structure size. |
299 | */ | 302 | */ |
300 | struct tomoyo_acl_info { | 303 | struct tomoyo_acl_info { |
301 | struct list_head list; | 304 | struct list_head list; |
302 | u8 type; | 305 | bool is_deleted; |
306 | u8 type; /* = one of values in "enum tomoyo_acl_entry_type_index". */ | ||
303 | } __packed; | 307 | } __packed; |
304 | 308 | ||
305 | /* | 309 | /* |
@@ -438,17 +442,15 @@ struct tomoyo_path2_acl { | |||
438 | * It has following fields. | 442 | * It has following fields. |
439 | * | 443 | * |
440 | * (1) "head" which is a "struct tomoyo_acl_info". | 444 | * (1) "head" which is a "struct tomoyo_acl_info". |
441 | * (2) "is_deleted" is boolean. | 445 | * (2) "dev_name" is the device name. |
442 | * (3) "dev_name" is the device name. | 446 | * (3) "dir_name" is the mount point. |
443 | * (4) "dir_name" is the mount point. | 447 | * (4) "fs_type" is the filesystem type. |
444 | * (5) "flags" is the mount flags. | 448 | * (5) "flags" is the mount flags. |
445 | * | 449 | * |
446 | * Directives held by this structure are "allow_rename", "allow_link" and | 450 | * Directive held by this structure is "allow_mount". |
447 | * "allow_pivot_root". | ||
448 | */ | 451 | */ |
449 | struct tomoyo_mount_acl { | 452 | struct tomoyo_mount_acl { |
450 | struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_MOUNT_ACL */ | 453 | struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_MOUNT_ACL */ |
451 | bool is_deleted; | ||
452 | struct tomoyo_name_union dev_name; | 454 | struct tomoyo_name_union dev_name; |
453 | struct tomoyo_name_union dir_name; | 455 | struct tomoyo_name_union dir_name; |
454 | struct tomoyo_name_union fs_type; | 456 | struct tomoyo_name_union fs_type; |
@@ -914,6 +916,16 @@ void tomoyo_run_gc(void); | |||
914 | 916 | ||
915 | void tomoyo_memory_free(void *ptr); | 917 | void tomoyo_memory_free(void *ptr); |
916 | 918 | ||
919 | int tomoyo_update_domain(struct tomoyo_acl_info *new_entry, const int size, | ||
920 | bool is_delete, struct tomoyo_domain_info *domain, | ||
921 | bool (*check_duplicate) (const struct tomoyo_acl_info | ||
922 | *, | ||
923 | const struct tomoyo_acl_info | ||
924 | *), | ||
925 | bool (*merge_duplicate) (struct tomoyo_acl_info *, | ||
926 | struct tomoyo_acl_info *, | ||
927 | const bool)); | ||
928 | |||
917 | /********** External variable definitions. **********/ | 929 | /********** External variable definitions. **********/ |
918 | 930 | ||
919 | /* Lock for GC. */ | 931 | /* Lock for GC. */ |
@@ -1042,52 +1054,6 @@ static inline bool tomoyo_is_same_number_union | |||
1042 | p1->max_type == p2->max_type && p1->is_group == p2->is_group; | 1054 | p1->max_type == p2->max_type && p1->is_group == p2->is_group; |
1043 | } | 1055 | } |
1044 | 1056 | ||
1045 | static inline bool tomoyo_is_same_path_acl(const struct tomoyo_path_acl *p1, | ||
1046 | const struct tomoyo_path_acl *p2) | ||
1047 | { | ||
1048 | return tomoyo_is_same_acl_head(&p1->head, &p2->head) && | ||
1049 | tomoyo_is_same_name_union(&p1->name, &p2->name); | ||
1050 | } | ||
1051 | |||
1052 | static inline bool tomoyo_is_same_path_number3_acl | ||
1053 | (const struct tomoyo_path_number3_acl *p1, | ||
1054 | const struct tomoyo_path_number3_acl *p2) | ||
1055 | { | ||
1056 | return tomoyo_is_same_acl_head(&p1->head, &p2->head) | ||
1057 | && tomoyo_is_same_name_union(&p1->name, &p2->name) | ||
1058 | && tomoyo_is_same_number_union(&p1->mode, &p2->mode) | ||
1059 | && tomoyo_is_same_number_union(&p1->major, &p2->major) | ||
1060 | && tomoyo_is_same_number_union(&p1->minor, &p2->minor); | ||
1061 | } | ||
1062 | |||
1063 | |||
1064 | static inline bool tomoyo_is_same_path2_acl(const struct tomoyo_path2_acl *p1, | ||
1065 | const struct tomoyo_path2_acl *p2) | ||
1066 | { | ||
1067 | return tomoyo_is_same_acl_head(&p1->head, &p2->head) && | ||
1068 | tomoyo_is_same_name_union(&p1->name1, &p2->name1) && | ||
1069 | tomoyo_is_same_name_union(&p1->name2, &p2->name2); | ||
1070 | } | ||
1071 | |||
1072 | static inline bool tomoyo_is_same_path_number_acl | ||
1073 | (const struct tomoyo_path_number_acl *p1, | ||
1074 | const struct tomoyo_path_number_acl *p2) | ||
1075 | { | ||
1076 | return tomoyo_is_same_acl_head(&p1->head, &p2->head) | ||
1077 | && tomoyo_is_same_name_union(&p1->name, &p2->name) | ||
1078 | && tomoyo_is_same_number_union(&p1->number, &p2->number); | ||
1079 | } | ||
1080 | |||
1081 | static inline bool tomoyo_is_same_mount_acl(const struct tomoyo_mount_acl *p1, | ||
1082 | const struct tomoyo_mount_acl *p2) | ||
1083 | { | ||
1084 | return tomoyo_is_same_acl_head(&p1->head, &p2->head) && | ||
1085 | tomoyo_is_same_name_union(&p1->dev_name, &p2->dev_name) && | ||
1086 | tomoyo_is_same_name_union(&p1->dir_name, &p2->dir_name) && | ||
1087 | tomoyo_is_same_name_union(&p1->fs_type, &p2->fs_type) && | ||
1088 | tomoyo_is_same_number_union(&p1->flags, &p2->flags); | ||
1089 | } | ||
1090 | |||
1091 | static inline bool tomoyo_is_same_domain_initializer_entry | 1057 | static inline bool tomoyo_is_same_domain_initializer_entry |
1092 | (const struct tomoyo_domain_initializer_entry *p1, | 1058 | (const struct tomoyo_domain_initializer_entry *p1, |
1093 | const struct tomoyo_domain_initializer_entry *p2) | 1059 | const struct tomoyo_domain_initializer_entry *p2) |