mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
TOMOYO: Simplify garbage collector.
When TOMOYO started using garbage collector at commit847b173e"TOMOYO: Add garbage collector.", we waited for close() before kfree(). Thus, elements to be kfree()d were queued up using tomoyo_gc_list list. But it turned out that tomoyo_element_linked_by_gc() tends to choke garbage collector when certain pattern of entries are queued. Since garbage collector is no longer waiting for close() since commit2e503bbb"TOMOYO: Fix lockdep warning.", we can remove tomoyo_gc_list list and tomoyo_element_linked_by_gc() by doing sequential processing. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
committed by
James Morris
parent
778c4a4d60
commit
f9732ea145
@@ -52,6 +52,9 @@
|
||||
|
||||
#define TOMOYO_EXEC_TMPSIZE 4096
|
||||
|
||||
/* Garbage collector is trying to kfree() this element. */
|
||||
#define TOMOYO_GC_IN_PROGRESS -1
|
||||
|
||||
/* Profile number is an integer between 0 and 255. */
|
||||
#define TOMOYO_MAX_PROFILES 256
|
||||
|
||||
@@ -398,7 +401,7 @@ enum tomoyo_pref_index {
|
||||
/* Common header for holding ACL entries. */
|
||||
struct tomoyo_acl_head {
|
||||
struct list_head list;
|
||||
bool is_deleted;
|
||||
s8 is_deleted; /* true or false or TOMOYO_GC_IN_PROGRESS */
|
||||
} __packed;
|
||||
|
||||
/* Common header for shared entries. */
|
||||
@@ -665,7 +668,7 @@ struct tomoyo_condition {
|
||||
struct tomoyo_acl_info {
|
||||
struct list_head list;
|
||||
struct tomoyo_condition *cond; /* Maybe NULL. */
|
||||
bool is_deleted;
|
||||
s8 is_deleted; /* true or false or TOMOYO_GC_IN_PROGRESS */
|
||||
u8 type; /* One of values in "enum tomoyo_acl_entry_type_index". */
|
||||
} __packed;
|
||||
|
||||
|
||||
@@ -400,8 +400,9 @@ static struct tomoyo_condition *tomoyo_commit_condition
|
||||
found = true;
|
||||
goto out;
|
||||
}
|
||||
list_for_each_entry_rcu(ptr, &tomoyo_condition_list, head.list) {
|
||||
if (!tomoyo_same_condition(ptr, entry))
|
||||
list_for_each_entry(ptr, &tomoyo_condition_list, head.list) {
|
||||
if (!tomoyo_same_condition(ptr, entry) ||
|
||||
atomic_read(&ptr->head.users) == TOMOYO_GC_IN_PROGRESS)
|
||||
continue;
|
||||
/* Same entry found. Share this entry. */
|
||||
atomic_inc(&ptr->head.users);
|
||||
@@ -411,8 +412,7 @@ static struct tomoyo_condition *tomoyo_commit_condition
|
||||
if (!found) {
|
||||
if (tomoyo_memory_ok(entry)) {
|
||||
atomic_set(&entry->head.users, 1);
|
||||
list_add_rcu(&entry->head.list,
|
||||
&tomoyo_condition_list);
|
||||
list_add(&entry->head.list, &tomoyo_condition_list);
|
||||
} else {
|
||||
found = true;
|
||||
ptr = NULL;
|
||||
|
||||
@@ -39,6 +39,8 @@ int tomoyo_update_policy(struct tomoyo_acl_head *new_entry, const int size,
|
||||
if (mutex_lock_interruptible(&tomoyo_policy_lock))
|
||||
return -ENOMEM;
|
||||
list_for_each_entry_rcu(entry, list, list) {
|
||||
if (entry->is_deleted == TOMOYO_GC_IN_PROGRESS)
|
||||
continue;
|
||||
if (!check_duplicate(entry, new_entry))
|
||||
continue;
|
||||
entry->is_deleted = param->is_delete;
|
||||
@@ -115,6 +117,8 @@ int tomoyo_update_domain(struct tomoyo_acl_info *new_entry, const int size,
|
||||
if (mutex_lock_interruptible(&tomoyo_policy_lock))
|
||||
goto out;
|
||||
list_for_each_entry_rcu(entry, list, list) {
|
||||
if (entry->is_deleted == TOMOYO_GC_IN_PROGRESS)
|
||||
continue;
|
||||
if (!tomoyo_same_acl_head(entry, new_entry) ||
|
||||
!check_duplicate(entry, new_entry))
|
||||
continue;
|
||||
|
||||
+169
-311
File diff suppressed because it is too large
Load Diff
@@ -123,7 +123,8 @@ struct tomoyo_group *tomoyo_get_group(struct tomoyo_acl_param *param,
|
||||
goto out;
|
||||
list = ¶m->ns->group_list[idx];
|
||||
list_for_each_entry(group, list, head.list) {
|
||||
if (e.group_name != group->group_name)
|
||||
if (e.group_name != group->group_name ||
|
||||
atomic_read(&group->head.users) == TOMOYO_GC_IN_PROGRESS)
|
||||
continue;
|
||||
atomic_inc(&group->head.users);
|
||||
found = true;
|
||||
@@ -175,7 +176,8 @@ const struct tomoyo_path_info *tomoyo_get_name(const char *name)
|
||||
if (mutex_lock_interruptible(&tomoyo_policy_lock))
|
||||
return NULL;
|
||||
list_for_each_entry(ptr, head, head.list) {
|
||||
if (hash != ptr->entry.hash || strcmp(name, ptr->entry.name))
|
||||
if (hash != ptr->entry.hash || strcmp(name, ptr->entry.name) ||
|
||||
atomic_read(&ptr->head.users) == TOMOYO_GC_IN_PROGRESS)
|
||||
continue;
|
||||
atomic_inc(&ptr->head.users);
|
||||
goto out;
|
||||
|
||||
Reference in New Issue
Block a user