Skip to content

Commit a230f9e

Browse files
Tetsuo Handaxjamesmorris
authored andcommitted
TOMOYO: Use array of "struct list_head".
Assign list id and make the lists as array of "struct list_head". Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
1 parent a98aa4d commit a230f9e

8 files changed

Lines changed: 98 additions & 383 deletions

File tree

‎security/tomoyo/common.c‎

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -434,38 +434,6 @@ static void tomoyo_read_profile(struct tomoyo_io_buffer *head)
434434
head->read_eof = true;
435435
}
436436

437-
/*
438-
* tomoyo_policy_manager_list is used for holding list of domainnames or
439-
* programs which are permitted to modify configuration via
440-
* /sys/kernel/security/tomoyo/ interface.
441-
*
442-
* An entry is added by
443-
*
444-
* # echo '<kernel> /sbin/mingetty /bin/login /bin/bash' > \
445-
* /sys/kernel/security/tomoyo/manager
446-
* (if you want to specify by a domainname)
447-
*
448-
* or
449-
*
450-
* # echo '/usr/sbin/tomoyo-editpolicy' > /sys/kernel/security/tomoyo/manager
451-
* (if you want to specify by a program's location)
452-
*
453-
* and is deleted by
454-
*
455-
* # echo 'delete <kernel> /sbin/mingetty /bin/login /bin/bash' > \
456-
* /sys/kernel/security/tomoyo/manager
457-
*
458-
* or
459-
*
460-
* # echo 'delete /usr/sbin/tomoyo-editpolicy' > \
461-
* /sys/kernel/security/tomoyo/manager
462-
*
463-
* and all entries are retrieved by
464-
*
465-
* # cat /sys/kernel/security/tomoyo/manager
466-
*/
467-
LIST_HEAD(tomoyo_policy_manager_list);
468-
469437
static bool tomoyo_same_manager_entry(const struct tomoyo_acl_head *a,
470438
const struct tomoyo_acl_head *b)
471439
{
@@ -503,7 +471,7 @@ static int tomoyo_update_manager_entry(const char *manager,
503471
if (!e.manager)
504472
return -ENOMEM;
505473
error = tomoyo_update_policy(&e.head, sizeof(e), is_delete,
506-
&tomoyo_policy_manager_list,
474+
&tomoyo_policy_list[TOMOYO_ID_MANAGER],
507475
tomoyo_same_manager_entry);
508476
tomoyo_put_name(e.manager);
509477
return error;
@@ -545,7 +513,7 @@ static void tomoyo_read_manager_policy(struct tomoyo_io_buffer *head)
545513
if (head->read_eof)
546514
return;
547515
list_for_each_cookie(pos, head->read_var2,
548-
&tomoyo_policy_manager_list) {
516+
&tomoyo_policy_list[TOMOYO_ID_MANAGER]) {
549517
struct tomoyo_policy_manager_entry *ptr;
550518
ptr = list_entry(pos, struct tomoyo_policy_manager_entry,
551519
head.list);
@@ -578,7 +546,8 @@ static bool tomoyo_policy_manager(void)
578546
return true;
579547
if (!tomoyo_manage_by_non_root && (task->cred->uid || task->cred->euid))
580548
return false;
581-
list_for_each_entry_rcu(ptr, &tomoyo_policy_manager_list, head.list) {
549+
list_for_each_entry_rcu(ptr, &tomoyo_policy_list[TOMOYO_ID_MANAGER],
550+
head.list) {
582551
if (!ptr->head.is_deleted && ptr->is_domain
583552
&& !tomoyo_pathcmp(domainname, ptr->manager)) {
584553
found = true;
@@ -590,7 +559,8 @@ static bool tomoyo_policy_manager(void)
590559
exe = tomoyo_get_exe();
591560
if (!exe)
592561
return false;
593-
list_for_each_entry_rcu(ptr, &tomoyo_policy_manager_list, head.list) {
562+
list_for_each_entry_rcu(ptr, &tomoyo_policy_list[TOMOYO_ID_MANAGER],
563+
head.list) {
594564
if (!ptr->head.is_deleted && !ptr->is_domain
595565
&& !strcmp(exe, ptr->manager->name)) {
596566
found = true;

‎security/tomoyo/common.h‎

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,30 @@ enum tomoyo_mode_index {
4646
TOMOYO_CONFIG_USE_DEFAULT = 255
4747
};
4848

49+
enum tomoyo_policy_id {
50+
TOMOYO_ID_GROUP,
51+
TOMOYO_ID_PATH_GROUP,
52+
TOMOYO_ID_NUMBER_GROUP,
53+
TOMOYO_ID_DOMAIN_INITIALIZER,
54+
TOMOYO_ID_DOMAIN_KEEPER,
55+
TOMOYO_ID_AGGREGATOR,
56+
TOMOYO_ID_ALIAS,
57+
TOMOYO_ID_GLOBALLY_READABLE,
58+
TOMOYO_ID_PATTERN,
59+
TOMOYO_ID_NO_REWRITE,
60+
TOMOYO_ID_MANAGER,
61+
TOMOYO_ID_NAME,
62+
TOMOYO_ID_ACL,
63+
TOMOYO_ID_DOMAIN,
64+
TOMOYO_MAX_POLICY
65+
};
66+
67+
enum tomoyo_group_id {
68+
TOMOYO_PATH_GROUP,
69+
TOMOYO_NUMBER_GROUP,
70+
TOMOYO_MAX_GROUP
71+
};
72+
4973
/* Keywords for ACLs. */
5074
#define TOMOYO_KEYWORD_AGGREGATOR "aggregator "
5175
#define TOMOYO_KEYWORD_ALIAS "alias "
@@ -570,7 +594,7 @@ struct tomoyo_globally_readable_file_entry {
570594

571595
/*
572596
* tomoyo_pattern_entry is a structure which is used for holding
573-
* "tomoyo_pattern_list" entries.
597+
* "file_pattern" entries.
574598
* It has following fields.
575599
*
576600
* (1) "head" is "struct tomoyo_acl_head".
@@ -950,16 +974,8 @@ extern struct srcu_struct tomoyo_ss;
950974
/* The list for "struct tomoyo_domain_info". */
951975
extern struct list_head tomoyo_domain_list;
952976

953-
extern struct list_head tomoyo_path_group_list;
954-
extern struct list_head tomoyo_number_group_list;
955-
extern struct list_head tomoyo_domain_initializer_list;
956-
extern struct list_head tomoyo_domain_keeper_list;
957-
extern struct list_head tomoyo_aggregator_list;
958-
extern struct list_head tomoyo_alias_list;
959-
extern struct list_head tomoyo_globally_readable_list;
960-
extern struct list_head tomoyo_pattern_list;
961-
extern struct list_head tomoyo_no_rewrite_list;
962-
extern struct list_head tomoyo_policy_manager_list;
977+
extern struct list_head tomoyo_policy_list[TOMOYO_MAX_POLICY];
978+
extern struct list_head tomoyo_group_list[TOMOYO_MAX_GROUP];
963979
extern struct list_head tomoyo_name_list[TOMOYO_MAX_HASH];
964980

965981
/* Lock for protecting policy. */

0 commit comments

Comments
 (0)