aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/common.c
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2010-02-10 19:41:58 -0500
committerJames Morris <jmorris@namei.org>2010-02-14 17:00:16 -0500
commitbf24fb016c861b7f52be0c36c4cedd3e89afa2e2 (patch)
treef485ca2e70d8305d9aaecf45b5fd929b68b971b2 /security/tomoyo/common.c
parentca0b7df3374c5566468c17f26fa2dfd3fe3c6a37 (diff)
TOMOYO: Add refcounter on string data.
Add refcounter to "struct tomoyo_name_entry" and replace tomoyo_save_name() with tomoyo_get_name()/tomoyo_put_name() pair so that we can kfree() when garbage collector is added. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Acked-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/tomoyo/common.c')
-rw-r--r--security/tomoyo/common.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
index a53ee059da48..0c7ea51e7a45 100644
--- a/security/tomoyo/common.c
+++ b/security/tomoyo/common.c
@@ -12,8 +12,8 @@
12#include <linux/uaccess.h> 12#include <linux/uaccess.h>
13#include <linux/security.h> 13#include <linux/security.h>
14#include <linux/hardirq.h> 14#include <linux/hardirq.h>
15#include "realpath.h"
16#include "common.h" 15#include "common.h"
16#include "realpath.h"
17#include "tomoyo.h" 17#include "tomoyo.h"
18 18
19/* Lock for protecting policy. */ 19/* Lock for protecting policy. */
@@ -943,7 +943,9 @@ static int tomoyo_write_profile(struct tomoyo_io_buffer *head)
943 return -EINVAL; 943 return -EINVAL;
944 *cp = '\0'; 944 *cp = '\0';
945 if (!strcmp(data, "COMMENT")) { 945 if (!strcmp(data, "COMMENT")) {
946 profile->comment = tomoyo_save_name(cp + 1); 946 const struct tomoyo_path_info *old_comment = profile->comment;
947 profile->comment = tomoyo_get_name(cp + 1);
948 tomoyo_put_name(old_comment);
947 return 0; 949 return 0;
948 } 950 }
949 for (i = 0; i < TOMOYO_MAX_CONTROL_INDEX; i++) { 951 for (i = 0; i < TOMOYO_MAX_CONTROL_INDEX; i++) {
@@ -1117,7 +1119,7 @@ static int tomoyo_update_manager_entry(const char *manager,
1117 if (!tomoyo_is_correct_path(manager, 1, -1, -1, __func__)) 1119 if (!tomoyo_is_correct_path(manager, 1, -1, -1, __func__))
1118 return -EINVAL; 1120 return -EINVAL;
1119 } 1121 }
1120 saved_manager = tomoyo_save_name(manager); 1122 saved_manager = tomoyo_get_name(manager);
1121 if (!saved_manager) 1123 if (!saved_manager)
1122 return -ENOMEM; 1124 return -ENOMEM;
1123 if (!is_delete) 1125 if (!is_delete)
@@ -1132,12 +1134,14 @@ static int tomoyo_update_manager_entry(const char *manager,
1132 } 1134 }
1133 if (!is_delete && error && tomoyo_memory_ok(entry)) { 1135 if (!is_delete && error && tomoyo_memory_ok(entry)) {
1134 entry->manager = saved_manager; 1136 entry->manager = saved_manager;
1137 saved_manager = NULL;
1135 entry->is_domain = is_domain; 1138 entry->is_domain = is_domain;
1136 list_add_tail_rcu(&entry->list, &tomoyo_policy_manager_list); 1139 list_add_tail_rcu(&entry->list, &tomoyo_policy_manager_list);
1137 entry = NULL; 1140 entry = NULL;
1138 error = 0; 1141 error = 0;
1139 } 1142 }
1140 mutex_unlock(&tomoyo_policy_lock); 1143 mutex_unlock(&tomoyo_policy_lock);
1144 tomoyo_put_name(saved_manager);
1141 kfree(entry); 1145 kfree(entry);
1142 return error; 1146 return error;
1143} 1147}