aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/common.c
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2010-05-05 11:18:15 -0400
committerJames Morris <jmorris@namei.org>2010-05-05 23:19:18 -0400
commit292823814261e085cdcef06b6b691e6c2563fbd4 (patch)
tree8c1eaebcf8f698ea13ac2a9291b9769abde1905e /security/tomoyo/common.c
parent2b9e4688fad8867b6e918610f396af3ab9246898 (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/common.c')
-rw-r--r--security/tomoyo/common.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
index 3c86bbc33aeb..8f34036fd31c 100644
--- a/security/tomoyo/common.c
+++ b/security/tomoyo/common.c
@@ -874,13 +874,13 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_domain_info * const domain)
874static struct tomoyo_profile *tomoyo_find_or_assign_new_profile(const unsigned 874static struct tomoyo_profile *tomoyo_find_or_assign_new_profile(const unsigned
875 int profile) 875 int profile)
876{ 876{
877 static DEFINE_MUTEX(lock);
878 struct tomoyo_profile *ptr = NULL; 877 struct tomoyo_profile *ptr = NULL;
879 int i; 878 int i;
880 879
881 if (profile >= TOMOYO_MAX_PROFILES) 880 if (profile >= TOMOYO_MAX_PROFILES)
882 return NULL; 881 return NULL;
883 mutex_lock(&lock); 882 if (mutex_lock_interruptible(&tomoyo_policy_lock))
883 return NULL;
884 ptr = tomoyo_profile_ptr[profile]; 884 ptr = tomoyo_profile_ptr[profile];
885 if (ptr) 885 if (ptr)
886 goto ok; 886 goto ok;
@@ -895,7 +895,7 @@ static struct tomoyo_profile *tomoyo_find_or_assign_new_profile(const unsigned
895 mb(); /* Avoid out-of-order execution. */ 895 mb(); /* Avoid out-of-order execution. */
896 tomoyo_profile_ptr[profile] = ptr; 896 tomoyo_profile_ptr[profile] = ptr;
897 ok: 897 ok:
898 mutex_unlock(&lock); 898 mutex_unlock(&tomoyo_policy_lock);
899 return ptr; 899 return ptr;
900} 900}
901 901
@@ -1090,7 +1090,8 @@ static int tomoyo_update_manager_entry(const char *manager,
1090 return -ENOMEM; 1090 return -ENOMEM;
1091 if (!is_delete) 1091 if (!is_delete)
1092 entry = kmalloc(sizeof(*entry), GFP_NOFS); 1092 entry = kmalloc(sizeof(*entry), GFP_NOFS);
1093 mutex_lock(&tomoyo_policy_lock); 1093 if (mutex_lock_interruptible(&tomoyo_policy_lock))
1094 goto out;
1094 list_for_each_entry_rcu(ptr, &tomoyo_policy_manager_list, list) { 1095 list_for_each_entry_rcu(ptr, &tomoyo_policy_manager_list, list) {
1095 if (ptr->manager != saved_manager) 1096 if (ptr->manager != saved_manager)
1096 continue; 1097 continue;
@@ -1107,6 +1108,7 @@ static int tomoyo_update_manager_entry(const char *manager,
1107 error = 0; 1108 error = 0;
1108 } 1109 }
1109 mutex_unlock(&tomoyo_policy_lock); 1110 mutex_unlock(&tomoyo_policy_lock);
1111 out:
1110 tomoyo_put_name(saved_manager); 1112 tomoyo_put_name(saved_manager);
1111 kfree(entry); 1113 kfree(entry);
1112 return error; 1114 return error;
@@ -1287,7 +1289,8 @@ static int tomoyo_delete_domain(char *domainname)
1287 1289
1288 name.name = domainname; 1290 name.name = domainname;
1289 tomoyo_fill_path_info(&name); 1291 tomoyo_fill_path_info(&name);
1290 mutex_lock(&tomoyo_policy_lock); 1292 if (mutex_lock_interruptible(&tomoyo_policy_lock))
1293 return 0;
1291 /* Is there an active domain? */ 1294 /* Is there an active domain? */
1292 list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) { 1295 list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) {
1293 /* Never delete tomoyo_kernel_domain */ 1296 /* Never delete tomoyo_kernel_domain */