diff options
author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2010-05-05 11:18:15 -0400 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2010-05-05 23:19:18 -0400 |
commit | 292823814261e085cdcef06b6b691e6c2563fbd4 (patch) | |
tree | 8c1eaebcf8f698ea13ac2a9291b9769abde1905e /security/tomoyo/realpath.c | |
parent | 2b9e4688fad8867b6e918610f396af3ab9246898 (diff) |
TOMOYO: Use mutex_lock_interruptible.
Some of TOMOYO's functions may sleep after mutex_lock(). If OOM-killer selected
a process which is waiting at mutex_lock(), the to-be-killed process can't be
killed. Thus, replace mutex_lock() with mutex_lock_interruptible() so that the
to-be-killed process can immediately return from TOMOYO's functions.
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/realpath.c')
-rw-r--r-- | security/tomoyo/realpath.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c index 6a51e0af2417..62062a68525a 100644 --- a/security/tomoyo/realpath.c +++ b/security/tomoyo/realpath.c | |||
@@ -240,8 +240,6 @@ void tomoyo_memory_free(void *ptr) | |||
240 | * "const struct tomoyo_path_info *". | 240 | * "const struct tomoyo_path_info *". |
241 | */ | 241 | */ |
242 | struct list_head tomoyo_name_list[TOMOYO_MAX_HASH]; | 242 | struct list_head tomoyo_name_list[TOMOYO_MAX_HASH]; |
243 | /* Lock for protecting tomoyo_name_list . */ | ||
244 | DEFINE_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,7 +261,8 @@ 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; |
@@ -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 | ||