aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/tomoyo/common.c')
-rw-r--r--security/tomoyo/common.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
index f01b9364db2d..642e0e565dfc 100644
--- a/security/tomoyo/common.c
+++ b/security/tomoyo/common.c
@@ -16,6 +16,9 @@
16#include "common.h" 16#include "common.h"
17#include "tomoyo.h" 17#include "tomoyo.h"
18 18
19/* Lock for protecting policy. */
20DEFINE_MUTEX(tomoyo_policy_lock);
21
19/* Has loading policy done? */ 22/* Has loading policy done? */
20bool tomoyo_policy_loaded; 23bool tomoyo_policy_loaded;
21 24
@@ -1086,7 +1089,6 @@ struct tomoyo_policy_manager_entry {
1086 * # cat /sys/kernel/security/tomoyo/manager 1089 * # cat /sys/kernel/security/tomoyo/manager
1087 */ 1090 */
1088static LIST_HEAD(tomoyo_policy_manager_list); 1091static LIST_HEAD(tomoyo_policy_manager_list);
1089static DECLARE_RWSEM(tomoyo_policy_manager_list_lock);
1090 1092
1091/** 1093/**
1092 * tomoyo_update_manager_entry - Add a manager entry. 1094 * tomoyo_update_manager_entry - Add a manager entry.
@@ -1118,7 +1120,7 @@ static int tomoyo_update_manager_entry(const char *manager,
1118 saved_manager = tomoyo_save_name(manager); 1120 saved_manager = tomoyo_save_name(manager);
1119 if (!saved_manager) 1121 if (!saved_manager)
1120 return -ENOMEM; 1122 return -ENOMEM;
1121 down_write(&tomoyo_policy_manager_list_lock); 1123 mutex_lock(&tomoyo_policy_lock);
1122 list_for_each_entry_rcu(ptr, &tomoyo_policy_manager_list, list) { 1124 list_for_each_entry_rcu(ptr, &tomoyo_policy_manager_list, list) {
1123 if (ptr->manager != saved_manager) 1125 if (ptr->manager != saved_manager)
1124 continue; 1126 continue;
@@ -1138,7 +1140,7 @@ static int tomoyo_update_manager_entry(const char *manager,
1138 list_add_tail_rcu(&new_entry->list, &tomoyo_policy_manager_list); 1140 list_add_tail_rcu(&new_entry->list, &tomoyo_policy_manager_list);
1139 error = 0; 1141 error = 0;
1140 out: 1142 out:
1141 up_write(&tomoyo_policy_manager_list_lock); 1143 mutex_unlock(&tomoyo_policy_lock);
1142 return error; 1144 return error;
1143} 1145}
1144 1146
@@ -1315,7 +1317,7 @@ static int tomoyo_delete_domain(char *domainname)
1315 1317
1316 name.name = domainname; 1318 name.name = domainname;
1317 tomoyo_fill_path_info(&name); 1319 tomoyo_fill_path_info(&name);
1318 down_write(&tomoyo_domain_list_lock); 1320 mutex_lock(&tomoyo_policy_lock);
1319 /* Is there an active domain? */ 1321 /* Is there an active domain? */
1320 list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) { 1322 list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) {
1321 /* Never delete tomoyo_kernel_domain */ 1323 /* Never delete tomoyo_kernel_domain */
@@ -1327,7 +1329,7 @@ static int tomoyo_delete_domain(char *domainname)
1327 domain->is_deleted = true; 1329 domain->is_deleted = true;
1328 break; 1330 break;
1329 } 1331 }
1330 up_write(&tomoyo_domain_list_lock); 1332 mutex_unlock(&tomoyo_policy_lock);
1331 return 0; 1333 return 0;
1332} 1334}
1333 1335