@@ -88,52 +88,64 @@ enum tomoyo_mac_index {
8888enum tomoyo_acl_entry_type_index {
8989 TOMOYO_TYPE_PATH_ACL ,
9090 TOMOYO_TYPE_PATH2_ACL ,
91+ TOMOYO_TYPE_PATH_NUMBER_ACL ,
92+ TOMOYO_TYPE_PATH_NUMBER3_ACL ,
9193};
9294
9395/* Index numbers for File Controls. */
9496
9597/*
96- * TYPE_READ_WRITE_ACL is special. TYPE_READ_WRITE_ACL is automatically set
97- * if both TYPE_READ_ACL and TYPE_WRITE_ACL are set. Both TYPE_READ_ACL and
98- * TYPE_WRITE_ACL are automatically set if TYPE_READ_WRITE_ACL is set.
99- * TYPE_READ_WRITE_ACL is automatically cleared if either TYPE_READ_ACL or
100- * TYPE_WRITE_ACL is cleared. Both TYPE_READ_ACL and TYPE_WRITE_ACL are
101- * automatically cleared if TYPE_READ_WRITE_ACL is cleared.
98+ * TOMOYO_TYPE_READ_WRITE is special. TOMOYO_TYPE_READ_WRITE is automatically
99+ * set if both TOMOYO_TYPE_READ and TOMOYO_TYPE_WRITE are set.
100+ * Both TOMOYO_TYPE_READ and TOMOYO_TYPE_WRITE are automatically set if
101+ * TOMOYO_TYPE_READ_WRITE is set.
102+ * TOMOYO_TYPE_READ_WRITE is automatically cleared if either TOMOYO_TYPE_READ
103+ * or TOMOYO_TYPE_WRITE is cleared.
104+ * Both TOMOYO_TYPE_READ and TOMOYO_TYPE_WRITE are automatically cleared if
105+ * TOMOYO_TYPE_READ_WRITE is cleared.
102106 */
103107
104108enum tomoyo_path_acl_index {
105109 TOMOYO_TYPE_READ_WRITE ,
106110 TOMOYO_TYPE_EXECUTE ,
107111 TOMOYO_TYPE_READ ,
108112 TOMOYO_TYPE_WRITE ,
109- TOMOYO_TYPE_CREATE ,
110113 TOMOYO_TYPE_UNLINK ,
111- TOMOYO_TYPE_MKDIR ,
112114 TOMOYO_TYPE_RMDIR ,
113- TOMOYO_TYPE_MKFIFO ,
114- TOMOYO_TYPE_MKSOCK ,
115- TOMOYO_TYPE_MKBLOCK ,
116- TOMOYO_TYPE_MKCHAR ,
117115 TOMOYO_TYPE_TRUNCATE ,
118116 TOMOYO_TYPE_SYMLINK ,
119117 TOMOYO_TYPE_REWRITE ,
120- TOMOYO_TYPE_IOCTL ,
121- TOMOYO_TYPE_CHMOD ,
122- TOMOYO_TYPE_CHOWN ,
123- TOMOYO_TYPE_CHGRP ,
124118 TOMOYO_TYPE_CHROOT ,
125119 TOMOYO_TYPE_MOUNT ,
126120 TOMOYO_TYPE_UMOUNT ,
127121 TOMOYO_MAX_PATH_OPERATION
128122};
129123
124+ enum tomoyo_path_number3_acl_index {
125+ TOMOYO_TYPE_MKBLOCK ,
126+ TOMOYO_TYPE_MKCHAR ,
127+ TOMOYO_MAX_PATH_NUMBER3_OPERATION
128+ };
129+
130130enum tomoyo_path2_acl_index {
131131 TOMOYO_TYPE_LINK ,
132132 TOMOYO_TYPE_RENAME ,
133133 TOMOYO_TYPE_PIVOT_ROOT ,
134134 TOMOYO_MAX_PATH2_OPERATION
135135};
136136
137+ enum tomoyo_path_number_acl_index {
138+ TOMOYO_TYPE_CREATE ,
139+ TOMOYO_TYPE_MKDIR ,
140+ TOMOYO_TYPE_MKFIFO ,
141+ TOMOYO_TYPE_MKSOCK ,
142+ TOMOYO_TYPE_IOCTL ,
143+ TOMOYO_TYPE_CHMOD ,
144+ TOMOYO_TYPE_CHOWN ,
145+ TOMOYO_TYPE_CHGRP ,
146+ TOMOYO_MAX_PATH_NUMBER_OPERATION
147+ };
148+
137149enum tomoyo_securityfs_interface_index {
138150 TOMOYO_DOMAINPOLICY ,
139151 TOMOYO_EXCEPTIONPOLICY ,
@@ -347,19 +359,61 @@ struct tomoyo_domain_info {
347359 * (3) "name" is the pathname.
348360 *
349361 * Directives held by this structure are "allow_read/write", "allow_execute",
350- * "allow_read", "allow_write", "allow_create", "allow_unlink", "allow_mkdir",
351- * "allow_rmdir", "allow_mkfifo", "allow_mksock", "allow_mkblock",
352- * "allow_mkchar", "allow_truncate", "allow_symlink", "allow_rewrite",
353- * "allow_ioctl", "allow_chmod", "allow_chown", "allow_chgrp", "allow_chroot",
362+ * "allow_read", "allow_write", "allow_unlink", "allow_rmdir",
363+ * "allow_truncate", "allow_symlink", "allow_rewrite", "allow_chroot",
354364 * "allow_mount" and "allow_unmount".
355365 */
356366struct tomoyo_path_acl {
357367 struct tomoyo_acl_info head ; /* type = TOMOYO_TYPE_PATH_ACL */
358- u8 perm_high ;
359368 u16 perm ;
360369 struct tomoyo_name_union name ;
361370};
362371
372+ /*
373+ * tomoyo_path_number_acl is a structure which is used for holding an
374+ * entry with one pathname and one number operation.
375+ * It has following fields.
376+ *
377+ * (1) "head" which is a "struct tomoyo_acl_info".
378+ * (2) "perm" which is a bitmask of permitted operations.
379+ * (3) "name" is the pathname.
380+ * (4) "number" is the numeric value.
381+ *
382+ * Directives held by this structure are "allow_create", "allow_mkdir",
383+ * "allow_ioctl", "allow_mkfifo", "allow_mksock", "allow_chmod", "allow_chown"
384+ * and "allow_chgrp".
385+ *
386+ */
387+ struct tomoyo_path_number_acl {
388+ struct tomoyo_acl_info head ; /* type = TOMOYO_TYPE_PATH_NUMBER_ACL */
389+ u8 perm ;
390+ struct tomoyo_name_union name ;
391+ struct tomoyo_number_union number ;
392+ };
393+
394+ /*
395+ * tomoyo_path_number3_acl is a structure which is used for holding an
396+ * entry with one pathname and three numbers operation.
397+ * It has following fields.
398+ *
399+ * (1) "head" which is a "struct tomoyo_acl_info".
400+ * (2) "perm" which is a bitmask of permitted operations.
401+ * (3) "mode" is the create mode.
402+ * (4) "major" is the major number of device node.
403+ * (5) "minor" is the minor number of device node.
404+ *
405+ * Directives held by this structure are "allow_mkchar", "allow_mkblock".
406+ *
407+ */
408+ struct tomoyo_path_number3_acl {
409+ struct tomoyo_acl_info head ; /* type = TOMOYO_TYPE_PATH_NUMBER3_ACL */
410+ u8 perm ;
411+ struct tomoyo_name_union name ;
412+ struct tomoyo_number_union mode ;
413+ struct tomoyo_number_union major ;
414+ struct tomoyo_number_union minor ;
415+ };
416+
363417/*
364418 * tomoyo_path2_acl is a structure which is used for holding an
365419 * entry with two pathnames operation (i.e. link(), rename() and pivot_root()).
@@ -639,6 +693,8 @@ bool tomoyo_tokenize(char *buffer, char *w[], size_t size);
639693bool tomoyo_verbose_mode (const struct tomoyo_domain_info * domain );
640694/* Convert double path operation to operation name. */
641695const char * tomoyo_path22keyword (const u8 operation );
696+ const char * tomoyo_path_number2keyword (const u8 operation );
697+ const char * tomoyo_path_number32keyword (const u8 operation );
642698/* Get the last component of the given domainname. */
643699const char * tomoyo_get_last_name (const struct tomoyo_domain_info * domain );
644700/* Convert single path operation to operation name. */
@@ -736,11 +792,18 @@ int tomoyo_check_exec_perm(struct tomoyo_domain_info *domain,
736792 const struct tomoyo_path_info * filename );
737793int tomoyo_check_open_permission (struct tomoyo_domain_info * domain ,
738794 struct path * path , const int flag );
795+ int tomoyo_path_number_perm (const u8 operation , struct path * path ,
796+ unsigned long number );
797+ int tomoyo_path_number3_perm (const u8 operation , struct path * path ,
798+ const unsigned int mode , unsigned int dev );
739799int tomoyo_path_perm (const u8 operation , struct path * path );
740800int tomoyo_path2_perm (const u8 operation , struct path * path1 ,
741801 struct path * path2 );
742802int tomoyo_find_next_domain (struct linux_binprm * bprm );
743803
804+ void tomoyo_print_ulong (char * buffer , const int buffer_len ,
805+ const unsigned long value , const u8 type );
806+
744807/* Drop refcount on tomoyo_name_union. */
745808void tomoyo_put_name_union (struct tomoyo_name_union * ptr );
746809
@@ -880,6 +943,18 @@ static inline bool tomoyo_is_same_path_acl(const struct tomoyo_path_acl *p1,
880943 tomoyo_is_same_name_union (& p1 -> name , & p2 -> name );
881944}
882945
946+ static inline bool tomoyo_is_same_path_number3_acl
947+ (const struct tomoyo_path_number3_acl * p1 ,
948+ const struct tomoyo_path_number3_acl * p2 )
949+ {
950+ return tomoyo_is_same_acl_head (& p1 -> head , & p2 -> head )
951+ && tomoyo_is_same_name_union (& p1 -> name , & p2 -> name )
952+ && tomoyo_is_same_number_union (& p1 -> mode , & p2 -> mode )
953+ && tomoyo_is_same_number_union (& p1 -> major , & p2 -> major )
954+ && tomoyo_is_same_number_union (& p1 -> minor , & p2 -> minor );
955+ }
956+
957+
883958static inline bool tomoyo_is_same_path2_acl (const struct tomoyo_path2_acl * p1 ,
884959 const struct tomoyo_path2_acl * p2 )
885960{
@@ -888,6 +963,15 @@ static inline bool tomoyo_is_same_path2_acl(const struct tomoyo_path2_acl *p1,
888963 tomoyo_is_same_name_union (& p1 -> name2 , & p2 -> name2 );
889964}
890965
966+ static inline bool tomoyo_is_same_path_number_acl
967+ (const struct tomoyo_path_number_acl * p1 ,
968+ const struct tomoyo_path_number_acl * p2 )
969+ {
970+ return tomoyo_is_same_acl_head (& p1 -> head , & p2 -> head )
971+ && tomoyo_is_same_name_union (& p1 -> name , & p2 -> name )
972+ && tomoyo_is_same_number_union (& p1 -> number , & p2 -> number );
973+ }
974+
891975static inline bool tomoyo_is_same_domain_initializer_entry
892976(const struct tomoyo_domain_initializer_entry * p1 ,
893977 const struct tomoyo_domain_initializer_entry * p2 )
0 commit comments