diff options
author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2010-06-16 03:29:59 -0400 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2010-08-02 01:34:35 -0400 |
commit | 8fbe71f0e0ac28a39e4a93694c34d670c2f31e88 (patch) | |
tree | 95dc6db6aaaa31a8876bc99c1531bfc26d0e838c | |
parent | cb917cf517075a357ce43b74e8a5a57f2c69a734 (diff) |
TOMOYO: Make read function to void.
Read functions do not fail. Make them from int to void.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: James Morris <jmorris@namei.org>
-rw-r--r-- | security/tomoyo/common.c | 55 | ||||
-rw-r--r-- | security/tomoyo/common.h | 4 | ||||
-rw-r--r-- | security/tomoyo/memory.c | 3 |
3 files changed, 20 insertions, 42 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 | */ |
358 | static int tomoyo_read_profile(struct tomoyo_io_buffer *head) | 356 | static 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 | */ |
545 | static int tomoyo_read_manager_policy(struct tomoyo_io_buffer *head) | 540 | static 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 | */ |
1011 | static int tomoyo_read_domain_policy(struct tomoyo_io_buffer *head) | 1003 | static 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 | */ |
1125 | static int tomoyo_read_domain_profile(struct tomoyo_io_buffer *head) | 1116 | static 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 | */ |
1173 | static int tomoyo_read_pid(struct tomoyo_io_buffer *head) | 1163 | static 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 | */ |
1245 | static int tomoyo_read_exception_policy(struct tomoyo_io_buffer *head) | 1232 | static 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 | */ |
1566 | static int tomoyo_read_query(struct tomoyo_io_buffer *head) | 1548 | static 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 | */ |
1670 | static int tomoyo_read_version(struct tomoyo_io_buffer *head) | 1651 | static 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 | */ |
1686 | static int tomoyo_read_self_domain(struct tomoyo_io_buffer *head) | 1666 | static 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. */ |
diff --git a/security/tomoyo/common.h b/security/tomoyo/common.h index f4da7a8034a3..e0c4ae11bf6c 100644 --- a/security/tomoyo/common.h +++ b/security/tomoyo/common.h | |||
@@ -526,7 +526,7 @@ struct tomoyo_mount_acl { | |||
526 | * is appended. | 526 | * is appended. |
527 | */ | 527 | */ |
528 | struct tomoyo_io_buffer { | 528 | struct tomoyo_io_buffer { |
529 | int (*read) (struct tomoyo_io_buffer *); | 529 | void (*read) (struct tomoyo_io_buffer *); |
530 | int (*write) (struct tomoyo_io_buffer *); | 530 | int (*write) (struct tomoyo_io_buffer *); |
531 | int (*poll) (struct file *file, poll_table *wait); | 531 | int (*poll) (struct file *file, poll_table *wait); |
532 | /* Exclusive lock for this structure. */ | 532 | /* Exclusive lock for this structure. */ |
@@ -900,7 +900,7 @@ void *tomoyo_commit_ok(void *data, const unsigned int size); | |||
900 | const struct tomoyo_path_info *tomoyo_get_name(const char *name); | 900 | const struct tomoyo_path_info *tomoyo_get_name(const char *name); |
901 | 901 | ||
902 | /* Check for memory usage. */ | 902 | /* Check for memory usage. */ |
903 | int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head); | 903 | void tomoyo_read_memory_counter(struct tomoyo_io_buffer *head); |
904 | 904 | ||
905 | /* Set memory quota. */ | 905 | /* Set memory quota. */ |
906 | int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head); | 906 | int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head); |
diff --git a/security/tomoyo/memory.c b/security/tomoyo/memory.c index 4809febc1acb..8de5333109aa 100644 --- a/security/tomoyo/memory.c +++ b/security/tomoyo/memory.c | |||
@@ -184,7 +184,7 @@ unsigned int tomoyo_quota_for_query; | |||
184 | * | 184 | * |
185 | * Returns memory usage. | 185 | * Returns memory usage. |
186 | */ | 186 | */ |
187 | int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head) | 187 | void tomoyo_read_memory_counter(struct tomoyo_io_buffer *head) |
188 | { | 188 | { |
189 | if (!head->read_eof) { | 189 | if (!head->read_eof) { |
190 | const unsigned int policy | 190 | const unsigned int policy |
@@ -212,7 +212,6 @@ int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head) | |||
212 | tomoyo_io_printf(head, "Total: %10u\n", policy + query); | 212 | tomoyo_io_printf(head, "Total: %10u\n", policy + query); |
213 | head->read_eof = true; | 213 | head->read_eof = true; |
214 | } | 214 | } |
215 | return 0; | ||
216 | } | 215 | } |
217 | 216 | ||
218 | /** | 217 | /** |