Commit 8fbe71f0e0ac28a39e4a93694c34d670c2f31e88
Committed by
James Morris
1 parent
cb917cf517
Exists in
master
and in
7 other branches
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>
Showing 3 changed files with 20 additions and 42 deletions Side-by-side Diff
security/tomoyo/common.c
... | ... | @@ -352,14 +352,12 @@ |
352 | 352 | * tomoyo_read_profile - Read profile table. |
353 | 353 | * |
354 | 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 | 358 | int index; |
361 | 359 | if (head->read_eof) |
362 | - return 0; | |
360 | + return; | |
363 | 361 | if (head->read_bit) |
364 | 362 | goto body; |
365 | 363 | tomoyo_io_printf(head, "PROFILE_VERSION=%s\n", "20090903"); |
... | ... | @@ -434,7 +432,6 @@ |
434 | 432 | } |
435 | 433 | if (index == TOMOYO_MAX_PROFILES) |
436 | 434 | head->read_eof = true; |
437 | - return 0; | |
438 | 435 | } |
439 | 436 | |
440 | 437 | /* |
441 | 438 | |
442 | 439 | |
... | ... | @@ -538,17 +535,15 @@ |
538 | 535 | * |
539 | 536 | * @head: Pointer to "struct tomoyo_io_buffer". |
540 | 537 | * |
541 | - * Returns 0. | |
542 | - * | |
543 | 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 | 542 | struct list_head *pos; |
548 | 543 | bool done = true; |
549 | 544 | |
550 | 545 | if (head->read_eof) |
551 | - return 0; | |
546 | + return; | |
552 | 547 | list_for_each_cookie(pos, head->read_var2, |
553 | 548 | &tomoyo_policy_manager_list) { |
554 | 549 | struct tomoyo_policy_manager_entry *ptr; |
... | ... | @@ -561,7 +556,6 @@ |
561 | 556 | break; |
562 | 557 | } |
563 | 558 | head->read_eof = done; |
564 | - return 0; | |
565 | 559 | } |
566 | 560 | |
567 | 561 | /** |
568 | 562 | |
569 | 563 | |
... | ... | @@ -1004,18 +998,16 @@ |
1004 | 998 | * |
1005 | 999 | * @head: Pointer to "struct tomoyo_io_buffer". |
1006 | 1000 | * |
1007 | - * Returns 0. | |
1008 | - * | |
1009 | 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 | 1005 | struct list_head *dpos; |
1014 | 1006 | struct list_head *apos; |
1015 | 1007 | bool done = true; |
1016 | 1008 | |
1017 | 1009 | if (head->read_eof) |
1018 | - return 0; | |
1010 | + return; | |
1019 | 1011 | if (head->read_step == 0) |
1020 | 1012 | head->read_step = 1; |
1021 | 1013 | list_for_each_cookie(dpos, head->read_var1, &tomoyo_domain_list) { |
... | ... | @@ -1070,7 +1062,6 @@ |
1070 | 1062 | break; |
1071 | 1063 | } |
1072 | 1064 | head->read_eof = done; |
1073 | - return 0; | |
1074 | 1065 | } |
1075 | 1066 | |
1076 | 1067 | /** |
1077 | 1068 | |
... | ... | @@ -1122,13 +1113,13 @@ |
1122 | 1113 | * |
1123 | 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 | 1118 | struct list_head *pos; |
1128 | 1119 | bool done = true; |
1129 | 1120 | |
1130 | 1121 | if (head->read_eof) |
1131 | - return 0; | |
1122 | + return; | |
1132 | 1123 | list_for_each_cookie(pos, head->read_var1, &tomoyo_domain_list) { |
1133 | 1124 | struct tomoyo_domain_info *domain; |
1134 | 1125 | domain = list_entry(pos, struct tomoyo_domain_info, list); |
... | ... | @@ -1140,7 +1131,6 @@ |
1140 | 1131 | break; |
1141 | 1132 | } |
1142 | 1133 | head->read_eof = done; |
1143 | - return 0; | |
1144 | 1134 | } |
1145 | 1135 | |
1146 | 1136 | /** |
... | ... | @@ -1170,7 +1160,7 @@ |
1170 | 1160 | * The PID is specified by tomoyo_write_pid() so that the user can obtain |
1171 | 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 | 1165 | if (head->read_avail == 0 && !head->read_eof) { |
1176 | 1166 | const int pid = head->read_step; |
... | ... | @@ -1188,7 +1178,6 @@ |
1188 | 1178 | domain->domainname->name); |
1189 | 1179 | head->read_eof = true; |
1190 | 1180 | } |
1191 | - return 0; | |
1192 | 1181 | } |
1193 | 1182 | |
1194 | 1183 | /** |
1195 | 1184 | |
... | ... | @@ -1238,11 +1227,9 @@ |
1238 | 1227 | * |
1239 | 1228 | * @head: Pointer to "struct tomoyo_io_buffer". |
1240 | 1229 | * |
1241 | - * Returns 0 on success, -EINVAL otherwise. | |
1242 | - * | |
1243 | 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 | 1234 | if (!head->read_eof) { |
1248 | 1235 | switch (head->read_step) { |
1249 | 1236 | |
... | ... | @@ -1302,11 +1289,8 @@ |
1302 | 1289 | case 11: |
1303 | 1290 | head->read_eof = true; |
1304 | 1291 | break; |
1305 | - default: | |
1306 | - return -EINVAL; | |
1307 | 1292 | } |
1308 | 1293 | } |
1309 | - return 0; | |
1310 | 1294 | } |
1311 | 1295 | |
1312 | 1296 | /** |
1313 | 1297 | |
1314 | 1298 | |
... | ... | @@ -1560,17 +1544,15 @@ |
1560 | 1544 | * tomoyo_read_query - Read access requests which violated policy in enforcing mode. |
1561 | 1545 | * |
1562 | 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 | 1550 | struct list_head *tmp; |
1569 | 1551 | int pos = 0; |
1570 | 1552 | int len = 0; |
1571 | 1553 | char *buf; |
1572 | 1554 | if (head->read_avail) |
1573 | - return 0; | |
1555 | + return; | |
1574 | 1556 | if (head->read_buf) { |
1575 | 1557 | kfree(head->read_buf); |
1576 | 1558 | head->read_buf = NULL; |
1577 | 1559 | |
... | ... | @@ -1590,11 +1572,11 @@ |
1590 | 1572 | spin_unlock(&tomoyo_query_list_lock); |
1591 | 1573 | if (!len) { |
1592 | 1574 | head->read_step = 0; |
1593 | - return 0; | |
1575 | + return; | |
1594 | 1576 | } |
1595 | 1577 | buf = kzalloc(len, GFP_NOFS); |
1596 | 1578 | if (!buf) |
1597 | - return 0; | |
1579 | + return; | |
1598 | 1580 | pos = 0; |
1599 | 1581 | spin_lock(&tomoyo_query_list_lock); |
1600 | 1582 | list_for_each(tmp, &tomoyo_query_list) { |
... | ... | @@ -1621,7 +1603,6 @@ |
1621 | 1603 | } else { |
1622 | 1604 | kfree(buf); |
1623 | 1605 | } |
1624 | - return 0; | |
1625 | 1606 | } |
1626 | 1607 | |
1627 | 1608 | /** |
1628 | 1609 | |
... | ... | @@ -1667,13 +1648,12 @@ |
1667 | 1648 | * |
1668 | 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 | 1653 | if (!head->read_eof) { |
1673 | 1654 | tomoyo_io_printf(head, "2.3.0-pre"); |
1674 | 1655 | head->read_eof = true; |
1675 | 1656 | } |
1676 | - return 0; | |
1677 | 1657 | } |
1678 | 1658 | |
1679 | 1659 | /** |
... | ... | @@ -1683,7 +1663,7 @@ |
1683 | 1663 | * |
1684 | 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 | 1668 | if (!head->read_eof) { |
1689 | 1669 | /* |
... | ... | @@ -1694,7 +1674,6 @@ |
1694 | 1674 | tomoyo_io_printf(head, "%s", tomoyo_domain()->domainname->name); |
1695 | 1675 | head->read_eof = true; |
1696 | 1676 | } |
1697 | - return 0; | |
1698 | 1677 | } |
1699 | 1678 | |
1700 | 1679 | /** |
... | ... | @@ -1862,7 +1841,7 @@ |
1862 | 1841 | if (mutex_lock_interruptible(&head->io_sem)) |
1863 | 1842 | return -EINTR; |
1864 | 1843 | /* Call the policy handler. */ |
1865 | - len = head->read(head); | |
1844 | + head->read(head); | |
1866 | 1845 | if (len < 0) |
1867 | 1846 | goto out; |
1868 | 1847 | /* Write to buffer. */ |
security/tomoyo/common.h
... | ... | @@ -526,7 +526,7 @@ |
526 | 526 | * is appended. |
527 | 527 | */ |
528 | 528 | struct tomoyo_io_buffer { |
529 | - int (*read) (struct tomoyo_io_buffer *); | |
529 | + void (*read) (struct tomoyo_io_buffer *); | |
530 | 530 | int (*write) (struct tomoyo_io_buffer *); |
531 | 531 | int (*poll) (struct file *file, poll_table *wait); |
532 | 532 | /* Exclusive lock for this structure. */ |
... | ... | @@ -900,7 +900,7 @@ |
900 | 900 | const struct tomoyo_path_info *tomoyo_get_name(const char *name); |
901 | 901 | |
902 | 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 | 905 | /* Set memory quota. */ |
906 | 906 | int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head); |
security/tomoyo/memory.c
... | ... | @@ -184,7 +184,7 @@ |
184 | 184 | * |
185 | 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 | 189 | if (!head->read_eof) { |
190 | 190 | const unsigned int policy |
... | ... | @@ -212,7 +212,6 @@ |
212 | 212 | tomoyo_io_printf(head, "Total: %10u\n", policy + query); |
213 | 213 | head->read_eof = true; |
214 | 214 | } |
215 | - return 0; | |
216 | 215 | } |
217 | 216 | |
218 | 217 | /** |