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.c55
1 files changed, 17 insertions, 38 deletions
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
index ba8360382895..9eeb19ec6af4 100644
--- a/security/tomoyo/common.c
+++ b/security/tomoyo/common.c
@@ -352,14 +352,12 @@ static int tomoyo_write_profile(struct tomoyo_io_buffer *head)
352 * tomoyo_read_profile - Read profile table. 352 * tomoyo_read_profile - Read profile table.
353 * 353 *
354 * @head: Pointer to "struct tomoyo_io_buffer". 354 * @head: Pointer to "struct tomoyo_io_buffer".
355 *
356 * Returns 0.
357 */ 355 */
358static int tomoyo_read_profile(struct tomoyo_io_buffer *head) 356static void tomoyo_read_profile(struct tomoyo_io_buffer *head)
359{ 357{
360 int index; 358 int index;
361 if (head->read_eof) 359 if (head->read_eof)
362 return 0; 360 return;
363 if (head->read_bit) 361 if (head->read_bit)
364 goto body; 362 goto body;
365 tomoyo_io_printf(head, "PROFILE_VERSION=%s\n", "20090903"); 363 tomoyo_io_printf(head, "PROFILE_VERSION=%s\n", "20090903");
@@ -434,7 +432,6 @@ static int tomoyo_read_profile(struct tomoyo_io_buffer *head)
434 } 432 }
435 if (index == TOMOYO_MAX_PROFILES) 433 if (index == TOMOYO_MAX_PROFILES)
436 head->read_eof = true; 434 head->read_eof = true;
437 return 0;
438} 435}
439 436
440/* 437/*
@@ -538,17 +535,15 @@ static int tomoyo_write_manager_policy(struct tomoyo_io_buffer *head)
538 * 535 *
539 * @head: Pointer to "struct tomoyo_io_buffer". 536 * @head: Pointer to "struct tomoyo_io_buffer".
540 * 537 *
541 * Returns 0.
542 *
543 * Caller holds tomoyo_read_lock(). 538 * Caller holds tomoyo_read_lock().
544 */ 539 */
545static int tomoyo_read_manager_policy(struct tomoyo_io_buffer *head) 540static void tomoyo_read_manager_policy(struct tomoyo_io_buffer *head)
546{ 541{
547 struct list_head *pos; 542 struct list_head *pos;
548 bool done = true; 543 bool done = true;
549 544
550 if (head->read_eof) 545 if (head->read_eof)
551 return 0; 546 return;
552 list_for_each_cookie(pos, head->read_var2, 547 list_for_each_cookie(pos, head->read_var2,
553 &tomoyo_policy_manager_list) { 548 &tomoyo_policy_manager_list) {
554 struct tomoyo_policy_manager_entry *ptr; 549 struct tomoyo_policy_manager_entry *ptr;
@@ -561,7 +556,6 @@ static int tomoyo_read_manager_policy(struct tomoyo_io_buffer *head)
561 break; 556 break;
562 } 557 }
563 head->read_eof = done; 558 head->read_eof = done;
564 return 0;
565} 559}
566 560
567/** 561/**
@@ -1004,18 +998,16 @@ static bool tomoyo_print_entry(struct tomoyo_io_buffer *head,
1004 * 998 *
1005 * @head: Pointer to "struct tomoyo_io_buffer". 999 * @head: Pointer to "struct tomoyo_io_buffer".
1006 * 1000 *
1007 * Returns 0.
1008 *
1009 * Caller holds tomoyo_read_lock(). 1001 * Caller holds tomoyo_read_lock().
1010 */ 1002 */
1011static int tomoyo_read_domain_policy(struct tomoyo_io_buffer *head) 1003static void tomoyo_read_domain_policy(struct tomoyo_io_buffer *head)
1012{ 1004{
1013 struct list_head *dpos; 1005 struct list_head *dpos;
1014 struct list_head *apos; 1006 struct list_head *apos;
1015 bool done = true; 1007 bool done = true;
1016 1008
1017 if (head->read_eof) 1009 if (head->read_eof)
1018 return 0; 1010 return;
1019 if (head->read_step == 0) 1011 if (head->read_step == 0)
1020 head->read_step = 1; 1012 head->read_step = 1;
1021 list_for_each_cookie(dpos, head->read_var1, &tomoyo_domain_list) { 1013 list_for_each_cookie(dpos, head->read_var1, &tomoyo_domain_list) {
@@ -1070,7 +1062,6 @@ tail_mark:
1070 break; 1062 break;
1071 } 1063 }
1072 head->read_eof = done; 1064 head->read_eof = done;
1073 return 0;
1074} 1065}
1075 1066
1076/** 1067/**
@@ -1122,13 +1113,13 @@ static int tomoyo_write_domain_profile(struct tomoyo_io_buffer *head)
1122 * 1113 *
1123 * Caller holds tomoyo_read_lock(). 1114 * Caller holds tomoyo_read_lock().
1124 */ 1115 */
1125static int tomoyo_read_domain_profile(struct tomoyo_io_buffer *head) 1116static void tomoyo_read_domain_profile(struct tomoyo_io_buffer *head)
1126{ 1117{
1127 struct list_head *pos; 1118 struct list_head *pos;
1128 bool done = true; 1119 bool done = true;
1129 1120
1130 if (head->read_eof) 1121 if (head->read_eof)
1131 return 0; 1122 return;
1132 list_for_each_cookie(pos, head->read_var1, &tomoyo_domain_list) { 1123 list_for_each_cookie(pos, head->read_var1, &tomoyo_domain_list) {
1133 struct tomoyo_domain_info *domain; 1124 struct tomoyo_domain_info *domain;
1134 domain = list_entry(pos, struct tomoyo_domain_info, list); 1125 domain = list_entry(pos, struct tomoyo_domain_info, list);
@@ -1140,7 +1131,6 @@ static int tomoyo_read_domain_profile(struct tomoyo_io_buffer *head)
1140 break; 1131 break;
1141 } 1132 }
1142 head->read_eof = done; 1133 head->read_eof = done;
1143 return 0;
1144} 1134}
1145 1135
1146/** 1136/**
@@ -1170,7 +1160,7 @@ static int tomoyo_write_pid(struct tomoyo_io_buffer *head)
1170 * The PID is specified by tomoyo_write_pid() so that the user can obtain 1160 * The PID is specified by tomoyo_write_pid() so that the user can obtain
1171 * using read()/write() interface rather than sysctl() interface. 1161 * using read()/write() interface rather than sysctl() interface.
1172 */ 1162 */
1173static int tomoyo_read_pid(struct tomoyo_io_buffer *head) 1163static void tomoyo_read_pid(struct tomoyo_io_buffer *head)
1174{ 1164{
1175 if (head->read_avail == 0 && !head->read_eof) { 1165 if (head->read_avail == 0 && !head->read_eof) {
1176 const int pid = head->read_step; 1166 const int pid = head->read_step;
@@ -1188,7 +1178,6 @@ static int tomoyo_read_pid(struct tomoyo_io_buffer *head)
1188 domain->domainname->name); 1178 domain->domainname->name);
1189 head->read_eof = true; 1179 head->read_eof = true;
1190 } 1180 }
1191 return 0;
1192} 1181}
1193 1182
1194/** 1183/**
@@ -1238,11 +1227,9 @@ static int tomoyo_write_exception_policy(struct tomoyo_io_buffer *head)
1238 * 1227 *
1239 * @head: Pointer to "struct tomoyo_io_buffer". 1228 * @head: Pointer to "struct tomoyo_io_buffer".
1240 * 1229 *
1241 * Returns 0 on success, -EINVAL otherwise.
1242 *
1243 * Caller holds tomoyo_read_lock(). 1230 * Caller holds tomoyo_read_lock().
1244 */ 1231 */
1245static int tomoyo_read_exception_policy(struct tomoyo_io_buffer *head) 1232static void tomoyo_read_exception_policy(struct tomoyo_io_buffer *head)
1246{ 1233{
1247 if (!head->read_eof) { 1234 if (!head->read_eof) {
1248 switch (head->read_step) { 1235 switch (head->read_step) {
@@ -1302,11 +1289,8 @@ static int tomoyo_read_exception_policy(struct tomoyo_io_buffer *head)
1302 case 11: 1289 case 11:
1303 head->read_eof = true; 1290 head->read_eof = true;
1304 break; 1291 break;
1305 default:
1306 return -EINVAL;
1307 } 1292 }
1308 } 1293 }
1309 return 0;
1310} 1294}
1311 1295
1312/** 1296/**
@@ -1560,17 +1544,15 @@ static int tomoyo_poll_query(struct file *file, poll_table *wait)
1560 * tomoyo_read_query - Read access requests which violated policy in enforcing mode. 1544 * tomoyo_read_query - Read access requests which violated policy in enforcing mode.
1561 * 1545 *
1562 * @head: Pointer to "struct tomoyo_io_buffer". 1546 * @head: Pointer to "struct tomoyo_io_buffer".
1563 *
1564 * Returns 0.
1565 */ 1547 */
1566static int tomoyo_read_query(struct tomoyo_io_buffer *head) 1548static void tomoyo_read_query(struct tomoyo_io_buffer *head)
1567{ 1549{
1568 struct list_head *tmp; 1550 struct list_head *tmp;
1569 int pos = 0; 1551 int pos = 0;
1570 int len = 0; 1552 int len = 0;
1571 char *buf; 1553 char *buf;
1572 if (head->read_avail) 1554 if (head->read_avail)
1573 return 0; 1555 return;
1574 if (head->read_buf) { 1556 if (head->read_buf) {
1575 kfree(head->read_buf); 1557 kfree(head->read_buf);
1576 head->read_buf = NULL; 1558 head->read_buf = NULL;
@@ -1590,11 +1572,11 @@ static int tomoyo_read_query(struct tomoyo_io_buffer *head)
1590 spin_unlock(&tomoyo_query_list_lock); 1572 spin_unlock(&tomoyo_query_list_lock);
1591 if (!len) { 1573 if (!len) {
1592 head->read_step = 0; 1574 head->read_step = 0;
1593 return 0; 1575 return;
1594 } 1576 }
1595 buf = kzalloc(len, GFP_NOFS); 1577 buf = kzalloc(len, GFP_NOFS);
1596 if (!buf) 1578 if (!buf)
1597 return 0; 1579 return;
1598 pos = 0; 1580 pos = 0;
1599 spin_lock(&tomoyo_query_list_lock); 1581 spin_lock(&tomoyo_query_list_lock);
1600 list_for_each(tmp, &tomoyo_query_list) { 1582 list_for_each(tmp, &tomoyo_query_list) {
@@ -1621,7 +1603,6 @@ static int tomoyo_read_query(struct tomoyo_io_buffer *head)
1621 } else { 1603 } else {
1622 kfree(buf); 1604 kfree(buf);
1623 } 1605 }
1624 return 0;
1625} 1606}
1626 1607
1627/** 1608/**
@@ -1667,13 +1648,12 @@ static int tomoyo_write_answer(struct tomoyo_io_buffer *head)
1667 * 1648 *
1668 * Returns version information. 1649 * Returns version information.
1669 */ 1650 */
1670static int tomoyo_read_version(struct tomoyo_io_buffer *head) 1651static void tomoyo_read_version(struct tomoyo_io_buffer *head)
1671{ 1652{
1672 if (!head->read_eof) { 1653 if (!head->read_eof) {
1673 tomoyo_io_printf(head, "2.3.0-pre"); 1654 tomoyo_io_printf(head, "2.3.0-pre");
1674 head->read_eof = true; 1655 head->read_eof = true;
1675 } 1656 }
1676 return 0;
1677} 1657}
1678 1658
1679/** 1659/**
@@ -1683,7 +1663,7 @@ static int tomoyo_read_version(struct tomoyo_io_buffer *head)
1683 * 1663 *
1684 * Returns the current process's domainname. 1664 * Returns the current process's domainname.
1685 */ 1665 */
1686static int tomoyo_read_self_domain(struct tomoyo_io_buffer *head) 1666static void tomoyo_read_self_domain(struct tomoyo_io_buffer *head)
1687{ 1667{
1688 if (!head->read_eof) { 1668 if (!head->read_eof) {
1689 /* 1669 /*
@@ -1694,7 +1674,6 @@ static int tomoyo_read_self_domain(struct tomoyo_io_buffer *head)
1694 tomoyo_io_printf(head, "%s", tomoyo_domain()->domainname->name); 1674 tomoyo_io_printf(head, "%s", tomoyo_domain()->domainname->name);
1695 head->read_eof = true; 1675 head->read_eof = true;
1696 } 1676 }
1697 return 0;
1698} 1677}
1699 1678
1700/** 1679/**
@@ -1862,7 +1841,7 @@ int tomoyo_read_control(struct file *file, char __user *buffer,
1862 if (mutex_lock_interruptible(&head->io_sem)) 1841 if (mutex_lock_interruptible(&head->io_sem))
1863 return -EINTR; 1842 return -EINTR;
1864 /* Call the policy handler. */ 1843 /* Call the policy handler. */
1865 len = head->read(head); 1844 head->read(head);
1866 if (len < 0) 1845 if (len < 0)
1867 goto out; 1846 goto out;
1868 /* Write to buffer. */ 1847 /* Write to buffer. */