aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/file.c
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2010-01-03 07:16:32 -0500
committerJames Morris <jmorris@namei.org>2010-01-10 15:57:44 -0500
commitf737d95ddfea4df68a36ffc9231db4bf34b06d13 (patch)
tree28a1bf737c96ba8048abcf87a7acfc8412e92a2e /security/tomoyo/file.c
parentfdb8ebb729bbb640e64028a4f579a02ebc405727 (diff)
TOMOYO: Replace rw_semaphore by mutex.
Since readers no longer use down_read(), writers no longer need to use rw_semaphore. Replace individual rw_semaphore by single mutex. 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/file.c')
-rw-r--r--security/tomoyo/file.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/security/tomoyo/file.c b/security/tomoyo/file.c
index 3c472867634f..5d1689d6e16c 100644
--- a/security/tomoyo/file.c
+++ b/security/tomoyo/file.c
@@ -167,9 +167,6 @@ static struct tomoyo_path_info *tomoyo_get_path(struct path *path)
167 return NULL; 167 return NULL;
168} 168}
169 169
170/* Lock for domain->acl_info_list. */
171DECLARE_RWSEM(tomoyo_domain_acl_info_list_lock);
172
173static int tomoyo_update_double_path_acl(const u8 type, const char *filename1, 170static int tomoyo_update_double_path_acl(const u8 type, const char *filename1,
174 const char *filename2, 171 const char *filename2,
175 struct tomoyo_domain_info * 172 struct tomoyo_domain_info *
@@ -204,7 +201,6 @@ static int tomoyo_update_single_path_acl(const u8 type, const char *filename,
204 * belongs to. 201 * belongs to.
205 */ 202 */
206static LIST_HEAD(tomoyo_globally_readable_list); 203static LIST_HEAD(tomoyo_globally_readable_list);
207static DECLARE_RWSEM(tomoyo_globally_readable_list_lock);
208 204
209/** 205/**
210 * tomoyo_update_globally_readable_entry - Update "struct tomoyo_globally_readable_file_entry" list. 206 * tomoyo_update_globally_readable_entry - Update "struct tomoyo_globally_readable_file_entry" list.
@@ -229,7 +225,7 @@ static int tomoyo_update_globally_readable_entry(const char *filename,
229 saved_filename = tomoyo_save_name(filename); 225 saved_filename = tomoyo_save_name(filename);
230 if (!saved_filename) 226 if (!saved_filename)
231 return -ENOMEM; 227 return -ENOMEM;
232 down_write(&tomoyo_globally_readable_list_lock); 228 mutex_lock(&tomoyo_policy_lock);
233 list_for_each_entry_rcu(ptr, &tomoyo_globally_readable_list, list) { 229 list_for_each_entry_rcu(ptr, &tomoyo_globally_readable_list, list) {
234 if (ptr->filename != saved_filename) 230 if (ptr->filename != saved_filename)
235 continue; 231 continue;
@@ -248,7 +244,7 @@ static int tomoyo_update_globally_readable_entry(const char *filename,
248 list_add_tail_rcu(&new_entry->list, &tomoyo_globally_readable_list); 244 list_add_tail_rcu(&new_entry->list, &tomoyo_globally_readable_list);
249 error = 0; 245 error = 0;
250 out: 246 out:
251 up_write(&tomoyo_globally_readable_list_lock); 247 mutex_unlock(&tomoyo_policy_lock);
252 return error; 248 return error;
253} 249}
254 250
@@ -352,7 +348,6 @@ bool tomoyo_read_globally_readable_policy(struct tomoyo_io_buffer *head)
352 * current process from accessing other process's information. 348 * current process from accessing other process's information.
353 */ 349 */
354static LIST_HEAD(tomoyo_pattern_list); 350static LIST_HEAD(tomoyo_pattern_list);
355static DECLARE_RWSEM(tomoyo_pattern_list_lock);
356 351
357/** 352/**
358 * tomoyo_update_file_pattern_entry - Update "struct tomoyo_pattern_entry" list. 353 * tomoyo_update_file_pattern_entry - Update "struct tomoyo_pattern_entry" list.
@@ -377,7 +372,7 @@ static int tomoyo_update_file_pattern_entry(const char *pattern,
377 saved_pattern = tomoyo_save_name(pattern); 372 saved_pattern = tomoyo_save_name(pattern);
378 if (!saved_pattern) 373 if (!saved_pattern)
379 return -ENOMEM; 374 return -ENOMEM;
380 down_write(&tomoyo_pattern_list_lock); 375 mutex_lock(&tomoyo_policy_lock);
381 list_for_each_entry_rcu(ptr, &tomoyo_pattern_list, list) { 376 list_for_each_entry_rcu(ptr, &tomoyo_pattern_list, list) {
382 if (saved_pattern != ptr->pattern) 377 if (saved_pattern != ptr->pattern)
383 continue; 378 continue;
@@ -396,7 +391,7 @@ static int tomoyo_update_file_pattern_entry(const char *pattern,
396 list_add_tail_rcu(&new_entry->list, &tomoyo_pattern_list); 391 list_add_tail_rcu(&new_entry->list, &tomoyo_pattern_list);
397 error = 0; 392 error = 0;
398 out: 393 out:
399 up_write(&tomoyo_pattern_list_lock); 394 mutex_unlock(&tomoyo_policy_lock);
400 return error; 395 return error;
401} 396}
402 397
@@ -505,7 +500,6 @@ bool tomoyo_read_file_pattern(struct tomoyo_io_buffer *head)
505 * need to worry whether the file is already unlink()ed or not. 500 * need to worry whether the file is already unlink()ed or not.
506 */ 501 */
507static LIST_HEAD(tomoyo_no_rewrite_list); 502static LIST_HEAD(tomoyo_no_rewrite_list);
508static DECLARE_RWSEM(tomoyo_no_rewrite_list_lock);
509 503
510/** 504/**
511 * tomoyo_update_no_rewrite_entry - Update "struct tomoyo_no_rewrite_entry" list. 505 * tomoyo_update_no_rewrite_entry - Update "struct tomoyo_no_rewrite_entry" list.
@@ -529,7 +523,7 @@ static int tomoyo_update_no_rewrite_entry(const char *pattern,
529 saved_pattern = tomoyo_save_name(pattern); 523 saved_pattern = tomoyo_save_name(pattern);
530 if (!saved_pattern) 524 if (!saved_pattern)
531 return -ENOMEM; 525 return -ENOMEM;
532 down_write(&tomoyo_no_rewrite_list_lock); 526 mutex_lock(&tomoyo_policy_lock);
533 list_for_each_entry_rcu(ptr, &tomoyo_no_rewrite_list, list) { 527 list_for_each_entry_rcu(ptr, &tomoyo_no_rewrite_list, list) {
534 if (ptr->pattern != saved_pattern) 528 if (ptr->pattern != saved_pattern)
535 continue; 529 continue;
@@ -548,7 +542,7 @@ static int tomoyo_update_no_rewrite_entry(const char *pattern,
548 list_add_tail_rcu(&new_entry->list, &tomoyo_no_rewrite_list); 542 list_add_tail_rcu(&new_entry->list, &tomoyo_no_rewrite_list);
549 error = 0; 543 error = 0;
550 out: 544 out:
551 up_write(&tomoyo_no_rewrite_list_lock); 545 mutex_unlock(&tomoyo_policy_lock);
552 return error; 546 return error;
553} 547}
554 548
@@ -881,7 +875,7 @@ static int tomoyo_update_single_path_acl(const u8 type, const char *filename,
881 saved_filename = tomoyo_save_name(filename); 875 saved_filename = tomoyo_save_name(filename);
882 if (!saved_filename) 876 if (!saved_filename)
883 return -ENOMEM; 877 return -ENOMEM;
884 down_write(&tomoyo_domain_acl_info_list_lock); 878 mutex_lock(&tomoyo_policy_lock);
885 if (is_delete) 879 if (is_delete)
886 goto delete; 880 goto delete;
887 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) { 881 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) {
@@ -943,7 +937,7 @@ static int tomoyo_update_single_path_acl(const u8 type, const char *filename,
943 break; 937 break;
944 } 938 }
945 out: 939 out:
946 up_write(&tomoyo_domain_acl_info_list_lock); 940 mutex_unlock(&tomoyo_policy_lock);
947 return error; 941 return error;
948} 942}
949 943
@@ -981,7 +975,7 @@ static int tomoyo_update_double_path_acl(const u8 type, const char *filename1,
981 saved_filename2 = tomoyo_save_name(filename2); 975 saved_filename2 = tomoyo_save_name(filename2);
982 if (!saved_filename1 || !saved_filename2) 976 if (!saved_filename1 || !saved_filename2)
983 return -ENOMEM; 977 return -ENOMEM;
984 down_write(&tomoyo_domain_acl_info_list_lock); 978 mutex_lock(&tomoyo_policy_lock);
985 if (is_delete) 979 if (is_delete)
986 goto delete; 980 goto delete;
987 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) { 981 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) {
@@ -1027,7 +1021,7 @@ static int tomoyo_update_double_path_acl(const u8 type, const char *filename1,
1027 break; 1021 break;
1028 } 1022 }
1029 out: 1023 out:
1030 up_write(&tomoyo_domain_acl_info_list_lock); 1024 mutex_unlock(&tomoyo_policy_lock);
1031 return error; 1025 return error;
1032} 1026}
1033 1027