2010-02-11 00:43:54 +00:00
|
|
|
/*
|
|
|
|
* security/tomoyo/gc.c
|
|
|
|
*
|
|
|
|
* Implementation of the Domain-Based Mandatory Access Control.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005-2010 NTT DATA CORPORATION
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include <linux/kthread.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2010-02-11 00:43:54 +00:00
|
|
|
|
|
|
|
struct tomoyo_gc_entry {
|
|
|
|
struct list_head list;
|
|
|
|
int type;
|
2010-06-16 07:31:50 +00:00
|
|
|
struct list_head *element;
|
2010-02-11 00:43:54 +00:00
|
|
|
};
|
|
|
|
static LIST_HEAD(tomoyo_gc_queue);
|
|
|
|
static DEFINE_MUTEX(tomoyo_gc_mutex);
|
|
|
|
|
|
|
|
/* Caller holds tomoyo_policy_lock mutex. */
|
2010-06-16 07:31:50 +00:00
|
|
|
static bool tomoyo_add_to_gc(const int type, struct list_head *element)
|
2010-02-11 00:43:54 +00:00
|
|
|
{
|
|
|
|
struct tomoyo_gc_entry *entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
|
|
|
|
if (!entry)
|
|
|
|
return false;
|
|
|
|
entry->type = type;
|
|
|
|
entry->element = element;
|
|
|
|
list_add(&entry->list, &tomoyo_gc_queue);
|
2010-06-16 07:31:50 +00:00
|
|
|
list_del_rcu(element);
|
2010-02-11 00:43:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-16 07:31:50 +00:00
|
|
|
static void tomoyo_del_allow_read(struct list_head *element)
|
2010-02-11 00:43:54 +00:00
|
|
|
{
|
2010-06-16 07:31:50 +00:00
|
|
|
struct tomoyo_globally_readable_file_entry *ptr =
|
|
|
|
container_of(element, typeof(*ptr), head.list);
|
2010-02-11 00:43:54 +00:00
|
|
|
tomoyo_put_name(ptr->filename);
|
|
|
|
}
|
|
|
|
|
2010-06-16 07:31:50 +00:00
|
|
|
static void tomoyo_del_file_pattern(struct list_head *element)
|
2010-02-11 00:43:54 +00:00
|
|
|
{
|
2010-06-16 07:31:50 +00:00
|
|
|
struct tomoyo_pattern_entry *ptr =
|
|
|
|
container_of(element, typeof(*ptr), head.list);
|
2010-02-11 00:43:54 +00:00
|
|
|
tomoyo_put_name(ptr->pattern);
|
|
|
|
}
|
|
|
|
|
2010-06-16 07:31:50 +00:00
|
|
|
static void tomoyo_del_no_rewrite(struct list_head *element)
|
2010-02-11 00:43:54 +00:00
|
|
|
{
|
2010-06-16 07:31:50 +00:00
|
|
|
struct tomoyo_no_rewrite_entry *ptr =
|
|
|
|
container_of(element, typeof(*ptr), head.list);
|
2010-02-11 00:43:54 +00:00
|
|
|
tomoyo_put_name(ptr->pattern);
|
|
|
|
}
|
|
|
|
|
2010-06-21 02:14:39 +00:00
|
|
|
static void tomoyo_del_transition_control(struct list_head *element)
|
2010-02-11 00:43:54 +00:00
|
|
|
{
|
2010-06-21 02:14:39 +00:00
|
|
|
struct tomoyo_transition_control *ptr =
|
2010-06-16 07:31:50 +00:00
|
|
|
container_of(element, typeof(*ptr), head.list);
|
2010-02-11 00:43:54 +00:00
|
|
|
tomoyo_put_name(ptr->domainname);
|
|
|
|
tomoyo_put_name(ptr->program);
|
|
|
|
}
|
|
|
|
|
2010-06-16 07:31:50 +00:00
|
|
|
static void tomoyo_del_aggregator(struct list_head *element)
|
2010-06-03 11:38:03 +00:00
|
|
|
{
|
2010-06-16 07:31:50 +00:00
|
|
|
struct tomoyo_aggregator_entry *ptr =
|
|
|
|
container_of(element, typeof(*ptr), head.list);
|
2010-06-03 11:38:03 +00:00
|
|
|
tomoyo_put_name(ptr->original_name);
|
|
|
|
tomoyo_put_name(ptr->aggregated_name);
|
|
|
|
}
|
|
|
|
|
2010-06-16 07:31:50 +00:00
|
|
|
static void tomoyo_del_manager(struct list_head *element)
|
2010-02-11 00:43:54 +00:00
|
|
|
{
|
2010-06-16 07:31:50 +00:00
|
|
|
struct tomoyo_policy_manager_entry *ptr =
|
|
|
|
container_of(element, typeof(*ptr), head.list);
|
2010-02-11 00:43:54 +00:00
|
|
|
tomoyo_put_name(ptr->manager);
|
|
|
|
}
|
|
|
|
|
2010-06-16 07:31:50 +00:00
|
|
|
static void tomoyo_del_acl(struct list_head *element)
|
2010-02-11 00:43:54 +00:00
|
|
|
{
|
2010-06-16 07:31:50 +00:00
|
|
|
struct tomoyo_acl_info *acl =
|
|
|
|
container_of(element, typeof(*acl), list);
|
2010-02-11 00:43:54 +00:00
|
|
|
switch (acl->type) {
|
2010-02-15 23:03:30 +00:00
|
|
|
case TOMOYO_TYPE_PATH_ACL:
|
2010-02-11 00:43:54 +00:00
|
|
|
{
|
2010-02-15 23:03:30 +00:00
|
|
|
struct tomoyo_path_acl *entry
|
2010-02-11 00:43:54 +00:00
|
|
|
= container_of(acl, typeof(*entry), head);
|
2010-05-10 08:30:26 +00:00
|
|
|
tomoyo_put_name_union(&entry->name);
|
2010-02-11 00:43:54 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-02-15 23:03:30 +00:00
|
|
|
case TOMOYO_TYPE_PATH2_ACL:
|
2010-02-11 00:43:54 +00:00
|
|
|
{
|
2010-02-15 23:03:30 +00:00
|
|
|
struct tomoyo_path2_acl *entry
|
2010-02-11 00:43:54 +00:00
|
|
|
= container_of(acl, typeof(*entry), head);
|
2010-05-10 08:30:26 +00:00
|
|
|
tomoyo_put_name_union(&entry->name1);
|
|
|
|
tomoyo_put_name_union(&entry->name2);
|
2010-02-11 00:43:54 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-05-17 01:09:15 +00:00
|
|
|
case TOMOYO_TYPE_PATH_NUMBER_ACL:
|
|
|
|
{
|
|
|
|
struct tomoyo_path_number_acl *entry
|
|
|
|
= container_of(acl, typeof(*entry), head);
|
|
|
|
tomoyo_put_name_union(&entry->name);
|
|
|
|
tomoyo_put_number_union(&entry->number);
|
|
|
|
}
|
|
|
|
break;
|
2010-06-16 07:23:55 +00:00
|
|
|
case TOMOYO_TYPE_MKDEV_ACL:
|
2010-05-17 01:09:15 +00:00
|
|
|
{
|
2010-06-16 07:23:55 +00:00
|
|
|
struct tomoyo_mkdev_acl *entry
|
2010-05-17 01:09:15 +00:00
|
|
|
= container_of(acl, typeof(*entry), head);
|
|
|
|
tomoyo_put_name_union(&entry->name);
|
|
|
|
tomoyo_put_number_union(&entry->mode);
|
|
|
|
tomoyo_put_number_union(&entry->major);
|
|
|
|
tomoyo_put_number_union(&entry->minor);
|
|
|
|
}
|
|
|
|
break;
|
2010-05-17 01:10:31 +00:00
|
|
|
case TOMOYO_TYPE_MOUNT_ACL:
|
|
|
|
{
|
|
|
|
struct tomoyo_mount_acl *entry
|
|
|
|
= container_of(acl, typeof(*entry), head);
|
|
|
|
tomoyo_put_name_union(&entry->dev_name);
|
|
|
|
tomoyo_put_name_union(&entry->dir_name);
|
|
|
|
tomoyo_put_name_union(&entry->fs_type);
|
|
|
|
tomoyo_put_number_union(&entry->flags);
|
|
|
|
}
|
|
|
|
break;
|
2010-02-11 00:43:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-16 07:31:50 +00:00
|
|
|
static bool tomoyo_del_domain(struct list_head *element)
|
2010-02-11 00:43:54 +00:00
|
|
|
{
|
2010-06-16 07:31:50 +00:00
|
|
|
struct tomoyo_domain_info *domain =
|
|
|
|
container_of(element, typeof(*domain), list);
|
2010-02-11 00:43:54 +00:00
|
|
|
struct tomoyo_acl_info *acl;
|
|
|
|
struct tomoyo_acl_info *tmp;
|
|
|
|
/*
|
|
|
|
* Since we don't protect whole execve() operation using SRCU,
|
|
|
|
* we need to recheck domain->users at this point.
|
|
|
|
*
|
|
|
|
* (1) Reader starts SRCU section upon execve().
|
|
|
|
* (2) Reader traverses tomoyo_domain_list and finds this domain.
|
|
|
|
* (3) Writer marks this domain as deleted.
|
|
|
|
* (4) Garbage collector removes this domain from tomoyo_domain_list
|
|
|
|
* because this domain is marked as deleted and used by nobody.
|
|
|
|
* (5) Reader saves reference to this domain into
|
|
|
|
* "struct linux_binprm"->cred->security .
|
|
|
|
* (6) Reader finishes SRCU section, although execve() operation has
|
|
|
|
* not finished yet.
|
|
|
|
* (7) Garbage collector waits for SRCU synchronization.
|
|
|
|
* (8) Garbage collector kfree() this domain because this domain is
|
|
|
|
* used by nobody.
|
|
|
|
* (9) Reader finishes execve() operation and restores this domain from
|
|
|
|
* "struct linux_binprm"->cred->security.
|
|
|
|
*
|
|
|
|
* By updating domain->users at (5), we can solve this race problem
|
|
|
|
* by rechecking domain->users at (8).
|
|
|
|
*/
|
|
|
|
if (atomic_read(&domain->users))
|
|
|
|
return false;
|
|
|
|
list_for_each_entry_safe(acl, tmp, &domain->acl_info_list, list) {
|
2010-06-16 07:31:50 +00:00
|
|
|
tomoyo_del_acl(&acl->list);
|
2010-02-11 00:43:54 +00:00
|
|
|
tomoyo_memory_free(acl);
|
|
|
|
}
|
|
|
|
tomoyo_put_name(domain->domainname);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-16 07:31:50 +00:00
|
|
|
static void tomoyo_del_name(struct list_head *element)
|
2010-02-11 00:43:54 +00:00
|
|
|
{
|
2010-06-16 07:31:50 +00:00
|
|
|
const struct tomoyo_name_entry *ptr =
|
|
|
|
container_of(element, typeof(*ptr), list);
|
2010-02-11 00:43:54 +00:00
|
|
|
}
|
|
|
|
|
2010-06-17 07:52:29 +00:00
|
|
|
static void tomoyo_del_path_group(struct list_head *element)
|
2010-05-10 08:30:26 +00:00
|
|
|
{
|
2010-06-17 07:52:29 +00:00
|
|
|
struct tomoyo_path_group *member =
|
2010-06-16 07:31:50 +00:00
|
|
|
container_of(element, typeof(*member), head.list);
|
2010-05-10 08:30:26 +00:00
|
|
|
tomoyo_put_name(member->member_name);
|
|
|
|
}
|
|
|
|
|
2010-06-17 07:52:29 +00:00
|
|
|
static void tomoyo_del_group(struct list_head *element)
|
2010-05-10 08:30:26 +00:00
|
|
|
{
|
2010-06-17 07:52:29 +00:00
|
|
|
struct tomoyo_group *group =
|
2010-06-16 07:31:50 +00:00
|
|
|
container_of(element, typeof(*group), list);
|
2010-05-10 08:30:26 +00:00
|
|
|
tomoyo_put_name(group->group_name);
|
|
|
|
}
|
|
|
|
|
2010-06-16 07:31:50 +00:00
|
|
|
static void tomoyo_del_number_group(struct list_head *element)
|
2010-05-17 01:06:58 +00:00
|
|
|
{
|
2010-06-17 07:52:29 +00:00
|
|
|
struct tomoyo_number_group *member =
|
|
|
|
container_of(element, typeof(*member), head.list);
|
2010-05-17 01:06:58 +00:00
|
|
|
}
|
|
|
|
|
2010-06-15 01:10:37 +00:00
|
|
|
static bool tomoyo_collect_member(struct list_head *member_list, int id)
|
|
|
|
{
|
|
|
|
struct tomoyo_acl_head *member;
|
|
|
|
list_for_each_entry(member, member_list, list) {
|
|
|
|
if (!member->is_deleted)
|
|
|
|
continue;
|
|
|
|
if (!tomoyo_add_to_gc(id, &member->list))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool tomoyo_collect_acl(struct tomoyo_domain_info *domain)
|
|
|
|
{
|
|
|
|
struct tomoyo_acl_info *acl;
|
|
|
|
list_for_each_entry(acl, &domain->acl_info_list, list) {
|
|
|
|
if (!acl->is_deleted)
|
|
|
|
continue;
|
|
|
|
if (!tomoyo_add_to_gc(TOMOYO_ID_ACL, &acl->list))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-11 00:43:54 +00:00
|
|
|
static void tomoyo_collect_entry(void)
|
|
|
|
{
|
2010-06-15 01:10:37 +00:00
|
|
|
int i;
|
2010-05-05 15:18:15 +00:00
|
|
|
if (mutex_lock_interruptible(&tomoyo_policy_lock))
|
|
|
|
return;
|
2010-06-15 01:10:37 +00:00
|
|
|
for (i = 0; i < TOMOYO_MAX_POLICY; i++) {
|
2010-06-17 07:53:24 +00:00
|
|
|
if (!tomoyo_collect_member(&tomoyo_policy_list[i], i))
|
|
|
|
goto unlock;
|
2010-02-11 00:43:54 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
struct tomoyo_domain_info *domain;
|
|
|
|
list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) {
|
2010-06-15 01:10:37 +00:00
|
|
|
if (!tomoyo_collect_acl(domain))
|
|
|
|
goto unlock;
|
2010-02-11 00:43:54 +00:00
|
|
|
if (!domain->is_deleted || atomic_read(&domain->users))
|
|
|
|
continue;
|
|
|
|
/*
|
|
|
|
* Nobody is referring this domain. But somebody may
|
|
|
|
* refer this domain after successful execve().
|
|
|
|
* We recheck domain->users after SRCU synchronization.
|
|
|
|
*/
|
2010-06-16 07:31:50 +00:00
|
|
|
if (!tomoyo_add_to_gc(TOMOYO_ID_DOMAIN, &domain->list))
|
2010-06-15 01:10:37 +00:00
|
|
|
goto unlock;
|
2010-02-11 00:43:54 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-15 01:10:37 +00:00
|
|
|
for (i = 0; i < TOMOYO_MAX_HASH; i++) {
|
|
|
|
struct tomoyo_name_entry *ptr;
|
|
|
|
list_for_each_entry_rcu(ptr, &tomoyo_name_list[i], list) {
|
|
|
|
if (atomic_read(&ptr->users))
|
|
|
|
continue;
|
2010-06-16 07:31:50 +00:00
|
|
|
if (!tomoyo_add_to_gc(TOMOYO_ID_NAME, &ptr->list))
|
2010-06-15 01:10:37 +00:00
|
|
|
goto unlock;
|
2010-02-11 00:43:54 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-17 07:55:58 +00:00
|
|
|
for (i = 0; i < TOMOYO_MAX_GROUP; i++) {
|
|
|
|
struct list_head *list = &tomoyo_group_list[i];
|
|
|
|
int id;
|
2010-06-17 07:52:29 +00:00
|
|
|
struct tomoyo_group *group;
|
2010-06-17 07:55:58 +00:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
id = TOMOYO_ID_PATH_GROUP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
id = TOMOYO_ID_NUMBER_GROUP;
|
|
|
|
break;
|
2010-05-10 08:30:26 +00:00
|
|
|
}
|
2010-06-17 07:55:58 +00:00
|
|
|
list_for_each_entry(group, list, list) {
|
|
|
|
if (!tomoyo_collect_member(&group->member_list, id))
|
|
|
|
goto unlock;
|
2010-05-17 01:06:58 +00:00
|
|
|
if (!list_empty(&group->member_list) ||
|
|
|
|
atomic_read(&group->users))
|
|
|
|
continue;
|
2010-06-17 07:55:58 +00:00
|
|
|
if (!tomoyo_add_to_gc(TOMOYO_ID_GROUP, &group->list))
|
2010-06-15 01:10:37 +00:00
|
|
|
goto unlock;
|
2010-05-17 01:06:58 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-15 01:10:37 +00:00
|
|
|
unlock:
|
2010-05-05 15:18:15 +00:00
|
|
|
mutex_unlock(&tomoyo_policy_lock);
|
2010-02-11 00:43:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void tomoyo_kfree_entry(void)
|
|
|
|
{
|
|
|
|
struct tomoyo_gc_entry *p;
|
|
|
|
struct tomoyo_gc_entry *tmp;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(p, tmp, &tomoyo_gc_queue, list) {
|
2010-06-16 07:31:50 +00:00
|
|
|
struct list_head *element = p->element;
|
2010-02-11 00:43:54 +00:00
|
|
|
switch (p->type) {
|
2010-06-21 02:14:39 +00:00
|
|
|
case TOMOYO_ID_TRANSITION_CONTROL:
|
|
|
|
tomoyo_del_transition_control(element);
|
2010-02-11 00:43:54 +00:00
|
|
|
break;
|
2010-06-03 11:38:03 +00:00
|
|
|
case TOMOYO_ID_AGGREGATOR:
|
2010-06-16 07:31:50 +00:00
|
|
|
tomoyo_del_aggregator(element);
|
2010-06-03 11:38:03 +00:00
|
|
|
break;
|
2010-02-11 00:43:54 +00:00
|
|
|
case TOMOYO_ID_GLOBALLY_READABLE:
|
2010-06-16 07:31:50 +00:00
|
|
|
tomoyo_del_allow_read(element);
|
2010-02-11 00:43:54 +00:00
|
|
|
break;
|
|
|
|
case TOMOYO_ID_PATTERN:
|
2010-06-16 07:31:50 +00:00
|
|
|
tomoyo_del_file_pattern(element);
|
2010-02-11 00:43:54 +00:00
|
|
|
break;
|
|
|
|
case TOMOYO_ID_NO_REWRITE:
|
2010-06-16 07:31:50 +00:00
|
|
|
tomoyo_del_no_rewrite(element);
|
2010-02-11 00:43:54 +00:00
|
|
|
break;
|
|
|
|
case TOMOYO_ID_MANAGER:
|
2010-06-16 07:31:50 +00:00
|
|
|
tomoyo_del_manager(element);
|
2010-02-11 00:43:54 +00:00
|
|
|
break;
|
|
|
|
case TOMOYO_ID_NAME:
|
2010-06-16 07:31:50 +00:00
|
|
|
tomoyo_del_name(element);
|
2010-02-11 00:43:54 +00:00
|
|
|
break;
|
|
|
|
case TOMOYO_ID_ACL:
|
2010-06-16 07:31:50 +00:00
|
|
|
tomoyo_del_acl(element);
|
2010-02-11 00:43:54 +00:00
|
|
|
break;
|
|
|
|
case TOMOYO_ID_DOMAIN:
|
2010-06-16 07:31:50 +00:00
|
|
|
if (!tomoyo_del_domain(element))
|
2010-02-11 00:43:54 +00:00
|
|
|
continue;
|
|
|
|
break;
|
2010-05-10 08:30:26 +00:00
|
|
|
case TOMOYO_ID_PATH_GROUP:
|
2010-06-16 07:31:50 +00:00
|
|
|
tomoyo_del_path_group(element);
|
2010-05-10 08:30:26 +00:00
|
|
|
break;
|
2010-06-17 07:52:29 +00:00
|
|
|
case TOMOYO_ID_GROUP:
|
|
|
|
tomoyo_del_group(element);
|
2010-05-17 01:06:58 +00:00
|
|
|
break;
|
|
|
|
case TOMOYO_ID_NUMBER_GROUP:
|
2010-06-16 07:31:50 +00:00
|
|
|
tomoyo_del_number_group(element);
|
2010-02-11 00:43:54 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-06-16 07:31:50 +00:00
|
|
|
tomoyo_memory_free(element);
|
2010-02-11 00:43:54 +00:00
|
|
|
list_del(&p->list);
|
|
|
|
kfree(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tomoyo_gc_thread(void *unused)
|
|
|
|
{
|
|
|
|
daemonize("GC for TOMOYO");
|
|
|
|
if (mutex_trylock(&tomoyo_gc_mutex)) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
tomoyo_collect_entry();
|
|
|
|
if (list_empty(&tomoyo_gc_queue))
|
|
|
|
break;
|
|
|
|
synchronize_srcu(&tomoyo_ss);
|
|
|
|
tomoyo_kfree_entry();
|
|
|
|
}
|
|
|
|
mutex_unlock(&tomoyo_gc_mutex);
|
|
|
|
}
|
|
|
|
do_exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tomoyo_run_gc(void)
|
|
|
|
{
|
|
|
|
struct task_struct *task = kthread_create(tomoyo_gc_thread, NULL,
|
|
|
|
"GC for TOMOYO");
|
|
|
|
if (!IS_ERR(task))
|
|
|
|
wake_up_process(task);
|
|
|
|
}
|