aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/common.h
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2011-06-26 10:15:31 -0400
committerJames Morris <jmorris@namei.org>2011-06-28 19:31:19 -0400
commit7c75964f432d14062d8eccfc916aa290f56b5aab (patch)
tree8aecdb96f9f079dd36735c3acccb79f3d10d6559 /security/tomoyo/common.h
parent1252cc3b232e582e887623dc5f70979418caaaa2 (diff)
TOMOYO: Cleanup part 1.
In order to synchronize with TOMOYO 1.8's syntax, (1) Remove special handling for allow_read/write permission. (2) Replace deny_rewrite/allow_rewrite permission with allow_append permission. (3) Remove file_pattern keyword. (4) Remove allow_read permission from exception policy. (5) Allow creating domains in enforcing mode without calling supervisor. (6) Add permission check for opening directory for reading. (7) Add permission check for stat() operation. (8) Make "cat < /sys/kernel/security/tomoyo/self_domain" behave as if "cat /sys/kernel/security/tomoyo/self_domain". 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.h93
1 files changed, 10 insertions, 83 deletions
diff --git a/security/tomoyo/common.h b/security/tomoyo/common.h
index 7c66bd898782..a5d6e212b18f 100644
--- a/security/tomoyo/common.h
+++ b/security/tomoyo/common.h
@@ -52,9 +52,6 @@ enum tomoyo_policy_id {
52 TOMOYO_ID_NUMBER_GROUP, 52 TOMOYO_ID_NUMBER_GROUP,
53 TOMOYO_ID_TRANSITION_CONTROL, 53 TOMOYO_ID_TRANSITION_CONTROL,
54 TOMOYO_ID_AGGREGATOR, 54 TOMOYO_ID_AGGREGATOR,
55 TOMOYO_ID_GLOBALLY_READABLE,
56 TOMOYO_ID_PATTERN,
57 TOMOYO_ID_NO_REWRITE,
58 TOMOYO_ID_MANAGER, 55 TOMOYO_ID_MANAGER,
59 TOMOYO_ID_NAME, 56 TOMOYO_ID_NAME,
60 TOMOYO_ID_ACL, 57 TOMOYO_ID_ACL,
@@ -73,8 +70,6 @@ enum tomoyo_group_id {
73#define TOMOYO_KEYWORD_ALLOW_MOUNT "allow_mount " 70#define TOMOYO_KEYWORD_ALLOW_MOUNT "allow_mount "
74#define TOMOYO_KEYWORD_ALLOW_READ "allow_read " 71#define TOMOYO_KEYWORD_ALLOW_READ "allow_read "
75#define TOMOYO_KEYWORD_DELETE "delete " 72#define TOMOYO_KEYWORD_DELETE "delete "
76#define TOMOYO_KEYWORD_DENY_REWRITE "deny_rewrite "
77#define TOMOYO_KEYWORD_FILE_PATTERN "file_pattern "
78#define TOMOYO_KEYWORD_INITIALIZE_DOMAIN "initialize_domain " 73#define TOMOYO_KEYWORD_INITIALIZE_DOMAIN "initialize_domain "
79#define TOMOYO_KEYWORD_KEEP_DOMAIN "keep_domain " 74#define TOMOYO_KEYWORD_KEEP_DOMAIN "keep_domain "
80#define TOMOYO_KEYWORD_NO_INITIALIZE_DOMAIN "no_initialize_domain " 75#define TOMOYO_KEYWORD_NO_INITIALIZE_DOMAIN "no_initialize_domain "
@@ -83,7 +78,6 @@ enum tomoyo_group_id {
83#define TOMOYO_KEYWORD_NUMBER_GROUP "number_group " 78#define TOMOYO_KEYWORD_NUMBER_GROUP "number_group "
84#define TOMOYO_KEYWORD_SELECT "select " 79#define TOMOYO_KEYWORD_SELECT "select "
85#define TOMOYO_KEYWORD_USE_PROFILE "use_profile " 80#define TOMOYO_KEYWORD_USE_PROFILE "use_profile "
86#define TOMOYO_KEYWORD_IGNORE_GLOBAL_ALLOW_READ "ignore_global_allow_read"
87#define TOMOYO_KEYWORD_QUOTA_EXCEEDED "quota_exceeded" 81#define TOMOYO_KEYWORD_QUOTA_EXCEEDED "quota_exceeded"
88#define TOMOYO_KEYWORD_TRANSITION_FAILED "transition_failed" 82#define TOMOYO_KEYWORD_TRANSITION_FAILED "transition_failed"
89/* A domain definition starts with <kernel>. */ 83/* A domain definition starts with <kernel>. */
@@ -115,35 +109,21 @@ enum tomoyo_acl_entry_type_index {
115}; 109};
116 110
117/* Index numbers for File Controls. */ 111/* Index numbers for File Controls. */
118
119/*
120 * TOMOYO_TYPE_READ_WRITE is special. TOMOYO_TYPE_READ_WRITE is automatically
121 * set if both TOMOYO_TYPE_READ and TOMOYO_TYPE_WRITE are set.
122 * Both TOMOYO_TYPE_READ and TOMOYO_TYPE_WRITE are automatically set if
123 * TOMOYO_TYPE_READ_WRITE is set.
124 * TOMOYO_TYPE_READ_WRITE is automatically cleared if either TOMOYO_TYPE_READ
125 * or TOMOYO_TYPE_WRITE is cleared.
126 * Both TOMOYO_TYPE_READ and TOMOYO_TYPE_WRITE are automatically cleared if
127 * TOMOYO_TYPE_READ_WRITE is cleared.
128 */
129
130enum tomoyo_path_acl_index { 112enum tomoyo_path_acl_index {
131 TOMOYO_TYPE_READ_WRITE,
132 TOMOYO_TYPE_EXECUTE, 113 TOMOYO_TYPE_EXECUTE,
133 TOMOYO_TYPE_READ, 114 TOMOYO_TYPE_READ,
134 TOMOYO_TYPE_WRITE, 115 TOMOYO_TYPE_WRITE,
116 TOMOYO_TYPE_APPEND,
135 TOMOYO_TYPE_UNLINK, 117 TOMOYO_TYPE_UNLINK,
118 TOMOYO_TYPE_GETATTR,
136 TOMOYO_TYPE_RMDIR, 119 TOMOYO_TYPE_RMDIR,
137 TOMOYO_TYPE_TRUNCATE, 120 TOMOYO_TYPE_TRUNCATE,
138 TOMOYO_TYPE_SYMLINK, 121 TOMOYO_TYPE_SYMLINK,
139 TOMOYO_TYPE_REWRITE,
140 TOMOYO_TYPE_CHROOT, 122 TOMOYO_TYPE_CHROOT,
141 TOMOYO_TYPE_UMOUNT, 123 TOMOYO_TYPE_UMOUNT,
142 TOMOYO_MAX_PATH_OPERATION 124 TOMOYO_MAX_PATH_OPERATION
143}; 125};
144 126
145#define TOMOYO_RW_MASK ((1 << TOMOYO_TYPE_READ) | (1 << TOMOYO_TYPE_WRITE))
146
147enum tomoyo_mkdev_acl_index { 127enum tomoyo_mkdev_acl_index {
148 TOMOYO_TYPE_MKBLOCK, 128 TOMOYO_TYPE_MKBLOCK,
149 TOMOYO_TYPE_MKCHAR, 129 TOMOYO_TYPE_MKCHAR,
@@ -187,13 +167,13 @@ enum tomoyo_mac_index {
187 TOMOYO_MAC_FILE_OPEN, 167 TOMOYO_MAC_FILE_OPEN,
188 TOMOYO_MAC_FILE_CREATE, 168 TOMOYO_MAC_FILE_CREATE,
189 TOMOYO_MAC_FILE_UNLINK, 169 TOMOYO_MAC_FILE_UNLINK,
170 TOMOYO_MAC_FILE_GETATTR,
190 TOMOYO_MAC_FILE_MKDIR, 171 TOMOYO_MAC_FILE_MKDIR,
191 TOMOYO_MAC_FILE_RMDIR, 172 TOMOYO_MAC_FILE_RMDIR,
192 TOMOYO_MAC_FILE_MKFIFO, 173 TOMOYO_MAC_FILE_MKFIFO,
193 TOMOYO_MAC_FILE_MKSOCK, 174 TOMOYO_MAC_FILE_MKSOCK,
194 TOMOYO_MAC_FILE_TRUNCATE, 175 TOMOYO_MAC_FILE_TRUNCATE,
195 TOMOYO_MAC_FILE_SYMLINK, 176 TOMOYO_MAC_FILE_SYMLINK,
196 TOMOYO_MAC_FILE_REWRITE,
197 TOMOYO_MAC_FILE_MKBLOCK, 177 TOMOYO_MAC_FILE_MKBLOCK,
198 TOMOYO_MAC_FILE_MKCHAR, 178 TOMOYO_MAC_FILE_MKCHAR,
199 TOMOYO_MAC_FILE_LINK, 179 TOMOYO_MAC_FILE_LINK,
@@ -388,9 +368,7 @@ struct tomoyo_acl_info {
388 * "deleted", false otherwise. 368 * "deleted", false otherwise.
389 * (6) "quota_warned" is a bool which is used for suppressing warning message 369 * (6) "quota_warned" is a bool which is used for suppressing warning message
390 * when learning mode learned too much entries. 370 * when learning mode learned too much entries.
391 * (7) "ignore_global_allow_read" is a bool which is true if this domain 371 * (7) "transition_failed" is a bool which is set to true when this domain was
392 * should ignore "allow_read" directive in exception policy.
393 * (8) "transition_failed" is a bool which is set to true when this domain was
394 * unable to create a new domain at tomoyo_find_next_domain() because the 372 * unable to create a new domain at tomoyo_find_next_domain() because the
395 * name of the domain to be created was too long or it could not allocate 373 * name of the domain to be created was too long or it could not allocate
396 * memory. If set to true, more than one process continued execve() 374 * memory. If set to true, more than one process continued execve()
@@ -415,7 +393,6 @@ struct tomoyo_domain_info {
415 u8 profile; /* Profile number to use. */ 393 u8 profile; /* Profile number to use. */
416 bool is_deleted; /* Delete flag. */ 394 bool is_deleted; /* Delete flag. */
417 bool quota_warned; /* Quota warnning flag. */ 395 bool quota_warned; /* Quota warnning flag. */
418 bool ignore_global_allow_read; /* Ignore "allow_read" flag. */
419 bool transition_failed; /* Domain transition failed flag. */ 396 bool transition_failed; /* Domain transition failed flag. */
420 atomic_t users; /* Number of referring credentials. */ 397 atomic_t users; /* Number of referring credentials. */
421}; 398};
@@ -429,10 +406,9 @@ struct tomoyo_domain_info {
429 * (2) "perm" which is a bitmask of permitted operations. 406 * (2) "perm" which is a bitmask of permitted operations.
430 * (3) "name" is the pathname. 407 * (3) "name" is the pathname.
431 * 408 *
432 * Directives held by this structure are "allow_read/write", "allow_execute", 409 * Directives held by this structure are "allow_execute", "allow_read",
433 * "allow_read", "allow_write", "allow_unlink", "allow_rmdir", 410 * "allow_write", "allow_append", "allow_unlink", "allow_rmdir",
434 * "allow_truncate", "allow_symlink", "allow_rewrite", "allow_chroot" and 411 * "allow_truncate", "allow_symlink", "allow_chroot" and "allow_unmount".
435 * "allow_unmount".
436 */ 412 */
437struct tomoyo_path_acl { 413struct tomoyo_path_acl {
438 struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_PATH_ACL */ 414 struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_PATH_ACL */
@@ -574,47 +550,6 @@ struct tomoyo_io_buffer {
574}; 550};
575 551
576/* 552/*
577 * tomoyo_readable_file is a structure which is used for holding
578 * "allow_read" entries.
579 * It has following fields.
580 *
581 * (1) "head" is "struct tomoyo_acl_head".
582 * (2) "filename" is a pathname which is allowed to open(O_RDONLY).
583 */
584struct tomoyo_readable_file {
585 struct tomoyo_acl_head head;
586 const struct tomoyo_path_info *filename;
587};
588
589/*
590 * tomoyo_no_pattern is a structure which is used for holding
591 * "file_pattern" entries.
592 * It has following fields.
593 *
594 * (1) "head" is "struct tomoyo_acl_head".
595 * (2) "pattern" is a pathname pattern which is used for converting pathnames
596 * to pathname patterns during learning mode.
597 */
598struct tomoyo_no_pattern {
599 struct tomoyo_acl_head head;
600 const struct tomoyo_path_info *pattern;
601};
602
603/*
604 * tomoyo_no_rewrite is a structure which is used for holding
605 * "deny_rewrite" entries.
606 * It has following fields.
607 *
608 * (1) "head" is "struct tomoyo_acl_head".
609 * (2) "pattern" is a pathname which is by default not permitted to modify
610 * already existing content.
611 */
612struct tomoyo_no_rewrite {
613 struct tomoyo_acl_head head;
614 const struct tomoyo_path_info *pattern;
615};
616
617/*
618 * tomoyo_transition_control is a structure which is used for holding 553 * tomoyo_transition_control is a structure which is used for holding
619 * "initialize_domain"/"no_initialize_domain"/"keep_domain"/"no_keep_domain" 554 * "initialize_domain"/"no_initialize_domain"/"keep_domain"/"no_keep_domain"
620 * entries. 555 * entries.
@@ -764,23 +699,17 @@ int tomoyo_write_aggregator(char *data, const bool is_delete);
764int tomoyo_write_transition_control(char *data, const bool is_delete, 699int tomoyo_write_transition_control(char *data, const bool is_delete,
765 const u8 type); 700 const u8 type);
766/* 701/*
767 * Create "allow_read/write", "allow_execute", "allow_read", "allow_write", 702 * Create "allow_execute", "allow_read", "allow_write", "allow_append",
768 * "allow_create", "allow_unlink", "allow_mkdir", "allow_rmdir", 703 * "allow_create", "allow_unlink", "allow_mkdir", "allow_rmdir",
769 * "allow_mkfifo", "allow_mksock", "allow_mkblock", "allow_mkchar", 704 * "allow_mkfifo", "allow_mksock", "allow_mkblock", "allow_mkchar",
770 * "allow_truncate", "allow_symlink", "allow_rewrite", "allow_rename" and 705 * "allow_truncate", "allow_symlink", "allow_rename" and "allow_link" entry
771 * "allow_link" entry in domain policy. 706 * in domain policy.
772 */ 707 */
773int tomoyo_write_file(char *data, struct tomoyo_domain_info *domain, 708int tomoyo_write_file(char *data, struct tomoyo_domain_info *domain,
774 const bool is_delete); 709 const bool is_delete);
775/* Create "allow_read" entry in exception policy. */
776int tomoyo_write_globally_readable(char *data, const bool is_delete);
777/* Create "allow_mount" entry in domain policy. */ 710/* Create "allow_mount" entry in domain policy. */
778int tomoyo_write_mount(char *data, struct tomoyo_domain_info *domain, 711int tomoyo_write_mount(char *data, struct tomoyo_domain_info *domain,
779 const bool is_delete); 712 const bool is_delete);
780/* Create "deny_rewrite" entry in exception policy. */
781int tomoyo_write_no_rewrite(char *data, const bool is_delete);
782/* Create "file_pattern" entry in exception policy. */
783int tomoyo_write_pattern(char *data, const bool is_delete);
784/* Create "path_group"/"number_group" entry in exception policy. */ 713/* Create "path_group"/"number_group" entry in exception policy. */
785int tomoyo_write_group(char *data, const bool is_delete, const u8 type); 714int tomoyo_write_group(char *data, const bool is_delete, const u8 type);
786int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...) 715int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
@@ -819,8 +748,6 @@ char *tomoyo_realpath_nofollow(const char *pathname);
819 * ignores chroot'ed root and the pathname is already solved. 748 * ignores chroot'ed root and the pathname is already solved.
820 */ 749 */
821char *tomoyo_realpath_from_path(struct path *path); 750char *tomoyo_realpath_from_path(struct path *path);
822/* Get patterned pathname. */
823const char *tomoyo_pattern(const struct tomoyo_path_info *filename);
824 751
825/* Check memory quota. */ 752/* Check memory quota. */
826bool tomoyo_memory_ok(void *ptr); 753bool tomoyo_memory_ok(void *ptr);