diff options
Diffstat (limited to 'security/tomoyo/gc.c')
| -rw-r--r-- | security/tomoyo/gc.c | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/security/tomoyo/gc.c b/security/tomoyo/gc.c index d9ad35bc7fa8..b9cc71b04314 100644 --- a/security/tomoyo/gc.c +++ b/security/tomoyo/gc.c | |||
| @@ -12,6 +12,8 @@ | |||
| 12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
| 13 | 13 | ||
| 14 | enum tomoyo_gc_id { | 14 | enum tomoyo_gc_id { |
| 15 | TOMOYO_ID_PATH_GROUP, | ||
| 16 | TOMOYO_ID_PATH_GROUP_MEMBER, | ||
| 15 | TOMOYO_ID_DOMAIN_INITIALIZER, | 17 | TOMOYO_ID_DOMAIN_INITIALIZER, |
| 16 | TOMOYO_ID_DOMAIN_KEEPER, | 18 | TOMOYO_ID_DOMAIN_KEEPER, |
| 17 | TOMOYO_ID_ALIAS, | 19 | TOMOYO_ID_ALIAS, |
| @@ -91,15 +93,15 @@ static void tomoyo_del_acl(struct tomoyo_acl_info *acl) | |||
| 91 | { | 93 | { |
| 92 | struct tomoyo_path_acl *entry | 94 | struct tomoyo_path_acl *entry |
| 93 | = container_of(acl, typeof(*entry), head); | 95 | = container_of(acl, typeof(*entry), head); |
| 94 | tomoyo_put_name(entry->filename); | 96 | tomoyo_put_name_union(&entry->name); |
| 95 | } | 97 | } |
| 96 | break; | 98 | break; |
| 97 | case TOMOYO_TYPE_PATH2_ACL: | 99 | case TOMOYO_TYPE_PATH2_ACL: |
| 98 | { | 100 | { |
| 99 | struct tomoyo_path2_acl *entry | 101 | struct tomoyo_path2_acl *entry |
| 100 | = container_of(acl, typeof(*entry), head); | 102 | = container_of(acl, typeof(*entry), head); |
| 101 | tomoyo_put_name(entry->filename1); | 103 | tomoyo_put_name_union(&entry->name1); |
| 102 | tomoyo_put_name(entry->filename2); | 104 | tomoyo_put_name_union(&entry->name2); |
| 103 | } | 105 | } |
| 104 | break; | 106 | break; |
| 105 | default: | 107 | default: |
| @@ -149,9 +151,21 @@ static void tomoyo_del_name(const struct tomoyo_name_entry *ptr) | |||
| 149 | { | 151 | { |
| 150 | } | 152 | } |
| 151 | 153 | ||
| 154 | static void tomoyo_del_path_group_member(struct tomoyo_path_group_member | ||
| 155 | *member) | ||
| 156 | { | ||
| 157 | tomoyo_put_name(member->member_name); | ||
| 158 | } | ||
| 159 | |||
| 160 | static void tomoyo_del_path_group(struct tomoyo_path_group *group) | ||
| 161 | { | ||
| 162 | tomoyo_put_name(group->group_name); | ||
| 163 | } | ||
| 164 | |||
| 152 | static void tomoyo_collect_entry(void) | 165 | static void tomoyo_collect_entry(void) |
| 153 | { | 166 | { |
| 154 | mutex_lock(&tomoyo_policy_lock); | 167 | if (mutex_lock_interruptible(&tomoyo_policy_lock)) |
| 168 | return; | ||
| 155 | { | 169 | { |
| 156 | struct tomoyo_globally_readable_file_entry *ptr; | 170 | struct tomoyo_globally_readable_file_entry *ptr; |
| 157 | list_for_each_entry_rcu(ptr, &tomoyo_globally_readable_list, | 171 | list_for_each_entry_rcu(ptr, &tomoyo_globally_readable_list, |
| @@ -275,8 +289,6 @@ static void tomoyo_collect_entry(void) | |||
| 275 | break; | 289 | break; |
| 276 | } | 290 | } |
| 277 | } | 291 | } |
| 278 | mutex_unlock(&tomoyo_policy_lock); | ||
| 279 | mutex_lock(&tomoyo_name_list_lock); | ||
| 280 | { | 292 | { |
| 281 | int i; | 293 | int i; |
| 282 | for (i = 0; i < TOMOYO_MAX_HASH; i++) { | 294 | for (i = 0; i < TOMOYO_MAX_HASH; i++) { |
| @@ -294,7 +306,30 @@ static void tomoyo_collect_entry(void) | |||
| 294 | } | 306 | } |
| 295 | } | 307 | } |
| 296 | } | 308 | } |
| 297 | mutex_unlock(&tomoyo_name_list_lock); | 309 | { |
| 310 | struct tomoyo_path_group *group; | ||
| 311 | list_for_each_entry_rcu(group, &tomoyo_path_group_list, list) { | ||
| 312 | struct tomoyo_path_group_member *member; | ||
| 313 | list_for_each_entry_rcu(member, &group->member_list, | ||
| 314 | list) { | ||
| 315 | if (!member->is_deleted) | ||
| 316 | continue; | ||
| 317 | if (tomoyo_add_to_gc(TOMOYO_ID_PATH_GROUP_MEMBER, | ||
| 318 | member)) | ||
| 319 | list_del_rcu(&member->list); | ||
| 320 | else | ||
| 321 | break; | ||
| 322 | } | ||
| 323 | if (!list_empty(&group->member_list) || | ||
| 324 | atomic_read(&group->users)) | ||
| 325 | continue; | ||
| 326 | if (tomoyo_add_to_gc(TOMOYO_ID_PATH_GROUP, group)) | ||
| 327 | list_del_rcu(&group->list); | ||
| 328 | else | ||
| 329 | break; | ||
| 330 | } | ||
| 331 | } | ||
| 332 | mutex_unlock(&tomoyo_policy_lock); | ||
| 298 | } | 333 | } |
| 299 | 334 | ||
| 300 | static void tomoyo_kfree_entry(void) | 335 | static void tomoyo_kfree_entry(void) |
| @@ -335,6 +370,12 @@ static void tomoyo_kfree_entry(void) | |||
| 335 | if (!tomoyo_del_domain(p->element)) | 370 | if (!tomoyo_del_domain(p->element)) |
| 336 | continue; | 371 | continue; |
| 337 | break; | 372 | break; |
| 373 | case TOMOYO_ID_PATH_GROUP_MEMBER: | ||
| 374 | tomoyo_del_path_group_member(p->element); | ||
| 375 | break; | ||
| 376 | case TOMOYO_ID_PATH_GROUP: | ||
| 377 | tomoyo_del_path_group(p->element); | ||
| 378 | break; | ||
| 338 | default: | 379 | default: |
| 339 | printk(KERN_WARNING "Unknown type\n"); | 380 | printk(KERN_WARNING "Unknown type\n"); |
| 340 | break; | 381 | break; |
