diff options
Diffstat (limited to 'security/tomoyo/common.c')
-rw-r--r-- | security/tomoyo/common.c | 228 |
1 files changed, 185 insertions, 43 deletions
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c index 2e43aec1c36b..150911c7ff08 100644 --- a/security/tomoyo/common.c +++ b/security/tomoyo/common.c | |||
@@ -20,6 +20,7 @@ const char * const tomoyo_mode[TOMOYO_CONFIG_MAX_MODE] = { | |||
20 | /* String table for /sys/kernel/security/tomoyo/profile */ | 20 | /* String table for /sys/kernel/security/tomoyo/profile */ |
21 | const char * const tomoyo_mac_keywords[TOMOYO_MAX_MAC_INDEX | 21 | const char * const tomoyo_mac_keywords[TOMOYO_MAX_MAC_INDEX |
22 | + TOMOYO_MAX_MAC_CATEGORY_INDEX] = { | 22 | + TOMOYO_MAX_MAC_CATEGORY_INDEX] = { |
23 | /* CONFIG::file group */ | ||
23 | [TOMOYO_MAC_FILE_EXECUTE] = "execute", | 24 | [TOMOYO_MAC_FILE_EXECUTE] = "execute", |
24 | [TOMOYO_MAC_FILE_OPEN] = "open", | 25 | [TOMOYO_MAC_FILE_OPEN] = "open", |
25 | [TOMOYO_MAC_FILE_CREATE] = "create", | 26 | [TOMOYO_MAC_FILE_CREATE] = "create", |
@@ -43,7 +44,28 @@ const char * const tomoyo_mac_keywords[TOMOYO_MAX_MAC_INDEX | |||
43 | [TOMOYO_MAC_FILE_MOUNT] = "mount", | 44 | [TOMOYO_MAC_FILE_MOUNT] = "mount", |
44 | [TOMOYO_MAC_FILE_UMOUNT] = "unmount", | 45 | [TOMOYO_MAC_FILE_UMOUNT] = "unmount", |
45 | [TOMOYO_MAC_FILE_PIVOT_ROOT] = "pivot_root", | 46 | [TOMOYO_MAC_FILE_PIVOT_ROOT] = "pivot_root", |
47 | /* CONFIG::network group */ | ||
48 | [TOMOYO_MAC_NETWORK_INET_STREAM_BIND] = "inet_stream_bind", | ||
49 | [TOMOYO_MAC_NETWORK_INET_STREAM_LISTEN] = "inet_stream_listen", | ||
50 | [TOMOYO_MAC_NETWORK_INET_STREAM_CONNECT] = "inet_stream_connect", | ||
51 | [TOMOYO_MAC_NETWORK_INET_DGRAM_BIND] = "inet_dgram_bind", | ||
52 | [TOMOYO_MAC_NETWORK_INET_DGRAM_SEND] = "inet_dgram_send", | ||
53 | [TOMOYO_MAC_NETWORK_INET_RAW_BIND] = "inet_raw_bind", | ||
54 | [TOMOYO_MAC_NETWORK_INET_RAW_SEND] = "inet_raw_send", | ||
55 | [TOMOYO_MAC_NETWORK_UNIX_STREAM_BIND] = "unix_stream_bind", | ||
56 | [TOMOYO_MAC_NETWORK_UNIX_STREAM_LISTEN] = "unix_stream_listen", | ||
57 | [TOMOYO_MAC_NETWORK_UNIX_STREAM_CONNECT] = "unix_stream_connect", | ||
58 | [TOMOYO_MAC_NETWORK_UNIX_DGRAM_BIND] = "unix_dgram_bind", | ||
59 | [TOMOYO_MAC_NETWORK_UNIX_DGRAM_SEND] = "unix_dgram_send", | ||
60 | [TOMOYO_MAC_NETWORK_UNIX_SEQPACKET_BIND] = "unix_seqpacket_bind", | ||
61 | [TOMOYO_MAC_NETWORK_UNIX_SEQPACKET_LISTEN] = "unix_seqpacket_listen", | ||
62 | [TOMOYO_MAC_NETWORK_UNIX_SEQPACKET_CONNECT] = "unix_seqpacket_connect", | ||
63 | /* CONFIG::misc group */ | ||
64 | [TOMOYO_MAC_ENVIRON] = "env", | ||
65 | /* CONFIG group */ | ||
46 | [TOMOYO_MAX_MAC_INDEX + TOMOYO_MAC_CATEGORY_FILE] = "file", | 66 | [TOMOYO_MAX_MAC_INDEX + TOMOYO_MAC_CATEGORY_FILE] = "file", |
67 | [TOMOYO_MAX_MAC_INDEX + TOMOYO_MAC_CATEGORY_NETWORK] = "network", | ||
68 | [TOMOYO_MAX_MAC_INDEX + TOMOYO_MAC_CATEGORY_MISC] = "misc", | ||
47 | }; | 69 | }; |
48 | 70 | ||
49 | /* String table for conditions. */ | 71 | /* String table for conditions. */ |
@@ -130,10 +152,20 @@ const char * const tomoyo_path_keyword[TOMOYO_MAX_PATH_OPERATION] = { | |||
130 | [TOMOYO_TYPE_UMOUNT] = "unmount", | 152 | [TOMOYO_TYPE_UMOUNT] = "unmount", |
131 | }; | 153 | }; |
132 | 154 | ||
155 | /* String table for socket's operation. */ | ||
156 | const char * const tomoyo_socket_keyword[TOMOYO_MAX_NETWORK_OPERATION] = { | ||
157 | [TOMOYO_NETWORK_BIND] = "bind", | ||
158 | [TOMOYO_NETWORK_LISTEN] = "listen", | ||
159 | [TOMOYO_NETWORK_CONNECT] = "connect", | ||
160 | [TOMOYO_NETWORK_SEND] = "send", | ||
161 | }; | ||
162 | |||
133 | /* String table for categories. */ | 163 | /* String table for categories. */ |
134 | static const char * const tomoyo_category_keywords | 164 | static const char * const tomoyo_category_keywords |
135 | [TOMOYO_MAX_MAC_CATEGORY_INDEX] = { | 165 | [TOMOYO_MAX_MAC_CATEGORY_INDEX] = { |
136 | [TOMOYO_MAC_CATEGORY_FILE] = "file", | 166 | [TOMOYO_MAC_CATEGORY_FILE] = "file", |
167 | [TOMOYO_MAC_CATEGORY_NETWORK] = "network", | ||
168 | [TOMOYO_MAC_CATEGORY_MISC] = "misc", | ||
137 | }; | 169 | }; |
138 | 170 | ||
139 | /* Permit policy management by non-root user? */ | 171 | /* Permit policy management by non-root user? */ |
@@ -230,13 +262,17 @@ static void tomoyo_set_string(struct tomoyo_io_buffer *head, const char *string) | |||
230 | WARN_ON(1); | 262 | WARN_ON(1); |
231 | } | 263 | } |
232 | 264 | ||
265 | static void tomoyo_io_printf(struct tomoyo_io_buffer *head, const char *fmt, | ||
266 | ...) __printf(2, 3); | ||
267 | |||
233 | /** | 268 | /** |
234 | * tomoyo_io_printf - printf() to "struct tomoyo_io_buffer" structure. | 269 | * tomoyo_io_printf - printf() to "struct tomoyo_io_buffer" structure. |
235 | * | 270 | * |
236 | * @head: Pointer to "struct tomoyo_io_buffer". | 271 | * @head: Pointer to "struct tomoyo_io_buffer". |
237 | * @fmt: The printf()'s format string, followed by parameters. | 272 | * @fmt: The printf()'s format string, followed by parameters. |
238 | */ | 273 | */ |
239 | void tomoyo_io_printf(struct tomoyo_io_buffer *head, const char *fmt, ...) | 274 | static void tomoyo_io_printf(struct tomoyo_io_buffer *head, const char *fmt, |
275 | ...) | ||
240 | { | 276 | { |
241 | va_list args; | 277 | va_list args; |
242 | size_t len; | 278 | size_t len; |
@@ -313,7 +349,7 @@ void tomoyo_init_policy_namespace(struct tomoyo_policy_namespace *ns) | |||
313 | INIT_LIST_HEAD(&ns->group_list[idx]); | 349 | INIT_LIST_HEAD(&ns->group_list[idx]); |
314 | for (idx = 0; idx < TOMOYO_MAX_POLICY; idx++) | 350 | for (idx = 0; idx < TOMOYO_MAX_POLICY; idx++) |
315 | INIT_LIST_HEAD(&ns->policy_list[idx]); | 351 | INIT_LIST_HEAD(&ns->policy_list[idx]); |
316 | ns->profile_version = 20100903; | 352 | ns->profile_version = 20110903; |
317 | tomoyo_namespace_enabled = !list_empty(&tomoyo_namespace_list); | 353 | tomoyo_namespace_enabled = !list_empty(&tomoyo_namespace_list); |
318 | list_add_tail_rcu(&ns->namespace_list, &tomoyo_namespace_list); | 354 | list_add_tail_rcu(&ns->namespace_list, &tomoyo_namespace_list); |
319 | } | 355 | } |
@@ -466,8 +502,10 @@ static struct tomoyo_profile *tomoyo_assign_profile | |||
466 | TOMOYO_CONFIG_WANT_REJECT_LOG; | 502 | TOMOYO_CONFIG_WANT_REJECT_LOG; |
467 | memset(ptr->config, TOMOYO_CONFIG_USE_DEFAULT, | 503 | memset(ptr->config, TOMOYO_CONFIG_USE_DEFAULT, |
468 | sizeof(ptr->config)); | 504 | sizeof(ptr->config)); |
469 | ptr->pref[TOMOYO_PREF_MAX_AUDIT_LOG] = 1024; | 505 | ptr->pref[TOMOYO_PREF_MAX_AUDIT_LOG] = |
470 | ptr->pref[TOMOYO_PREF_MAX_LEARNING_ENTRY] = 2048; | 506 | CONFIG_SECURITY_TOMOYO_MAX_AUDIT_LOG; |
507 | ptr->pref[TOMOYO_PREF_MAX_LEARNING_ENTRY] = | ||
508 | CONFIG_SECURITY_TOMOYO_MAX_ACCEPT_ENTRY; | ||
471 | mb(); /* Avoid out-of-order execution. */ | 509 | mb(); /* Avoid out-of-order execution. */ |
472 | ns->profile_ptr[profile] = ptr; | 510 | ns->profile_ptr[profile] = ptr; |
473 | entry = NULL; | 511 | entry = NULL; |
@@ -951,14 +989,12 @@ static bool tomoyo_select_domain(struct tomoyo_io_buffer *head, | |||
951 | (global_pid = true, sscanf(data, "global-pid=%u", &pid) == 1)) { | 989 | (global_pid = true, sscanf(data, "global-pid=%u", &pid) == 1)) { |
952 | struct task_struct *p; | 990 | struct task_struct *p; |
953 | rcu_read_lock(); | 991 | rcu_read_lock(); |
954 | read_lock(&tasklist_lock); | ||
955 | if (global_pid) | 992 | if (global_pid) |
956 | p = find_task_by_pid_ns(pid, &init_pid_ns); | 993 | p = find_task_by_pid_ns(pid, &init_pid_ns); |
957 | else | 994 | else |
958 | p = find_task_by_vpid(pid); | 995 | p = find_task_by_vpid(pid); |
959 | if (p) | 996 | if (p) |
960 | domain = tomoyo_real_domain(p); | 997 | domain = tomoyo_real_domain(p); |
961 | read_unlock(&tasklist_lock); | ||
962 | rcu_read_unlock(); | 998 | rcu_read_unlock(); |
963 | } else if (!strncmp(data, "domain=", 7)) { | 999 | } else if (!strncmp(data, "domain=", 7)) { |
964 | if (tomoyo_domain_def(data + 7)) | 1000 | if (tomoyo_domain_def(data + 7)) |
@@ -982,6 +1018,48 @@ static bool tomoyo_select_domain(struct tomoyo_io_buffer *head, | |||
982 | } | 1018 | } |
983 | 1019 | ||
984 | /** | 1020 | /** |
1021 | * tomoyo_same_task_acl - Check for duplicated "struct tomoyo_task_acl" entry. | ||
1022 | * | ||
1023 | * @a: Pointer to "struct tomoyo_acl_info". | ||
1024 | * @b: Pointer to "struct tomoyo_acl_info". | ||
1025 | * | ||
1026 | * Returns true if @a == @b, false otherwise. | ||
1027 | */ | ||
1028 | static bool tomoyo_same_task_acl(const struct tomoyo_acl_info *a, | ||
1029 | const struct tomoyo_acl_info *b) | ||
1030 | { | ||
1031 | const struct tomoyo_task_acl *p1 = container_of(a, typeof(*p1), head); | ||
1032 | const struct tomoyo_task_acl *p2 = container_of(b, typeof(*p2), head); | ||
1033 | return p1->domainname == p2->domainname; | ||
1034 | } | ||
1035 | |||
1036 | /** | ||
1037 | * tomoyo_write_task - Update task related list. | ||
1038 | * | ||
1039 | * @param: Pointer to "struct tomoyo_acl_param". | ||
1040 | * | ||
1041 | * Returns 0 on success, negative value otherwise. | ||
1042 | * | ||
1043 | * Caller holds tomoyo_read_lock(). | ||
1044 | */ | ||
1045 | static int tomoyo_write_task(struct tomoyo_acl_param *param) | ||
1046 | { | ||
1047 | int error = -EINVAL; | ||
1048 | if (tomoyo_str_starts(¶m->data, "manual_domain_transition ")) { | ||
1049 | struct tomoyo_task_acl e = { | ||
1050 | .head.type = TOMOYO_TYPE_MANUAL_TASK_ACL, | ||
1051 | .domainname = tomoyo_get_domainname(param), | ||
1052 | }; | ||
1053 | if (e.domainname) | ||
1054 | error = tomoyo_update_domain(&e.head, sizeof(e), param, | ||
1055 | tomoyo_same_task_acl, | ||
1056 | NULL); | ||
1057 | tomoyo_put_name(e.domainname); | ||
1058 | } | ||
1059 | return error; | ||
1060 | } | ||
1061 | |||
1062 | /** | ||
985 | * tomoyo_delete_domain - Delete a domain. | 1063 | * tomoyo_delete_domain - Delete a domain. |
986 | * | 1064 | * |
987 | * @domainname: The name of domain. | 1065 | * @domainname: The name of domain. |
@@ -1039,11 +1117,16 @@ static int tomoyo_write_domain2(struct tomoyo_policy_namespace *ns, | |||
1039 | static const struct { | 1117 | static const struct { |
1040 | const char *keyword; | 1118 | const char *keyword; |
1041 | int (*write) (struct tomoyo_acl_param *); | 1119 | int (*write) (struct tomoyo_acl_param *); |
1042 | } tomoyo_callback[1] = { | 1120 | } tomoyo_callback[5] = { |
1043 | { "file ", tomoyo_write_file }, | 1121 | { "file ", tomoyo_write_file }, |
1122 | { "network inet ", tomoyo_write_inet_network }, | ||
1123 | { "network unix ", tomoyo_write_unix_network }, | ||
1124 | { "misc ", tomoyo_write_misc }, | ||
1125 | { "task ", tomoyo_write_task }, | ||
1044 | }; | 1126 | }; |
1045 | u8 i; | 1127 | u8 i; |
1046 | for (i = 0; i < 1; i++) { | 1128 | |
1129 | for (i = 0; i < ARRAY_SIZE(tomoyo_callback); i++) { | ||
1047 | if (!tomoyo_str_starts(¶m.data, | 1130 | if (!tomoyo_str_starts(¶m.data, |
1048 | tomoyo_callback[i].keyword)) | 1131 | tomoyo_callback[i].keyword)) |
1049 | continue; | 1132 | continue; |
@@ -1127,6 +1210,10 @@ static bool tomoyo_print_condition(struct tomoyo_io_buffer *head, | |||
1127 | case 0: | 1210 | case 0: |
1128 | head->r.cond_index = 0; | 1211 | head->r.cond_index = 0; |
1129 | head->r.cond_step++; | 1212 | head->r.cond_step++; |
1213 | if (cond->transit) { | ||
1214 | tomoyo_set_space(head); | ||
1215 | tomoyo_set_string(head, cond->transit->name); | ||
1216 | } | ||
1130 | /* fall through */ | 1217 | /* fall through */ |
1131 | case 1: | 1218 | case 1: |
1132 | { | 1219 | { |
@@ -1239,6 +1326,10 @@ static bool tomoyo_print_condition(struct tomoyo_io_buffer *head, | |||
1239 | head->r.cond_step++; | 1326 | head->r.cond_step++; |
1240 | /* fall through */ | 1327 | /* fall through */ |
1241 | case 3: | 1328 | case 3: |
1329 | if (cond->grant_log != TOMOYO_GRANTLOG_AUTO) | ||
1330 | tomoyo_io_printf(head, " grant_log=%s", | ||
1331 | tomoyo_yesno(cond->grant_log == | ||
1332 | TOMOYO_GRANTLOG_YES)); | ||
1242 | tomoyo_set_lf(head); | 1333 | tomoyo_set_lf(head); |
1243 | return true; | 1334 | return true; |
1244 | } | 1335 | } |
@@ -1306,6 +1397,12 @@ static bool tomoyo_print_entry(struct tomoyo_io_buffer *head, | |||
1306 | if (first) | 1397 | if (first) |
1307 | return true; | 1398 | return true; |
1308 | tomoyo_print_name_union(head, &ptr->name); | 1399 | tomoyo_print_name_union(head, &ptr->name); |
1400 | } else if (acl_type == TOMOYO_TYPE_MANUAL_TASK_ACL) { | ||
1401 | struct tomoyo_task_acl *ptr = | ||
1402 | container_of(acl, typeof(*ptr), head); | ||
1403 | tomoyo_set_group(head, "task "); | ||
1404 | tomoyo_set_string(head, "manual_domain_transition "); | ||
1405 | tomoyo_set_string(head, ptr->domainname->name); | ||
1309 | } else if (head->r.print_transition_related_only) { | 1406 | } else if (head->r.print_transition_related_only) { |
1310 | return true; | 1407 | return true; |
1311 | } else if (acl_type == TOMOYO_TYPE_PATH2_ACL) { | 1408 | } else if (acl_type == TOMOYO_TYPE_PATH2_ACL) { |
@@ -1370,6 +1467,60 @@ static bool tomoyo_print_entry(struct tomoyo_io_buffer *head, | |||
1370 | tomoyo_print_number_union(head, &ptr->mode); | 1467 | tomoyo_print_number_union(head, &ptr->mode); |
1371 | tomoyo_print_number_union(head, &ptr->major); | 1468 | tomoyo_print_number_union(head, &ptr->major); |
1372 | tomoyo_print_number_union(head, &ptr->minor); | 1469 | tomoyo_print_number_union(head, &ptr->minor); |
1470 | } else if (acl_type == TOMOYO_TYPE_INET_ACL) { | ||
1471 | struct tomoyo_inet_acl *ptr = | ||
1472 | container_of(acl, typeof(*ptr), head); | ||
1473 | const u8 perm = ptr->perm; | ||
1474 | |||
1475 | for (bit = 0; bit < TOMOYO_MAX_NETWORK_OPERATION; bit++) { | ||
1476 | if (!(perm & (1 << bit))) | ||
1477 | continue; | ||
1478 | if (first) { | ||
1479 | tomoyo_set_group(head, "network inet "); | ||
1480 | tomoyo_set_string(head, tomoyo_proto_keyword | ||
1481 | [ptr->protocol]); | ||
1482 | tomoyo_set_space(head); | ||
1483 | first = false; | ||
1484 | } else { | ||
1485 | tomoyo_set_slash(head); | ||
1486 | } | ||
1487 | tomoyo_set_string(head, tomoyo_socket_keyword[bit]); | ||
1488 | } | ||
1489 | if (first) | ||
1490 | return true; | ||
1491 | tomoyo_set_space(head); | ||
1492 | if (ptr->address.group) { | ||
1493 | tomoyo_set_string(head, "@"); | ||
1494 | tomoyo_set_string(head, ptr->address.group->group_name | ||
1495 | ->name); | ||
1496 | } else { | ||
1497 | char buf[128]; | ||
1498 | tomoyo_print_ip(buf, sizeof(buf), &ptr->address); | ||
1499 | tomoyo_io_printf(head, "%s", buf); | ||
1500 | } | ||
1501 | tomoyo_print_number_union(head, &ptr->port); | ||
1502 | } else if (acl_type == TOMOYO_TYPE_UNIX_ACL) { | ||
1503 | struct tomoyo_unix_acl *ptr = | ||
1504 | container_of(acl, typeof(*ptr), head); | ||
1505 | const u8 perm = ptr->perm; | ||
1506 | |||
1507 | for (bit = 0; bit < TOMOYO_MAX_NETWORK_OPERATION; bit++) { | ||
1508 | if (!(perm & (1 << bit))) | ||
1509 | continue; | ||
1510 | if (first) { | ||
1511 | tomoyo_set_group(head, "network unix "); | ||
1512 | tomoyo_set_string(head, tomoyo_proto_keyword | ||
1513 | [ptr->protocol]); | ||
1514 | tomoyo_set_space(head); | ||
1515 | first = false; | ||
1516 | } else { | ||
1517 | tomoyo_set_slash(head); | ||
1518 | } | ||
1519 | tomoyo_set_string(head, tomoyo_socket_keyword[bit]); | ||
1520 | } | ||
1521 | if (first) | ||
1522 | return true; | ||
1523 | tomoyo_print_name_union(head, &ptr->name); | ||
1373 | } else if (acl_type == TOMOYO_TYPE_MOUNT_ACL) { | 1524 | } else if (acl_type == TOMOYO_TYPE_MOUNT_ACL) { |
1374 | struct tomoyo_mount_acl *ptr = | 1525 | struct tomoyo_mount_acl *ptr = |
1375 | container_of(acl, typeof(*ptr), head); | 1526 | container_of(acl, typeof(*ptr), head); |
@@ -1378,6 +1529,12 @@ static bool tomoyo_print_entry(struct tomoyo_io_buffer *head, | |||
1378 | tomoyo_print_name_union(head, &ptr->dir_name); | 1529 | tomoyo_print_name_union(head, &ptr->dir_name); |
1379 | tomoyo_print_name_union(head, &ptr->fs_type); | 1530 | tomoyo_print_name_union(head, &ptr->fs_type); |
1380 | tomoyo_print_number_union(head, &ptr->flags); | 1531 | tomoyo_print_number_union(head, &ptr->flags); |
1532 | } else if (acl_type == TOMOYO_TYPE_ENV_ACL) { | ||
1533 | struct tomoyo_env_acl *ptr = | ||
1534 | container_of(acl, typeof(*ptr), head); | ||
1535 | |||
1536 | tomoyo_set_group(head, "misc env "); | ||
1537 | tomoyo_set_string(head, ptr->env->name); | ||
1381 | } | 1538 | } |
1382 | if (acl->cond) { | 1539 | if (acl->cond) { |
1383 | head->r.print_cond_part = true; | 1540 | head->r.print_cond_part = true; |
@@ -1510,14 +1667,12 @@ static void tomoyo_read_pid(struct tomoyo_io_buffer *head) | |||
1510 | global_pid = true; | 1667 | global_pid = true; |
1511 | pid = (unsigned int) simple_strtoul(buf, NULL, 10); | 1668 | pid = (unsigned int) simple_strtoul(buf, NULL, 10); |
1512 | rcu_read_lock(); | 1669 | rcu_read_lock(); |
1513 | read_lock(&tasklist_lock); | ||
1514 | if (global_pid) | 1670 | if (global_pid) |
1515 | p = find_task_by_pid_ns(pid, &init_pid_ns); | 1671 | p = find_task_by_pid_ns(pid, &init_pid_ns); |
1516 | else | 1672 | else |
1517 | p = find_task_by_vpid(pid); | 1673 | p = find_task_by_vpid(pid); |
1518 | if (p) | 1674 | if (p) |
1519 | domain = tomoyo_real_domain(p); | 1675 | domain = tomoyo_real_domain(p); |
1520 | read_unlock(&tasklist_lock); | ||
1521 | rcu_read_unlock(); | 1676 | rcu_read_unlock(); |
1522 | if (!domain) | 1677 | if (!domain) |
1523 | return; | 1678 | return; |
@@ -1537,8 +1692,9 @@ static const char *tomoyo_transition_type[TOMOYO_MAX_TRANSITION_TYPE] = { | |||
1537 | 1692 | ||
1538 | /* String table for grouping keywords. */ | 1693 | /* String table for grouping keywords. */ |
1539 | static const char *tomoyo_group_name[TOMOYO_MAX_GROUP] = { | 1694 | static const char *tomoyo_group_name[TOMOYO_MAX_GROUP] = { |
1540 | [TOMOYO_PATH_GROUP] = "path_group ", | 1695 | [TOMOYO_PATH_GROUP] = "path_group ", |
1541 | [TOMOYO_NUMBER_GROUP] = "number_group ", | 1696 | [TOMOYO_NUMBER_GROUP] = "number_group ", |
1697 | [TOMOYO_ADDRESS_GROUP] = "address_group ", | ||
1542 | }; | 1698 | }; |
1543 | 1699 | ||
1544 | /** | 1700 | /** |
@@ -1580,7 +1736,7 @@ static int tomoyo_write_exception(struct tomoyo_io_buffer *head) | |||
1580 | } | 1736 | } |
1581 | 1737 | ||
1582 | /** | 1738 | /** |
1583 | * tomoyo_read_group - Read "struct tomoyo_path_group"/"struct tomoyo_number_group" list. | 1739 | * tomoyo_read_group - Read "struct tomoyo_path_group"/"struct tomoyo_number_group"/"struct tomoyo_address_group" list. |
1584 | * | 1740 | * |
1585 | * @head: Pointer to "struct tomoyo_io_buffer". | 1741 | * @head: Pointer to "struct tomoyo_io_buffer". |
1586 | * @idx: Index number. | 1742 | * @idx: Index number. |
@@ -1617,6 +1773,15 @@ static bool tomoyo_read_group(struct tomoyo_io_buffer *head, const int idx) | |||
1617 | (ptr, | 1773 | (ptr, |
1618 | struct tomoyo_number_group, | 1774 | struct tomoyo_number_group, |
1619 | head)->number); | 1775 | head)->number); |
1776 | } else if (idx == TOMOYO_ADDRESS_GROUP) { | ||
1777 | char buffer[128]; | ||
1778 | |||
1779 | struct tomoyo_address_group *member = | ||
1780 | container_of(ptr, typeof(*member), | ||
1781 | head); | ||
1782 | tomoyo_print_ip(buffer, sizeof(buffer), | ||
1783 | &member->address); | ||
1784 | tomoyo_io_printf(head, " %s", buffer); | ||
1620 | } | 1785 | } |
1621 | tomoyo_set_lf(head); | 1786 | tomoyo_set_lf(head); |
1622 | } | 1787 | } |
@@ -2066,27 +2231,7 @@ static int tomoyo_write_answer(struct tomoyo_io_buffer *head) | |||
2066 | static void tomoyo_read_version(struct tomoyo_io_buffer *head) | 2231 | static void tomoyo_read_version(struct tomoyo_io_buffer *head) |
2067 | { | 2232 | { |
2068 | if (!head->r.eof) { | 2233 | if (!head->r.eof) { |
2069 | tomoyo_io_printf(head, "2.4.0"); | 2234 | tomoyo_io_printf(head, "2.5.0"); |
2070 | head->r.eof = true; | ||
2071 | } | ||
2072 | } | ||
2073 | |||
2074 | /** | ||
2075 | * tomoyo_read_self_domain - Get the current process's domainname. | ||
2076 | * | ||
2077 | * @head: Pointer to "struct tomoyo_io_buffer". | ||
2078 | * | ||
2079 | * Returns the current process's domainname. | ||
2080 | */ | ||
2081 | static void tomoyo_read_self_domain(struct tomoyo_io_buffer *head) | ||
2082 | { | ||
2083 | if (!head->r.eof) { | ||
2084 | /* | ||
2085 | * tomoyo_domain()->domainname != NULL | ||
2086 | * because every process belongs to a domain and | ||
2087 | * the domain's name cannot be NULL. | ||
2088 | */ | ||
2089 | tomoyo_io_printf(head, "%s", tomoyo_domain()->domainname->name); | ||
2090 | head->r.eof = true; | 2235 | head->r.eof = true; |
2091 | } | 2236 | } |
2092 | } | 2237 | } |
@@ -2221,10 +2366,6 @@ int tomoyo_open_control(const u8 type, struct file *file) | |||
2221 | head->poll = tomoyo_poll_log; | 2366 | head->poll = tomoyo_poll_log; |
2222 | head->read = tomoyo_read_log; | 2367 | head->read = tomoyo_read_log; |
2223 | break; | 2368 | break; |
2224 | case TOMOYO_SELFDOMAIN: | ||
2225 | /* /sys/kernel/security/tomoyo/self_domain */ | ||
2226 | head->read = tomoyo_read_self_domain; | ||
2227 | break; | ||
2228 | case TOMOYO_PROCESS_STATUS: | 2369 | case TOMOYO_PROCESS_STATUS: |
2229 | /* /sys/kernel/security/tomoyo/.process_status */ | 2370 | /* /sys/kernel/security/tomoyo/.process_status */ |
2230 | head->write = tomoyo_write_pid; | 2371 | head->write = tomoyo_write_pid; |
@@ -2453,6 +2594,7 @@ ssize_t tomoyo_write_control(struct tomoyo_io_buffer *head, | |||
2453 | return -EFAULT; | 2594 | return -EFAULT; |
2454 | if (mutex_lock_interruptible(&head->io_sem)) | 2595 | if (mutex_lock_interruptible(&head->io_sem)) |
2455 | return -EINTR; | 2596 | return -EINTR; |
2597 | head->read_user_buf_avail = 0; | ||
2456 | idx = tomoyo_read_lock(); | 2598 | idx = tomoyo_read_lock(); |
2457 | /* Read a line and dispatch it to the policy handler. */ | 2599 | /* Read a line and dispatch it to the policy handler. */ |
2458 | while (avail_len > 0) { | 2600 | while (avail_len > 0) { |
@@ -2562,11 +2704,11 @@ void tomoyo_check_profile(void) | |||
2562 | struct tomoyo_domain_info *domain; | 2704 | struct tomoyo_domain_info *domain; |
2563 | const int idx = tomoyo_read_lock(); | 2705 | const int idx = tomoyo_read_lock(); |
2564 | tomoyo_policy_loaded = true; | 2706 | tomoyo_policy_loaded = true; |
2565 | printk(KERN_INFO "TOMOYO: 2.4.0\n"); | 2707 | printk(KERN_INFO "TOMOYO: 2.5.0\n"); |
2566 | list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) { | 2708 | list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) { |
2567 | const u8 profile = domain->profile; | 2709 | const u8 profile = domain->profile; |
2568 | const struct tomoyo_policy_namespace *ns = domain->ns; | 2710 | const struct tomoyo_policy_namespace *ns = domain->ns; |
2569 | if (ns->profile_version != 20100903) | 2711 | if (ns->profile_version != 20110903) |
2570 | printk(KERN_ERR | 2712 | printk(KERN_ERR |
2571 | "Profile version %u is not supported.\n", | 2713 | "Profile version %u is not supported.\n", |
2572 | ns->profile_version); | 2714 | ns->profile_version); |
@@ -2577,9 +2719,9 @@ void tomoyo_check_profile(void) | |||
2577 | else | 2719 | else |
2578 | continue; | 2720 | continue; |
2579 | printk(KERN_ERR | 2721 | printk(KERN_ERR |
2580 | "Userland tools for TOMOYO 2.4 must be installed and " | 2722 | "Userland tools for TOMOYO 2.5 must be installed and " |
2581 | "policy must be initialized.\n"); | 2723 | "policy must be initialized.\n"); |
2582 | printk(KERN_ERR "Please see http://tomoyo.sourceforge.jp/2.4/ " | 2724 | printk(KERN_ERR "Please see http://tomoyo.sourceforge.jp/2.5/ " |
2583 | "for more information.\n"); | 2725 | "for more information.\n"); |
2584 | panic("STOP!"); | 2726 | panic("STOP!"); |
2585 | } | 2727 | } |