summaryrefslogtreecommitdiffstats
path: root/security/tomoyo/common.c
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2010-06-15 09:23:26 +0900
committerJames Morris <jmorris@namei.org>2010-08-02 15:34:29 +1000
commit36f5e1ffbf2bb951105ae4e261bcc1de3eaf510c (patch)
tree80e01278296477b4d30288081267d35ff771d720 /security/tomoyo/common.c
parent82e0f001a4c1112dcff9cafa9812a33889ad9b8a (diff)
downloadtalos-obmc-linux-36f5e1ffbf2bb951105ae4e261bcc1de3eaf510c.tar.gz
talos-obmc-linux-36f5e1ffbf2bb951105ae4e261bcc1de3eaf510c.zip
TOMOYO: Use callback for updating entries.
Use common code for elements using "struct list_head" + "bool" structure. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/tomoyo/common.c')
-rw-r--r--security/tomoyo/common.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
index 7bfad45fcd61..4ee47af0917d 100644
--- a/security/tomoyo/common.c
+++ b/security/tomoyo/common.c
@@ -469,6 +469,15 @@ static int tomoyo_read_profile(struct tomoyo_io_buffer *head)
*/
LIST_HEAD(tomoyo_policy_manager_list);
+static bool tomoyo_same_manager_entry(const struct tomoyo_acl_head *a,
+ const struct tomoyo_acl_head *b)
+{
+ return container_of(a, struct tomoyo_policy_manager_entry, head)
+ ->manager ==
+ container_of(b, struct tomoyo_policy_manager_entry, head)
+ ->manager;
+}
+
/**
* tomoyo_update_manager_entry - Add a manager entry.
*
@@ -482,9 +491,8 @@ LIST_HEAD(tomoyo_policy_manager_list);
static int tomoyo_update_manager_entry(const char *manager,
const bool is_delete)
{
- struct tomoyo_policy_manager_entry *ptr;
struct tomoyo_policy_manager_entry e = { };
- int error = is_delete ? -ENOENT : -ENOMEM;
+ int error;
if (tomoyo_is_domain_def(manager)) {
if (!tomoyo_is_correct_domain(manager))
@@ -497,26 +505,9 @@ static int tomoyo_update_manager_entry(const char *manager,
e.manager = tomoyo_get_name(manager);
if (!e.manager)
return -ENOMEM;
- if (mutex_lock_interruptible(&tomoyo_policy_lock))
- goto out;
- list_for_each_entry_rcu(ptr, &tomoyo_policy_manager_list, head.list) {
- if (ptr->manager != e.manager)
- continue;
- ptr->head.is_deleted = is_delete;
- error = 0;
- break;
- }
- if (!is_delete && error) {
- struct tomoyo_policy_manager_entry *entry =
- tomoyo_commit_ok(&e, sizeof(e));
- if (entry) {
- list_add_tail_rcu(&entry->head.list,
- &tomoyo_policy_manager_list);
- error = 0;
- }
- }
- mutex_unlock(&tomoyo_policy_lock);
- out:
+ error = tomoyo_update_policy(&e.head, sizeof(e), is_delete,
+ &tomoyo_policy_manager_list,
+ tomoyo_same_manager_entry);
tomoyo_put_name(e.manager);
return error;
}
OpenPOWER on IntegriCloud