aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/domain.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/tomoyo/domain.c')
-rw-r--r--security/tomoyo/domain.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/security/tomoyo/domain.c b/security/tomoyo/domain.c
index cb5d2b05c244..af5f325e2f33 100644
--- a/security/tomoyo/domain.c
+++ b/security/tomoyo/domain.c
@@ -12,6 +12,9 @@
12 12
13/* Variables definitions.*/ 13/* Variables definitions.*/
14 14
15/* The global ACL referred by "use_group" keyword. */
16struct list_head tomoyo_acl_group[TOMOYO_MAX_ACL_GROUPS];
17
15/* The initial domain. */ 18/* The initial domain. */
16struct tomoyo_domain_info tomoyo_kernel_domain; 19struct tomoyo_domain_info tomoyo_kernel_domain;
17 20
@@ -125,14 +128,27 @@ int tomoyo_update_domain(struct tomoyo_acl_info *new_entry, const int size,
125 return error; 128 return error;
126} 129}
127 130
131/**
132 * tomoyo_check_acl - Do permission check.
133 *
134 * @r: Pointer to "struct tomoyo_request_info".
135 * @check_entry: Callback function to check type specific parameters.
136 *
137 * Returns 0 on success, negative value otherwise.
138 *
139 * Caller holds tomoyo_read_lock().
140 */
128void tomoyo_check_acl(struct tomoyo_request_info *r, 141void tomoyo_check_acl(struct tomoyo_request_info *r,
129 bool (*check_entry) (struct tomoyo_request_info *, 142 bool (*check_entry) (struct tomoyo_request_info *,
130 const struct tomoyo_acl_info *)) 143 const struct tomoyo_acl_info *))
131{ 144{
132 const struct tomoyo_domain_info *domain = r->domain; 145 const struct tomoyo_domain_info *domain = r->domain;
133 struct tomoyo_acl_info *ptr; 146 struct tomoyo_acl_info *ptr;
147 bool retried = false;
148 const struct list_head *list = &domain->acl_info_list;
134 149
135 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) { 150retry:
151 list_for_each_entry_rcu(ptr, list, list) {
136 if (ptr->is_deleted || ptr->type != r->param_type) 152 if (ptr->is_deleted || ptr->type != r->param_type)
137 continue; 153 continue;
138 if (check_entry(r, ptr)) { 154 if (check_entry(r, ptr)) {
@@ -140,6 +156,11 @@ void tomoyo_check_acl(struct tomoyo_request_info *r,
140 return; 156 return;
141 } 157 }
142 } 158 }
159 if (!retried) {
160 retried = true;
161 list = &tomoyo_acl_group[domain->group];
162 goto retry;
163 }
143 r->granted = false; 164 r->granted = false;
144} 165}
145 166