@@ -53,6 +53,7 @@ enum tomoyo_mode_index {
5353
5454/* Keywords for ACLs. */
5555#define TOMOYO_KEYWORD_ALIAS "alias "
56+ #define TOMOYO_KEYWORD_ALLOW_MOUNT "allow_mount "
5657#define TOMOYO_KEYWORD_ALLOW_READ "allow_read "
5758#define TOMOYO_KEYWORD_DELETE "delete "
5859#define TOMOYO_KEYWORD_DENY_REWRITE "deny_rewrite "
@@ -90,6 +91,7 @@ enum tomoyo_acl_entry_type_index {
9091 TOMOYO_TYPE_PATH2_ACL ,
9192 TOMOYO_TYPE_PATH_NUMBER_ACL ,
9293 TOMOYO_TYPE_PATH_NUMBER3_ACL ,
94+ TOMOYO_TYPE_MOUNT_ACL ,
9395};
9496
9597/* Index numbers for File Controls. */
@@ -116,7 +118,6 @@ enum tomoyo_path_acl_index {
116118 TOMOYO_TYPE_SYMLINK ,
117119 TOMOYO_TYPE_REWRITE ,
118120 TOMOYO_TYPE_CHROOT ,
119- TOMOYO_TYPE_MOUNT ,
120121 TOMOYO_TYPE_UMOUNT ,
121122 TOMOYO_MAX_PATH_OPERATION
122123};
@@ -360,8 +361,8 @@ struct tomoyo_domain_info {
360361 *
361362 * Directives held by this structure are "allow_read/write", "allow_execute",
362363 * "allow_read", "allow_write", "allow_unlink", "allow_rmdir",
363- * "allow_truncate", "allow_symlink", "allow_rewrite", "allow_chroot",
364- * "allow_mount" and " allow_unmount".
364+ * "allow_truncate", "allow_symlink", "allow_rewrite", "allow_chroot" and
365+ * "allow_unmount".
365366 */
366367struct tomoyo_path_acl {
367368 struct tomoyo_acl_info head ; /* type = TOMOYO_TYPE_PATH_ACL */
@@ -434,6 +435,29 @@ struct tomoyo_path2_acl {
434435 struct tomoyo_name_union name2 ;
435436};
436437
438+ /*
439+ * tomoyo_mount_acl is a structure which is used for holding an
440+ * entry for mount operation.
441+ * It has following fields.
442+ *
443+ * (1) "head" which is a "struct tomoyo_acl_info".
444+ * (2) "is_deleted" is boolean.
445+ * (3) "dev_name" is the device name.
446+ * (4) "dir_name" is the mount point.
447+ * (5) "flags" is the mount flags.
448+ *
449+ * Directives held by this structure are "allow_rename", "allow_link" and
450+ * "allow_pivot_root".
451+ */
452+ struct tomoyo_mount_acl {
453+ struct tomoyo_acl_info head ; /* type = TOMOYO_TYPE_MOUNT_ACL */
454+ bool is_deleted ;
455+ struct tomoyo_name_union dev_name ;
456+ struct tomoyo_name_union dir_name ;
457+ struct tomoyo_name_union fs_type ;
458+ struct tomoyo_number_union flags ;
459+ };
460+
437461/*
438462 * tomoyo_io_buffer is a structure which is used for reading and modifying
439463 * configuration via /sys/kernel/security/tomoyo/ interface.
@@ -638,6 +662,9 @@ struct tomoyo_policy_manager_entry {
638662/* Check whether the given name matches the given name_union. */
639663bool tomoyo_compare_name_union (const struct tomoyo_path_info * name ,
640664 const struct tomoyo_name_union * ptr );
665+ /* Check whether the given number matches the given number_union. */
666+ bool tomoyo_compare_number_union (const unsigned long value ,
667+ const struct tomoyo_number_union * ptr );
641668/* Check whether the domain has too many ACL entries to hold. */
642669bool tomoyo_domain_quota_is_ok (struct tomoyo_request_info * r );
643670/* Transactional sprintf() for policy dump. */
@@ -699,6 +726,12 @@ const char *tomoyo_path_number32keyword(const u8 operation);
699726const char * tomoyo_get_last_name (const struct tomoyo_domain_info * domain );
700727/* Convert single path operation to operation name. */
701728const char * tomoyo_path2keyword (const u8 operation );
729+ /* Fill "struct tomoyo_request_info". */
730+ int tomoyo_init_request_info (struct tomoyo_request_info * r ,
731+ struct tomoyo_domain_info * domain );
732+ /* Check permission for mount operation. */
733+ int tomoyo_mount_permission (char * dev_name , struct path * path , char * type ,
734+ unsigned long flags , void * data_page );
702735/* Create "alias" entry in exception policy. */
703736int tomoyo_write_alias_policy (char * data , const bool is_delete );
704737/*
@@ -721,6 +754,9 @@ int tomoyo_write_file_policy(char *data, struct tomoyo_domain_info *domain,
721754 const bool is_delete );
722755/* Create "allow_read" entry in exception policy. */
723756int tomoyo_write_globally_readable_policy (char * data , const bool is_delete );
757+ /* Create "allow_mount" entry in domain policy. */
758+ int tomoyo_write_mount_policy (char * data , struct tomoyo_domain_info * domain ,
759+ const bool is_delete );
724760/* Create "deny_rewrite" entry in exception policy. */
725761int tomoyo_write_no_rewrite_policy (char * data , const bool is_delete );
726762/* Create "file_pattern" entry in exception policy. */
@@ -735,7 +771,9 @@ struct tomoyo_domain_info *tomoyo_find_domain(const char *domainname);
735771struct tomoyo_domain_info * tomoyo_find_or_assign_new_domain (const char *
736772 domainname ,
737773 const u8 profile );
738-
774+ /* Get patterned pathname. */
775+ const struct tomoyo_path_info *
776+ tomoyo_get_file_pattern (const struct tomoyo_path_info * filename );
739777/* Allocate memory for "struct tomoyo_path_group". */
740778struct tomoyo_path_group * tomoyo_get_path_group (const char * group_name );
741779struct tomoyo_number_group * tomoyo_get_number_group (const char * group_name );
@@ -972,6 +1010,16 @@ static inline bool tomoyo_is_same_path_number_acl
9721010 && tomoyo_is_same_number_union (& p1 -> number , & p2 -> number );
9731011}
9741012
1013+ static inline bool tomoyo_is_same_mount_acl (const struct tomoyo_mount_acl * p1 ,
1014+ const struct tomoyo_mount_acl * p2 )
1015+ {
1016+ return tomoyo_is_same_acl_head (& p1 -> head , & p2 -> head ) &&
1017+ tomoyo_is_same_name_union (& p1 -> dev_name , & p2 -> dev_name ) &&
1018+ tomoyo_is_same_name_union (& p1 -> dir_name , & p2 -> dir_name ) &&
1019+ tomoyo_is_same_name_union (& p1 -> fs_type , & p2 -> fs_type ) &&
1020+ tomoyo_is_same_number_union (& p1 -> flags , & p2 -> flags );
1021+ }
1022+
9751023static inline bool tomoyo_is_same_domain_initializer_entry
9761024(const struct tomoyo_domain_initializer_entry * p1 ,
9771025 const struct tomoyo_domain_initializer_entry * p2 )
0 commit comments