#include <linux/kthread.h>
#include <linux/slab.h>
-struct tomoyo_gc_entry {
+struct tomoyo_gc {
struct list_head list;
int type;
struct list_head *element;
/* Caller holds tomoyo_policy_lock mutex. */
static bool tomoyo_add_to_gc(const int type, struct list_head *element)
{
- struct tomoyo_gc_entry *entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ struct tomoyo_gc *entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry)
return false;
entry->type = type;
static void tomoyo_del_allow_read(struct list_head *element)
{
- struct tomoyo_globally_readable_file_entry *ptr =
+ struct tomoyo_readable_file *ptr =
container_of(element, typeof(*ptr), head.list);
tomoyo_put_name(ptr->filename);
}
static void tomoyo_del_file_pattern(struct list_head *element)
{
- struct tomoyo_pattern_entry *ptr =
+ struct tomoyo_no_pattern *ptr =
container_of(element, typeof(*ptr), head.list);
tomoyo_put_name(ptr->pattern);
}
static void tomoyo_del_no_rewrite(struct list_head *element)
{
- struct tomoyo_no_rewrite_entry *ptr =
+ struct tomoyo_no_rewrite *ptr =
container_of(element, typeof(*ptr), head.list);
tomoyo_put_name(ptr->pattern);
}
-static void tomoyo_del_domain_initializer(struct list_head *element)
+static void tomoyo_del_transition_control(struct list_head *element)
{
- struct tomoyo_domain_initializer_entry *ptr =
- container_of(element, typeof(*ptr), head.list);
- tomoyo_put_name(ptr->domainname);
- tomoyo_put_name(ptr->program);
-}
-
-static void tomoyo_del_domain_keeper(struct list_head *element)
-{
- struct tomoyo_domain_keeper_entry *ptr =
+ struct tomoyo_transition_control *ptr =
container_of(element, typeof(*ptr), head.list);
tomoyo_put_name(ptr->domainname);
tomoyo_put_name(ptr->program);
static void tomoyo_del_aggregator(struct list_head *element)
{
- struct tomoyo_aggregator_entry *ptr =
+ struct tomoyo_aggregator *ptr =
container_of(element, typeof(*ptr), head.list);
tomoyo_put_name(ptr->original_name);
tomoyo_put_name(ptr->aggregated_name);
}
-static void tomoyo_del_alias(struct list_head *element)
-{
- struct tomoyo_alias_entry *ptr =
- container_of(element, typeof(*ptr), head.list);
- tomoyo_put_name(ptr->original_name);
- tomoyo_put_name(ptr->aliased_name);
-}
-
static void tomoyo_del_manager(struct list_head *element)
{
- struct tomoyo_policy_manager_entry *ptr =
+ struct tomoyo_manager *ptr =
container_of(element, typeof(*ptr), head.list);
tomoyo_put_name(ptr->manager);
}
static void tomoyo_del_name(struct list_head *element)
{
- const struct tomoyo_name_entry *ptr =
+ const struct tomoyo_name *ptr =
container_of(element, typeof(*ptr), list);
}
}
}
for (i = 0; i < TOMOYO_MAX_HASH; i++) {
- struct tomoyo_name_entry *ptr;
+ struct tomoyo_name *ptr;
list_for_each_entry_rcu(ptr, &tomoyo_name_list[i], list) {
if (atomic_read(&ptr->users))
continue;
goto unlock;
}
}
- {
+ for (i = 0; i < TOMOYO_MAX_GROUP; i++) {
+ struct list_head *list = &tomoyo_group_list[i];
+ int id;
struct tomoyo_group *group;
- list_for_each_entry_rcu(group,
- &tomoyo_group_list[TOMOYO_PATH_GROUP],
- list) {
- tomoyo_collect_member(&group->member_list,
- TOMOYO_ID_PATH_GROUP);
- if (!list_empty(&group->member_list) ||
- atomic_read(&group->users))
- continue;
- if (!tomoyo_add_to_gc(TOMOYO_ID_GROUP,
- &group->list))
- goto unlock;
+ switch (i) {
+ case 0:
+ id = TOMOYO_ID_PATH_GROUP;
+ break;
+ default:
+ id = TOMOYO_ID_NUMBER_GROUP;
+ break;
}
- }
- {
- struct tomoyo_group *group;
- list_for_each_entry_rcu(group,
- &tomoyo_group_list[TOMOYO_NUMBER_GROUP],
- list) {
- tomoyo_collect_member(&group->member_list,
- TOMOYO_ID_NUMBER_GROUP);
+ list_for_each_entry(group, list, list) {
+ if (!tomoyo_collect_member(&group->member_list, id))
+ goto unlock;
if (!list_empty(&group->member_list) ||
atomic_read(&group->users))
continue;
- if (!tomoyo_add_to_gc(TOMOYO_ID_GROUP,
- &group->list))
+ if (!tomoyo_add_to_gc(TOMOYO_ID_GROUP, &group->list))
goto unlock;
}
}
static void tomoyo_kfree_entry(void)
{
- struct tomoyo_gc_entry *p;
- struct tomoyo_gc_entry *tmp;
+ struct tomoyo_gc *p;
+ struct tomoyo_gc *tmp;
list_for_each_entry_safe(p, tmp, &tomoyo_gc_queue, list) {
struct list_head *element = p->element;
switch (p->type) {
- case TOMOYO_ID_DOMAIN_INITIALIZER:
- tomoyo_del_domain_initializer(element);
- break;
- case TOMOYO_ID_DOMAIN_KEEPER:
- tomoyo_del_domain_keeper(element);
+ case TOMOYO_ID_TRANSITION_CONTROL:
+ tomoyo_del_transition_control(element);
break;
case TOMOYO_ID_AGGREGATOR:
tomoyo_del_aggregator(element);
break;
- case TOMOYO_ID_ALIAS:
- tomoyo_del_alias(element);
- break;
case TOMOYO_ID_GLOBALLY_READABLE:
tomoyo_del_allow_read(element);
break;