aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/realpath.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/tomoyo/realpath.c')
-rw-r--r--security/tomoyo/realpath.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c
index c225c65ce426..62062a68525a 100644
--- a/security/tomoyo/realpath.c
+++ b/security/tomoyo/realpath.c
@@ -139,7 +139,7 @@ int tomoyo_realpath_from_path2(struct path *path, char *newname,
139 */ 139 */
140char *tomoyo_realpath_from_path(struct path *path) 140char *tomoyo_realpath_from_path(struct path *path)
141{ 141{
142 char *buf = kzalloc(sizeof(struct tomoyo_page_buffer), GFP_KERNEL); 142 char *buf = kzalloc(sizeof(struct tomoyo_page_buffer), GFP_NOFS);
143 143
144 BUILD_BUG_ON(sizeof(struct tomoyo_page_buffer) 144 BUILD_BUG_ON(sizeof(struct tomoyo_page_buffer)
145 <= TOMOYO_MAX_PATHNAME_LEN - 1); 145 <= TOMOYO_MAX_PATHNAME_LEN - 1);
@@ -240,8 +240,6 @@ void tomoyo_memory_free(void *ptr)
240 * "const struct tomoyo_path_info *". 240 * "const struct tomoyo_path_info *".
241 */ 241 */
242struct list_head tomoyo_name_list[TOMOYO_MAX_HASH]; 242struct list_head tomoyo_name_list[TOMOYO_MAX_HASH];
243/* Lock for protecting tomoyo_name_list . */
244DEFINE_MUTEX(tomoyo_name_list_lock);
245 243
246/** 244/**
247 * tomoyo_get_name - Allocate permanent memory for string data. 245 * tomoyo_get_name - Allocate permanent memory for string data.
@@ -263,14 +261,15 @@ const struct tomoyo_path_info *tomoyo_get_name(const char *name)
263 len = strlen(name) + 1; 261 len = strlen(name) + 1;
264 hash = full_name_hash((const unsigned char *) name, len - 1); 262 hash = full_name_hash((const unsigned char *) name, len - 1);
265 head = &tomoyo_name_list[hash_long(hash, TOMOYO_HASH_BITS)]; 263 head = &tomoyo_name_list[hash_long(hash, TOMOYO_HASH_BITS)];
266 mutex_lock(&tomoyo_name_list_lock); 264 if (mutex_lock_interruptible(&tomoyo_policy_lock))
265 return NULL;
267 list_for_each_entry(ptr, head, list) { 266 list_for_each_entry(ptr, head, list) {
268 if (hash != ptr->entry.hash || strcmp(name, ptr->entry.name)) 267 if (hash != ptr->entry.hash || strcmp(name, ptr->entry.name))
269 continue; 268 continue;
270 atomic_inc(&ptr->users); 269 atomic_inc(&ptr->users);
271 goto out; 270 goto out;
272 } 271 }
273 ptr = kzalloc(sizeof(*ptr) + len, GFP_KERNEL); 272 ptr = kzalloc(sizeof(*ptr) + len, GFP_NOFS);
274 allocated_len = ptr ? ksize(ptr) : 0; 273 allocated_len = ptr ? ksize(ptr) : 0;
275 if (!ptr || (tomoyo_quota_for_policy && 274 if (!ptr || (tomoyo_quota_for_policy &&
276 atomic_read(&tomoyo_policy_memory_size) + allocated_len 275 atomic_read(&tomoyo_policy_memory_size) + allocated_len
@@ -290,7 +289,7 @@ const struct tomoyo_path_info *tomoyo_get_name(const char *name)
290 tomoyo_fill_path_info(&ptr->entry); 289 tomoyo_fill_path_info(&ptr->entry);
291 list_add_tail(&ptr->list, head); 290 list_add_tail(&ptr->list, head);
292 out: 291 out:
293 mutex_unlock(&tomoyo_name_list_lock); 292 mutex_unlock(&tomoyo_policy_lock);
294 return ptr ? &ptr->entry : NULL; 293 return ptr ? &ptr->entry : NULL;
295} 294}
296 295