@@ -55,13 +55,20 @@ struct linux_binprm;
5555#define TOMOYO_KEYWORD_NO_INITIALIZE_DOMAIN "no_initialize_domain "
5656#define TOMOYO_KEYWORD_NO_KEEP_DOMAIN "no_keep_domain "
5757#define TOMOYO_KEYWORD_PATH_GROUP "path_group "
58+ #define TOMOYO_KEYWORD_NUMBER_GROUP "number_group "
5859#define TOMOYO_KEYWORD_SELECT "select "
5960#define TOMOYO_KEYWORD_USE_PROFILE "use_profile "
6061#define TOMOYO_KEYWORD_IGNORE_GLOBAL_ALLOW_READ "ignore_global_allow_read"
6162/* A domain definition starts with <kernel>. */
6263#define TOMOYO_ROOT_NAME "<kernel>"
6364#define TOMOYO_ROOT_NAME_LEN (sizeof(TOMOYO_ROOT_NAME) - 1)
6465
66+ /* Value type definition. */
67+ #define TOMOYO_VALUE_TYPE_INVALID 0
68+ #define TOMOYO_VALUE_TYPE_DECIMAL 1
69+ #define TOMOYO_VALUE_TYPE_OCTAL 2
70+ #define TOMOYO_VALUE_TYPE_HEXADECIMAL 3
71+
6572/* Index numbers for Access Controls. */
6673enum tomoyo_mac_index {
6774 TOMOYO_MAC_FOR_FILE , /* domain_policy.conf */
@@ -211,6 +218,14 @@ struct tomoyo_name_union {
211218 u8 is_group ;
212219};
213220
221+ struct tomoyo_number_union {
222+ unsigned long values [2 ];
223+ struct tomoyo_number_group * group ;
224+ u8 min_type ;
225+ u8 max_type ;
226+ u8 is_group ;
227+ };
228+
214229/* Structure for "path_group" directive. */
215230struct tomoyo_path_group {
216231 struct list_head list ;
@@ -219,13 +234,28 @@ struct tomoyo_path_group {
219234 atomic_t users ;
220235};
221236
237+ /* Structure for "number_group" directive. */
238+ struct tomoyo_number_group {
239+ struct list_head list ;
240+ const struct tomoyo_path_info * group_name ;
241+ struct list_head member_list ;
242+ atomic_t users ;
243+ };
244+
222245/* Structure for "path_group" directive. */
223246struct tomoyo_path_group_member {
224247 struct list_head list ;
225248 bool is_deleted ;
226249 const struct tomoyo_path_info * member_name ;
227250};
228251
252+ /* Structure for "number_group" directive. */
253+ struct tomoyo_number_group_member {
254+ struct list_head list ;
255+ bool is_deleted ;
256+ struct tomoyo_number_union number ;
257+ };
258+
229259/*
230260 * tomoyo_acl_info is a structure which is used for holding
231261 *
@@ -554,9 +584,18 @@ bool tomoyo_parse_name_union(const char *filename,
554584bool tomoyo_path_matches_group (const struct tomoyo_path_info * pathname ,
555585 const struct tomoyo_path_group * group ,
556586 const bool may_use_pattern );
587+ /* Check whether the given value matches the given number_group. */
588+ bool tomoyo_number_matches_group (const unsigned long min ,
589+ const unsigned long max ,
590+ const struct tomoyo_number_group * group );
557591/* Check whether the given filename matches the given pattern. */
558592bool tomoyo_path_matches_pattern (const struct tomoyo_path_info * filename ,
559593 const struct tomoyo_path_info * pattern );
594+
595+ bool tomoyo_print_number_union (struct tomoyo_io_buffer * head ,
596+ const struct tomoyo_number_union * ptr );
597+ bool tomoyo_parse_number_union (char * data , struct tomoyo_number_union * num );
598+
560599/* Read "alias" entry in exception policy. */
561600bool tomoyo_read_alias_policy (struct tomoyo_io_buffer * head );
562601/*
@@ -570,6 +609,8 @@ bool tomoyo_read_domain_keeper_policy(struct tomoyo_io_buffer *head);
570609bool tomoyo_read_file_pattern (struct tomoyo_io_buffer * head );
571610/* Read "path_group" entry in exception policy. */
572611bool tomoyo_read_path_group_policy (struct tomoyo_io_buffer * head );
612+ /* Read "number_group" entry in exception policy. */
613+ bool tomoyo_read_number_group_policy (struct tomoyo_io_buffer * head );
573614/* Read "allow_read" entry in exception policy. */
574615bool tomoyo_read_globally_readable_policy (struct tomoyo_io_buffer * head );
575616/* Read "deny_rewrite" entry in exception policy. */
@@ -614,6 +655,8 @@ int tomoyo_write_no_rewrite_policy(char *data, const bool is_delete);
614655int tomoyo_write_pattern_policy (char * data , const bool is_delete );
615656/* Create "path_group" entry in exception policy. */
616657int tomoyo_write_path_group_policy (char * data , const bool is_delete );
658+ /* Create "number_group" entry in exception policy. */
659+ int tomoyo_write_number_group_policy (char * data , const bool is_delete );
617660/* Find a domain by the given name. */
618661struct tomoyo_domain_info * tomoyo_find_domain (const char * domainname );
619662/* Find or create a domain by the given name. */
@@ -623,6 +666,7 @@ struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char *
623666
624667/* Allocate memory for "struct tomoyo_path_group". */
625668struct tomoyo_path_group * tomoyo_get_path_group (const char * group_name );
669+ struct tomoyo_number_group * tomoyo_get_number_group (const char * group_name );
626670
627671/* Check mode for specified functionality. */
628672unsigned int tomoyo_check_flags (const struct tomoyo_domain_info * domain ,
@@ -632,6 +676,8 @@ void tomoyo_fill_path_info(struct tomoyo_path_info *ptr);
632676/* Run policy loader when /sbin/init starts. */
633677void tomoyo_load_policy (const char * filename );
634678
679+ void tomoyo_put_number_union (struct tomoyo_number_union * ptr );
680+
635681/* Convert binary string to ascii string. */
636682int tomoyo_encode (char * buffer , int buflen , const char * str );
637683
@@ -697,6 +743,7 @@ extern struct srcu_struct tomoyo_ss;
697743extern struct list_head tomoyo_domain_list ;
698744
699745extern struct list_head tomoyo_path_group_list ;
746+ extern struct list_head tomoyo_number_group_list ;
700747extern struct list_head tomoyo_domain_initializer_list ;
701748extern struct list_head tomoyo_domain_keeper_list ;
702749extern struct list_head tomoyo_alias_list ;
@@ -773,6 +820,12 @@ static inline void tomoyo_put_path_group(struct tomoyo_path_group *group)
773820 atomic_dec (& group -> users );
774821}
775822
823+ static inline void tomoyo_put_number_group (struct tomoyo_number_group * group )
824+ {
825+ if (group )
826+ atomic_dec (& group -> users );
827+ }
828+
776829static inline struct tomoyo_domain_info * tomoyo_domain (void )
777830{
778831 return current_cred ()-> security ;
@@ -797,6 +850,14 @@ static inline bool tomoyo_is_same_name_union
797850 p1 -> is_group == p2 -> is_group ;
798851}
799852
853+ static inline bool tomoyo_is_same_number_union
854+ (const struct tomoyo_number_union * p1 , const struct tomoyo_number_union * p2 )
855+ {
856+ return p1 -> values [0 ] == p2 -> values [0 ] && p1 -> values [1 ] == p2 -> values [1 ]
857+ && p1 -> group == p2 -> group && p1 -> min_type == p2 -> min_type &&
858+ p1 -> max_type == p2 -> max_type && p1 -> is_group == p2 -> is_group ;
859+ }
860+
800861static inline bool tomoyo_is_same_path_acl (const struct tomoyo_path_acl * p1 ,
801862 const struct tomoyo_path_acl * p2 )
802863{
0 commit comments