diff options
-rw-r--r-- | security/tomoyo/audit.c | 4 | ||||
-rw-r--r-- | security/tomoyo/common.c | 14 | ||||
-rw-r--r-- | security/tomoyo/domain.c | 12 | ||||
-rw-r--r-- | security/tomoyo/file.c | 22 | ||||
-rw-r--r-- | security/tomoyo/gc.c | 7 | ||||
-rw-r--r-- | security/tomoyo/group.c | 28 | ||||
-rw-r--r-- | security/tomoyo/load_policy.c | 4 | ||||
-rw-r--r-- | security/tomoyo/memory.c | 4 | ||||
-rw-r--r-- | security/tomoyo/mount.c | 10 | ||||
-rw-r--r-- | security/tomoyo/realpath.c | 4 | ||||
-rw-r--r-- | security/tomoyo/securityfs_if.c | 6 | ||||
-rw-r--r-- | security/tomoyo/tomoyo.c | 210 | ||||
-rw-r--r-- | security/tomoyo/util.c | 6 |
13 files changed, 269 insertions, 62 deletions
diff --git a/security/tomoyo/audit.c b/security/tomoyo/audit.c index eefedd9e48e6..5dbb1f7617c0 100644 --- a/security/tomoyo/audit.c +++ b/security/tomoyo/audit.c | |||
@@ -1,9 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * security/tomoyo/audit.c | 2 | * security/tomoyo/audit.c |
3 | * | 3 | * |
4 | * Pathname restriction functions. | 4 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
5 | * | ||
6 | * Copyright (C) 2005-2010 NTT DATA CORPORATION | ||
7 | */ | 5 | */ |
8 | 6 | ||
9 | #include "common.h" | 7 | #include "common.h" |
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c index 4f9047e94bd1..c8439cf2a448 100644 --- a/security/tomoyo/common.c +++ b/security/tomoyo/common.c | |||
@@ -1,9 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * security/tomoyo/common.c | 2 | * security/tomoyo/common.c |
3 | * | 3 | * |
4 | * Common functions for TOMOYO. | 4 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
5 | * | ||
6 | * Copyright (C) 2005-2010 NTT DATA CORPORATION | ||
7 | */ | 5 | */ |
8 | 6 | ||
9 | #include <linux/uaccess.h> | 7 | #include <linux/uaccess.h> |
@@ -775,6 +773,14 @@ static void tomoyo_read_profile(struct tomoyo_io_buffer *head) | |||
775 | goto next; | 773 | goto next; |
776 | } | 774 | } |
777 | 775 | ||
776 | /** | ||
777 | * tomoyo_same_manager - Check for duplicated "struct tomoyo_manager" entry. | ||
778 | * | ||
779 | * @a: Pointer to "struct tomoyo_acl_head". | ||
780 | * @b: Pointer to "struct tomoyo_acl_head". | ||
781 | * | ||
782 | * Returns true if @a == @b, false otherwise. | ||
783 | */ | ||
778 | static bool tomoyo_same_manager(const struct tomoyo_acl_head *a, | 784 | static bool tomoyo_same_manager(const struct tomoyo_acl_head *a, |
779 | const struct tomoyo_acl_head *b) | 785 | const struct tomoyo_acl_head *b) |
780 | { | 786 | { |
@@ -1516,6 +1522,7 @@ static void tomoyo_read_pid(struct tomoyo_io_buffer *head) | |||
1516 | tomoyo_set_string(head, domain->domainname->name); | 1522 | tomoyo_set_string(head, domain->domainname->name); |
1517 | } | 1523 | } |
1518 | 1524 | ||
1525 | /* String table for domain transition control keywords. */ | ||
1519 | static const char *tomoyo_transition_type[TOMOYO_MAX_TRANSITION_TYPE] = { | 1526 | static const char *tomoyo_transition_type[TOMOYO_MAX_TRANSITION_TYPE] = { |
1520 | [TOMOYO_TRANSITION_CONTROL_NO_RESET] = "no_reset_domain ", | 1527 | [TOMOYO_TRANSITION_CONTROL_NO_RESET] = "no_reset_domain ", |
1521 | [TOMOYO_TRANSITION_CONTROL_RESET] = "reset_domain ", | 1528 | [TOMOYO_TRANSITION_CONTROL_RESET] = "reset_domain ", |
@@ -1525,6 +1532,7 @@ static const char *tomoyo_transition_type[TOMOYO_MAX_TRANSITION_TYPE] = { | |||
1525 | [TOMOYO_TRANSITION_CONTROL_KEEP] = "keep_domain ", | 1532 | [TOMOYO_TRANSITION_CONTROL_KEEP] = "keep_domain ", |
1526 | }; | 1533 | }; |
1527 | 1534 | ||
1535 | /* String table for grouping keywords. */ | ||
1528 | static const char *tomoyo_group_name[TOMOYO_MAX_GROUP] = { | 1536 | static const char *tomoyo_group_name[TOMOYO_MAX_GROUP] = { |
1529 | [TOMOYO_PATH_GROUP] = "path_group ", | 1537 | [TOMOYO_PATH_GROUP] = "path_group ", |
1530 | [TOMOYO_NUMBER_GROUP] = "number_group ", | 1538 | [TOMOYO_NUMBER_GROUP] = "number_group ", |
diff --git a/security/tomoyo/domain.c b/security/tomoyo/domain.c index 878d0206f43e..cd0f92d88bb4 100644 --- a/security/tomoyo/domain.c +++ b/security/tomoyo/domain.c | |||
@@ -1,9 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * security/tomoyo/domain.c | 2 | * security/tomoyo/domain.c |
3 | * | 3 | * |
4 | * Domain transition functions for TOMOYO. | 4 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
5 | * | ||
6 | * Copyright (C) 2005-2010 NTT DATA CORPORATION | ||
7 | */ | 5 | */ |
8 | 6 | ||
9 | #include "common.h" | 7 | #include "common.h" |
@@ -182,10 +180,10 @@ LIST_HEAD(tomoyo_domain_list); | |||
182 | */ | 180 | */ |
183 | static const char *tomoyo_last_word(const char *name) | 181 | static const char *tomoyo_last_word(const char *name) |
184 | { | 182 | { |
185 | const char *cp = strrchr(name, ' '); | 183 | const char *cp = strrchr(name, ' '); |
186 | if (cp) | 184 | if (cp) |
187 | return cp + 1; | 185 | return cp + 1; |
188 | return name; | 186 | return name; |
189 | } | 187 | } |
190 | 188 | ||
191 | /** | 189 | /** |
diff --git a/security/tomoyo/file.c b/security/tomoyo/file.c index 31a9a4ab7af9..743c35f5084a 100644 --- a/security/tomoyo/file.c +++ b/security/tomoyo/file.c | |||
@@ -1,9 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * security/tomoyo/file.c | 2 | * security/tomoyo/file.c |
3 | * | 3 | * |
4 | * Pathname restriction functions. | 4 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
5 | * | ||
6 | * Copyright (C) 2005-2010 NTT DATA CORPORATION | ||
7 | */ | 5 | */ |
8 | 6 | ||
9 | #include "common.h" | 7 | #include "common.h" |
@@ -154,7 +152,7 @@ static bool tomoyo_get_realpath(struct tomoyo_path_info *buf, struct path *path) | |||
154 | tomoyo_fill_path_info(buf); | 152 | tomoyo_fill_path_info(buf); |
155 | return true; | 153 | return true; |
156 | } | 154 | } |
157 | return false; | 155 | return false; |
158 | } | 156 | } |
159 | 157 | ||
160 | /** | 158 | /** |
@@ -883,16 +881,16 @@ int tomoyo_path2_perm(const u8 operation, struct path *path1, | |||
883 | switch (operation) { | 881 | switch (operation) { |
884 | struct dentry *dentry; | 882 | struct dentry *dentry; |
885 | case TOMOYO_TYPE_RENAME: | 883 | case TOMOYO_TYPE_RENAME: |
886 | case TOMOYO_TYPE_LINK: | 884 | case TOMOYO_TYPE_LINK: |
887 | dentry = path1->dentry; | 885 | dentry = path1->dentry; |
888 | if (!dentry->d_inode || !S_ISDIR(dentry->d_inode->i_mode)) | 886 | if (!dentry->d_inode || !S_ISDIR(dentry->d_inode->i_mode)) |
889 | break; | 887 | break; |
890 | /* fall through */ | 888 | /* fall through */ |
891 | case TOMOYO_TYPE_PIVOT_ROOT: | 889 | case TOMOYO_TYPE_PIVOT_ROOT: |
892 | tomoyo_add_slash(&buf1); | 890 | tomoyo_add_slash(&buf1); |
893 | tomoyo_add_slash(&buf2); | 891 | tomoyo_add_slash(&buf2); |
894 | break; | 892 | break; |
895 | } | 893 | } |
896 | r.obj = &obj; | 894 | r.obj = &obj; |
897 | r.param_type = TOMOYO_TYPE_PATH2_ACL; | 895 | r.param_type = TOMOYO_TYPE_PATH2_ACL; |
898 | r.param.path2.operation = operation; | 896 | r.param.path2.operation = operation; |
diff --git a/security/tomoyo/gc.c b/security/tomoyo/gc.c index 1ac3312059f6..ae135fbbbe95 100644 --- a/security/tomoyo/gc.c +++ b/security/tomoyo/gc.c | |||
@@ -1,10 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * security/tomoyo/gc.c | 2 | * security/tomoyo/gc.c |
3 | * | 3 | * |
4 | * Implementation of the Domain-Based Mandatory Access Control. | 4 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
5 | * | ||
6 | * Copyright (C) 2005-2010 NTT DATA CORPORATION | ||
7 | * | ||
8 | */ | 5 | */ |
9 | 6 | ||
10 | #include "common.h" | 7 | #include "common.h" |
@@ -455,7 +452,7 @@ static bool tomoyo_collect_member(const enum tomoyo_policy_id id, | |||
455 | if (!tomoyo_add_to_gc(id, &member->list)) | 452 | if (!tomoyo_add_to_gc(id, &member->list)) |
456 | return false; | 453 | return false; |
457 | } | 454 | } |
458 | return true; | 455 | return true; |
459 | } | 456 | } |
460 | 457 | ||
461 | /** | 458 | /** |
diff --git a/security/tomoyo/group.c b/security/tomoyo/group.c index 2e5b7bc73264..5fb0e1298400 100644 --- a/security/tomoyo/group.c +++ b/security/tomoyo/group.c | |||
@@ -1,21 +1,37 @@ | |||
1 | /* | 1 | /* |
2 | * security/tomoyo/group.c | 2 | * security/tomoyo/group.c |
3 | * | 3 | * |
4 | * Copyright (C) 2005-2010 NTT DATA CORPORATION | 4 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <linux/slab.h> | 7 | #include <linux/slab.h> |
8 | #include "common.h" | 8 | #include "common.h" |
9 | 9 | ||
10 | /** | ||
11 | * tomoyo_same_path_group - Check for duplicated "struct tomoyo_path_group" entry. | ||
12 | * | ||
13 | * @a: Pointer to "struct tomoyo_acl_head". | ||
14 | * @b: Pointer to "struct tomoyo_acl_head". | ||
15 | * | ||
16 | * Returns true if @a == @b, false otherwise. | ||
17 | */ | ||
10 | static bool tomoyo_same_path_group(const struct tomoyo_acl_head *a, | 18 | static bool tomoyo_same_path_group(const struct tomoyo_acl_head *a, |
11 | const struct tomoyo_acl_head *b) | 19 | const struct tomoyo_acl_head *b) |
12 | { | 20 | { |
13 | return container_of(a, struct tomoyo_path_group, head)->member_name == | 21 | return container_of(a, struct tomoyo_path_group, head)->member_name == |
14 | container_of(b, struct tomoyo_path_group, head)->member_name; | 22 | container_of(b, struct tomoyo_path_group, head)->member_name; |
15 | } | 23 | } |
16 | 24 | ||
25 | /** | ||
26 | * tomoyo_same_number_group - Check for duplicated "struct tomoyo_number_group" entry. | ||
27 | * | ||
28 | * @a: Pointer to "struct tomoyo_acl_head". | ||
29 | * @b: Pointer to "struct tomoyo_acl_head". | ||
30 | * | ||
31 | * Returns true if @a == @b, false otherwise. | ||
32 | */ | ||
17 | static bool tomoyo_same_number_group(const struct tomoyo_acl_head *a, | 33 | static bool tomoyo_same_number_group(const struct tomoyo_acl_head *a, |
18 | const struct tomoyo_acl_head *b) | 34 | const struct tomoyo_acl_head *b) |
19 | { | 35 | { |
20 | return !memcmp(&container_of(a, struct tomoyo_number_group, head) | 36 | return !memcmp(&container_of(a, struct tomoyo_number_group, head) |
21 | ->number, | 37 | ->number, |
@@ -29,7 +45,7 @@ static bool tomoyo_same_number_group(const struct tomoyo_acl_head *a, | |||
29 | * tomoyo_write_group - Write "struct tomoyo_path_group"/"struct tomoyo_number_group" list. | 45 | * tomoyo_write_group - Write "struct tomoyo_path_group"/"struct tomoyo_number_group" list. |
30 | * | 46 | * |
31 | * @param: Pointer to "struct tomoyo_acl_param". | 47 | * @param: Pointer to "struct tomoyo_acl_param". |
32 | * @type: Type of this group. | 48 | * @type: Type of this group. |
33 | * | 49 | * |
34 | * Returns 0 on success, negative value otherwise. | 50 | * Returns 0 on success, negative value otherwise. |
35 | */ | 51 | */ |
@@ -70,8 +86,8 @@ out: | |||
70 | /** | 86 | /** |
71 | * tomoyo_path_matches_group - Check whether the given pathname matches members of the given pathname group. | 87 | * tomoyo_path_matches_group - Check whether the given pathname matches members of the given pathname group. |
72 | * | 88 | * |
73 | * @pathname: The name of pathname. | 89 | * @pathname: The name of pathname. |
74 | * @group: Pointer to "struct tomoyo_path_group". | 90 | * @group: Pointer to "struct tomoyo_path_group". |
75 | * | 91 | * |
76 | * Returns matched member's pathname if @pathname matches pathnames in @group, | 92 | * Returns matched member's pathname if @pathname matches pathnames in @group, |
77 | * NULL otherwise. | 93 | * NULL otherwise. |
diff --git a/security/tomoyo/load_policy.c b/security/tomoyo/load_policy.c index 6a5463d26635..67975405140f 100644 --- a/security/tomoyo/load_policy.c +++ b/security/tomoyo/load_policy.c | |||
@@ -1,9 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * security/tomoyo/load_policy.c | 2 | * security/tomoyo/load_policy.c |
3 | * | 3 | * |
4 | * Policy loader launcher for TOMOYO. | 4 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
5 | * | ||
6 | * Copyright (C) 2005-2010 NTT DATA CORPORATION | ||
7 | */ | 5 | */ |
8 | 6 | ||
9 | #include "common.h" | 7 | #include "common.h" |
diff --git a/security/tomoyo/memory.c b/security/tomoyo/memory.c index 46538ce47d72..7a56051146c2 100644 --- a/security/tomoyo/memory.c +++ b/security/tomoyo/memory.c | |||
@@ -1,9 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * security/tomoyo/memory.c | 2 | * security/tomoyo/memory.c |
3 | * | 3 | * |
4 | * Memory management functions for TOMOYO. | 4 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
5 | * | ||
6 | * Copyright (C) 2005-2010 NTT DATA CORPORATION | ||
7 | */ | 5 | */ |
8 | 6 | ||
9 | #include <linux/hash.h> | 7 | #include <linux/hash.h> |
diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c index 408385307470..bee09d062057 100644 --- a/security/tomoyo/mount.c +++ b/security/tomoyo/mount.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * security/tomoyo/mount.c | 2 | * security/tomoyo/mount.c |
3 | * | 3 | * |
4 | * Copyright (C) 2005-2010 NTT DATA CORPORATION | 4 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <linux/slab.h> | 7 | #include <linux/slab.h> |
@@ -62,7 +62,7 @@ static bool tomoyo_check_mount_acl(struct tomoyo_request_info *r, | |||
62 | * tomoyo_mount_acl - Check permission for mount() operation. | 62 | * tomoyo_mount_acl - Check permission for mount() operation. |
63 | * | 63 | * |
64 | * @r: Pointer to "struct tomoyo_request_info". | 64 | * @r: Pointer to "struct tomoyo_request_info". |
65 | * @dev_name: Name of device file. | 65 | * @dev_name: Name of device file. Maybe NULL. |
66 | * @dir: Pointer to "struct path". | 66 | * @dir: Pointer to "struct path". |
67 | * @type: Name of filesystem type. | 67 | * @type: Name of filesystem type. |
68 | * @flags: Mount options. | 68 | * @flags: Mount options. |
@@ -175,11 +175,11 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r, char *dev_name, | |||
175 | /** | 175 | /** |
176 | * tomoyo_mount_permission - Check permission for mount() operation. | 176 | * tomoyo_mount_permission - Check permission for mount() operation. |
177 | * | 177 | * |
178 | * @dev_name: Name of device file. | 178 | * @dev_name: Name of device file. Maybe NULL. |
179 | * @path: Pointer to "struct path". | 179 | * @path: Pointer to "struct path". |
180 | * @type: Name of filesystem type. May be NULL. | 180 | * @type: Name of filesystem type. Maybe NULL. |
181 | * @flags: Mount options. | 181 | * @flags: Mount options. |
182 | * @data_page: Optional data. May be NULL. | 182 | * @data_page: Optional data. Maybe NULL. |
183 | * | 183 | * |
184 | * Returns 0 on success, negative value otherwise. | 184 | * Returns 0 on success, negative value otherwise. |
185 | */ | 185 | */ |
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c index 1a785777118b..6c601bd300f3 100644 --- a/security/tomoyo/realpath.c +++ b/security/tomoyo/realpath.c | |||
@@ -1,9 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * security/tomoyo/realpath.c | 2 | * security/tomoyo/realpath.c |
3 | * | 3 | * |
4 | * Pathname calculation functions for TOMOYO. | 4 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
5 | * | ||
6 | * Copyright (C) 2005-2010 NTT DATA CORPORATION | ||
7 | */ | 5 | */ |
8 | 6 | ||
9 | #include <linux/types.h> | 7 | #include <linux/types.h> |
diff --git a/security/tomoyo/securityfs_if.c b/security/tomoyo/securityfs_if.c index 888e83dd4cf6..a49c3bfd4dd5 100644 --- a/security/tomoyo/securityfs_if.c +++ b/security/tomoyo/securityfs_if.c | |||
@@ -1,9 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * security/tomoyo/common.c | 2 | * security/tomoyo/securityfs_if.c |
3 | * | 3 | * |
4 | * Securityfs interface for TOMOYO. | 4 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
5 | * | ||
6 | * Copyright (C) 2005-2010 NTT DATA CORPORATION | ||
7 | */ | 5 | */ |
8 | 6 | ||
9 | #include <linux/security.h> | 7 | #include <linux/security.h> |
diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c index a536cb182c05..f776400a8f31 100644 --- a/security/tomoyo/tomoyo.c +++ b/security/tomoyo/tomoyo.c | |||
@@ -1,20 +1,35 @@ | |||
1 | /* | 1 | /* |
2 | * security/tomoyo/tomoyo.c | 2 | * security/tomoyo/tomoyo.c |
3 | * | 3 | * |
4 | * LSM hooks for TOMOYO Linux. | 4 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
5 | * | ||
6 | * Copyright (C) 2005-2010 NTT DATA CORPORATION | ||
7 | */ | 5 | */ |
8 | 6 | ||
9 | #include <linux/security.h> | 7 | #include <linux/security.h> |
10 | #include "common.h" | 8 | #include "common.h" |
11 | 9 | ||
10 | /** | ||
11 | * tomoyo_cred_alloc_blank - Target for security_cred_alloc_blank(). | ||
12 | * | ||
13 | * @new: Pointer to "struct cred". | ||
14 | * @gfp: Memory allocation flags. | ||
15 | * | ||
16 | * Returns 0. | ||
17 | */ | ||
12 | static int tomoyo_cred_alloc_blank(struct cred *new, gfp_t gfp) | 18 | static int tomoyo_cred_alloc_blank(struct cred *new, gfp_t gfp) |
13 | { | 19 | { |
14 | new->security = NULL; | 20 | new->security = NULL; |
15 | return 0; | 21 | return 0; |
16 | } | 22 | } |
17 | 23 | ||
24 | /** | ||
25 | * tomoyo_cred_prepare - Target for security_prepare_creds(). | ||
26 | * | ||
27 | * @new: Pointer to "struct cred". | ||
28 | * @old: Pointer to "struct cred". | ||
29 | * @gfp: Memory allocation flags. | ||
30 | * | ||
31 | * Returns 0. | ||
32 | */ | ||
18 | static int tomoyo_cred_prepare(struct cred *new, const struct cred *old, | 33 | static int tomoyo_cred_prepare(struct cred *new, const struct cred *old, |
19 | gfp_t gfp) | 34 | gfp_t gfp) |
20 | { | 35 | { |
@@ -25,11 +40,22 @@ static int tomoyo_cred_prepare(struct cred *new, const struct cred *old, | |||
25 | return 0; | 40 | return 0; |
26 | } | 41 | } |
27 | 42 | ||
43 | /** | ||
44 | * tomoyo_cred_transfer - Target for security_transfer_creds(). | ||
45 | * | ||
46 | * @new: Pointer to "struct cred". | ||
47 | * @old: Pointer to "struct cred". | ||
48 | */ | ||
28 | static void tomoyo_cred_transfer(struct cred *new, const struct cred *old) | 49 | static void tomoyo_cred_transfer(struct cred *new, const struct cred *old) |
29 | { | 50 | { |
30 | tomoyo_cred_prepare(new, old, 0); | 51 | tomoyo_cred_prepare(new, old, 0); |
31 | } | 52 | } |
32 | 53 | ||
54 | /** | ||
55 | * tomoyo_cred_free - Target for security_cred_free(). | ||
56 | * | ||
57 | * @cred: Pointer to "struct cred". | ||
58 | */ | ||
33 | static void tomoyo_cred_free(struct cred *cred) | 59 | static void tomoyo_cred_free(struct cred *cred) |
34 | { | 60 | { |
35 | struct tomoyo_domain_info *domain = cred->security; | 61 | struct tomoyo_domain_info *domain = cred->security; |
@@ -37,6 +63,13 @@ static void tomoyo_cred_free(struct cred *cred) | |||
37 | atomic_dec(&domain->users); | 63 | atomic_dec(&domain->users); |
38 | } | 64 | } |
39 | 65 | ||
66 | /** | ||
67 | * tomoyo_bprm_set_creds - Target for security_bprm_set_creds(). | ||
68 | * | ||
69 | * @bprm: Pointer to "struct linux_binprm". | ||
70 | * | ||
71 | * Returns 0 on success, negative value otherwise. | ||
72 | */ | ||
40 | static int tomoyo_bprm_set_creds(struct linux_binprm *bprm) | 73 | static int tomoyo_bprm_set_creds(struct linux_binprm *bprm) |
41 | { | 74 | { |
42 | int rc; | 75 | int rc; |
@@ -75,6 +108,13 @@ static int tomoyo_bprm_set_creds(struct linux_binprm *bprm) | |||
75 | return 0; | 108 | return 0; |
76 | } | 109 | } |
77 | 110 | ||
111 | /** | ||
112 | * tomoyo_bprm_check_security - Target for security_bprm_check(). | ||
113 | * | ||
114 | * @bprm: Pointer to "struct linux_binprm". | ||
115 | * | ||
116 | * Returns 0 on success, negative value otherwise. | ||
117 | */ | ||
78 | static int tomoyo_bprm_check_security(struct linux_binprm *bprm) | 118 | static int tomoyo_bprm_check_security(struct linux_binprm *bprm) |
79 | { | 119 | { |
80 | struct tomoyo_domain_info *domain = bprm->cred->security; | 120 | struct tomoyo_domain_info *domain = bprm->cred->security; |
@@ -92,26 +132,59 @@ static int tomoyo_bprm_check_security(struct linux_binprm *bprm) | |||
92 | /* | 132 | /* |
93 | * Read permission is checked against interpreters using next domain. | 133 | * Read permission is checked against interpreters using next domain. |
94 | */ | 134 | */ |
95 | return tomoyo_check_open_permission(domain, &bprm->file->f_path, O_RDONLY); | 135 | return tomoyo_check_open_permission(domain, &bprm->file->f_path, |
136 | O_RDONLY); | ||
96 | } | 137 | } |
97 | 138 | ||
139 | /** | ||
140 | * tomoyo_inode_getattr - Target for security_inode_getattr(). | ||
141 | * | ||
142 | * @mnt: Pointer to "struct vfsmount". | ||
143 | * @dentry: Pointer to "struct dentry". | ||
144 | * | ||
145 | * Returns 0 on success, negative value otherwise. | ||
146 | */ | ||
98 | static int tomoyo_inode_getattr(struct vfsmount *mnt, struct dentry *dentry) | 147 | static int tomoyo_inode_getattr(struct vfsmount *mnt, struct dentry *dentry) |
99 | { | 148 | { |
100 | struct path path = { mnt, dentry }; | 149 | struct path path = { mnt, dentry }; |
101 | return tomoyo_path_perm(TOMOYO_TYPE_GETATTR, &path, NULL); | 150 | return tomoyo_path_perm(TOMOYO_TYPE_GETATTR, &path, NULL); |
102 | } | 151 | } |
103 | 152 | ||
153 | /** | ||
154 | * tomoyo_path_truncate - Target for security_path_truncate(). | ||
155 | * | ||
156 | * @path: Pointer to "struct path". | ||
157 | * | ||
158 | * Returns 0 on success, negative value otherwise. | ||
159 | */ | ||
104 | static int tomoyo_path_truncate(struct path *path) | 160 | static int tomoyo_path_truncate(struct path *path) |
105 | { | 161 | { |
106 | return tomoyo_path_perm(TOMOYO_TYPE_TRUNCATE, path, NULL); | 162 | return tomoyo_path_perm(TOMOYO_TYPE_TRUNCATE, path, NULL); |
107 | } | 163 | } |
108 | 164 | ||
165 | /** | ||
166 | * tomoyo_path_unlink - Target for security_path_unlink(). | ||
167 | * | ||
168 | * @parent: Pointer to "struct path". | ||
169 | * @dentry: Pointer to "struct dentry". | ||
170 | * | ||
171 | * Returns 0 on success, negative value otherwise. | ||
172 | */ | ||
109 | static int tomoyo_path_unlink(struct path *parent, struct dentry *dentry) | 173 | static int tomoyo_path_unlink(struct path *parent, struct dentry *dentry) |
110 | { | 174 | { |
111 | struct path path = { parent->mnt, dentry }; | 175 | struct path path = { parent->mnt, dentry }; |
112 | return tomoyo_path_perm(TOMOYO_TYPE_UNLINK, &path, NULL); | 176 | return tomoyo_path_perm(TOMOYO_TYPE_UNLINK, &path, NULL); |
113 | } | 177 | } |
114 | 178 | ||
179 | /** | ||
180 | * tomoyo_path_mkdir - Target for security_path_mkdir(). | ||
181 | * | ||
182 | * @parent: Pointer to "struct path". | ||
183 | * @dentry: Pointer to "struct dentry". | ||
184 | * @mode: DAC permission mode. | ||
185 | * | ||
186 | * Returns 0 on success, negative value otherwise. | ||
187 | */ | ||
115 | static int tomoyo_path_mkdir(struct path *parent, struct dentry *dentry, | 188 | static int tomoyo_path_mkdir(struct path *parent, struct dentry *dentry, |
116 | int mode) | 189 | int mode) |
117 | { | 190 | { |
@@ -120,12 +193,29 @@ static int tomoyo_path_mkdir(struct path *parent, struct dentry *dentry, | |||
120 | mode & S_IALLUGO); | 193 | mode & S_IALLUGO); |
121 | } | 194 | } |
122 | 195 | ||
196 | /** | ||
197 | * tomoyo_path_rmdir - Target for security_path_rmdir(). | ||
198 | * | ||
199 | * @parent: Pointer to "struct path". | ||
200 | * @dentry: Pointer to "struct dentry". | ||
201 | * | ||
202 | * Returns 0 on success, negative value otherwise. | ||
203 | */ | ||
123 | static int tomoyo_path_rmdir(struct path *parent, struct dentry *dentry) | 204 | static int tomoyo_path_rmdir(struct path *parent, struct dentry *dentry) |
124 | { | 205 | { |
125 | struct path path = { parent->mnt, dentry }; | 206 | struct path path = { parent->mnt, dentry }; |
126 | return tomoyo_path_perm(TOMOYO_TYPE_RMDIR, &path, NULL); | 207 | return tomoyo_path_perm(TOMOYO_TYPE_RMDIR, &path, NULL); |
127 | } | 208 | } |
128 | 209 | ||
210 | /** | ||
211 | * tomoyo_path_symlink - Target for security_path_symlink(). | ||
212 | * | ||
213 | * @parent: Pointer to "struct path". | ||
214 | * @dentry: Pointer to "struct dentry". | ||
215 | * @old_name: Symlink's content. | ||
216 | * | ||
217 | * Returns 0 on success, negative value otherwise. | ||
218 | */ | ||
129 | static int tomoyo_path_symlink(struct path *parent, struct dentry *dentry, | 219 | static int tomoyo_path_symlink(struct path *parent, struct dentry *dentry, |
130 | const char *old_name) | 220 | const char *old_name) |
131 | { | 221 | { |
@@ -133,6 +223,16 @@ static int tomoyo_path_symlink(struct path *parent, struct dentry *dentry, | |||
133 | return tomoyo_path_perm(TOMOYO_TYPE_SYMLINK, &path, old_name); | 223 | return tomoyo_path_perm(TOMOYO_TYPE_SYMLINK, &path, old_name); |
134 | } | 224 | } |
135 | 225 | ||
226 | /** | ||
227 | * tomoyo_path_mknod - Target for security_path_mknod(). | ||
228 | * | ||
229 | * @parent: Pointer to "struct path". | ||
230 | * @dentry: Pointer to "struct dentry". | ||
231 | * @mode: DAC permission mode. | ||
232 | * @dev: Device attributes. | ||
233 | * | ||
234 | * Returns 0 on success, negative value otherwise. | ||
235 | */ | ||
136 | static int tomoyo_path_mknod(struct path *parent, struct dentry *dentry, | 236 | static int tomoyo_path_mknod(struct path *parent, struct dentry *dentry, |
137 | int mode, unsigned int dev) | 237 | int mode, unsigned int dev) |
138 | { | 238 | { |
@@ -163,6 +263,15 @@ static int tomoyo_path_mknod(struct path *parent, struct dentry *dentry, | |||
163 | return tomoyo_path_number_perm(type, &path, perm); | 263 | return tomoyo_path_number_perm(type, &path, perm); |
164 | } | 264 | } |
165 | 265 | ||
266 | /** | ||
267 | * tomoyo_path_link - Target for security_path_link(). | ||
268 | * | ||
269 | * @old_dentry: Pointer to "struct dentry". | ||
270 | * @new_dir: Pointer to "struct path". | ||
271 | * @new_dentry: Pointer to "struct dentry". | ||
272 | * | ||
273 | * Returns 0 on success, negative value otherwise. | ||
274 | */ | ||
166 | static int tomoyo_path_link(struct dentry *old_dentry, struct path *new_dir, | 275 | static int tomoyo_path_link(struct dentry *old_dentry, struct path *new_dir, |
167 | struct dentry *new_dentry) | 276 | struct dentry *new_dentry) |
168 | { | 277 | { |
@@ -171,6 +280,16 @@ static int tomoyo_path_link(struct dentry *old_dentry, struct path *new_dir, | |||
171 | return tomoyo_path2_perm(TOMOYO_TYPE_LINK, &path1, &path2); | 280 | return tomoyo_path2_perm(TOMOYO_TYPE_LINK, &path1, &path2); |
172 | } | 281 | } |
173 | 282 | ||
283 | /** | ||
284 | * tomoyo_path_rename - Target for security_path_rename(). | ||
285 | * | ||
286 | * @old_parent: Pointer to "struct path". | ||
287 | * @old_dentry: Pointer to "struct dentry". | ||
288 | * @new_parent: Pointer to "struct path". | ||
289 | * @new_dentry: Pointer to "struct dentry". | ||
290 | * | ||
291 | * Returns 0 on success, negative value otherwise. | ||
292 | */ | ||
174 | static int tomoyo_path_rename(struct path *old_parent, | 293 | static int tomoyo_path_rename(struct path *old_parent, |
175 | struct dentry *old_dentry, | 294 | struct dentry *old_dentry, |
176 | struct path *new_parent, | 295 | struct path *new_parent, |
@@ -181,6 +300,15 @@ static int tomoyo_path_rename(struct path *old_parent, | |||
181 | return tomoyo_path2_perm(TOMOYO_TYPE_RENAME, &path1, &path2); | 300 | return tomoyo_path2_perm(TOMOYO_TYPE_RENAME, &path1, &path2); |
182 | } | 301 | } |
183 | 302 | ||
303 | /** | ||
304 | * tomoyo_file_fcntl - Target for security_file_fcntl(). | ||
305 | * | ||
306 | * @file: Pointer to "struct file". | ||
307 | * @cmd: Command for fcntl(). | ||
308 | * @arg: Argument for @cmd. | ||
309 | * | ||
310 | * Returns 0 on success, negative value otherwise. | ||
311 | */ | ||
184 | static int tomoyo_file_fcntl(struct file *file, unsigned int cmd, | 312 | static int tomoyo_file_fcntl(struct file *file, unsigned int cmd, |
185 | unsigned long arg) | 313 | unsigned long arg) |
186 | { | 314 | { |
@@ -190,6 +318,14 @@ static int tomoyo_file_fcntl(struct file *file, unsigned int cmd, | |||
190 | O_WRONLY | (arg & O_APPEND)); | 318 | O_WRONLY | (arg & O_APPEND)); |
191 | } | 319 | } |
192 | 320 | ||
321 | /** | ||
322 | * tomoyo_dentry_open - Target for security_dentry_open(). | ||
323 | * | ||
324 | * @f: Pointer to "struct file". | ||
325 | * @cred: Pointer to "struct cred". | ||
326 | * | ||
327 | * Returns 0 on success, negative value otherwise. | ||
328 | */ | ||
193 | static int tomoyo_dentry_open(struct file *f, const struct cred *cred) | 329 | static int tomoyo_dentry_open(struct file *f, const struct cred *cred) |
194 | { | 330 | { |
195 | int flags = f->f_flags; | 331 | int flags = f->f_flags; |
@@ -199,12 +335,30 @@ static int tomoyo_dentry_open(struct file *f, const struct cred *cred) | |||
199 | return tomoyo_check_open_permission(tomoyo_domain(), &f->f_path, flags); | 335 | return tomoyo_check_open_permission(tomoyo_domain(), &f->f_path, flags); |
200 | } | 336 | } |
201 | 337 | ||
338 | /** | ||
339 | * tomoyo_file_ioctl - Target for security_file_ioctl(). | ||
340 | * | ||
341 | * @file: Pointer to "struct file". | ||
342 | * @cmd: Command for ioctl(). | ||
343 | * @arg: Argument for @cmd. | ||
344 | * | ||
345 | * Returns 0 on success, negative value otherwise. | ||
346 | */ | ||
202 | static int tomoyo_file_ioctl(struct file *file, unsigned int cmd, | 347 | static int tomoyo_file_ioctl(struct file *file, unsigned int cmd, |
203 | unsigned long arg) | 348 | unsigned long arg) |
204 | { | 349 | { |
205 | return tomoyo_path_number_perm(TOMOYO_TYPE_IOCTL, &file->f_path, cmd); | 350 | return tomoyo_path_number_perm(TOMOYO_TYPE_IOCTL, &file->f_path, cmd); |
206 | } | 351 | } |
207 | 352 | ||
353 | /** | ||
354 | * tomoyo_path_chmod - Target for security_path_chmod(). | ||
355 | * | ||
356 | * @dentry: Pointer to "struct dentry". | ||
357 | * @mnt: Pointer to "struct vfsmount". | ||
358 | * @mode: DAC permission mode. | ||
359 | * | ||
360 | * Returns 0 on success, negative value otherwise. | ||
361 | */ | ||
208 | static int tomoyo_path_chmod(struct dentry *dentry, struct vfsmount *mnt, | 362 | static int tomoyo_path_chmod(struct dentry *dentry, struct vfsmount *mnt, |
209 | mode_t mode) | 363 | mode_t mode) |
210 | { | 364 | { |
@@ -213,6 +367,15 @@ static int tomoyo_path_chmod(struct dentry *dentry, struct vfsmount *mnt, | |||
213 | mode & S_IALLUGO); | 367 | mode & S_IALLUGO); |
214 | } | 368 | } |
215 | 369 | ||
370 | /** | ||
371 | * tomoyo_path_chown - Target for security_path_chown(). | ||
372 | * | ||
373 | * @path: Pointer to "struct path". | ||
374 | * @uid: Owner ID. | ||
375 | * @gid: Group ID. | ||
376 | * | ||
377 | * Returns 0 on success, negative value otherwise. | ||
378 | */ | ||
216 | static int tomoyo_path_chown(struct path *path, uid_t uid, gid_t gid) | 379 | static int tomoyo_path_chown(struct path *path, uid_t uid, gid_t gid) |
217 | { | 380 | { |
218 | int error = 0; | 381 | int error = 0; |
@@ -223,23 +386,57 @@ static int tomoyo_path_chown(struct path *path, uid_t uid, gid_t gid) | |||
223 | return error; | 386 | return error; |
224 | } | 387 | } |
225 | 388 | ||
389 | /** | ||
390 | * tomoyo_path_chroot - Target for security_path_chroot(). | ||
391 | * | ||
392 | * @path: Pointer to "struct path". | ||
393 | * | ||
394 | * Returns 0 on success, negative value otherwise. | ||
395 | */ | ||
226 | static int tomoyo_path_chroot(struct path *path) | 396 | static int tomoyo_path_chroot(struct path *path) |
227 | { | 397 | { |
228 | return tomoyo_path_perm(TOMOYO_TYPE_CHROOT, path, NULL); | 398 | return tomoyo_path_perm(TOMOYO_TYPE_CHROOT, path, NULL); |
229 | } | 399 | } |
230 | 400 | ||
401 | /** | ||
402 | * tomoyo_sb_mount - Target for security_sb_mount(). | ||
403 | * | ||
404 | * @dev_name: Name of device file. Maybe NULL. | ||
405 | * @path: Pointer to "struct path". | ||
406 | * @type: Name of filesystem type. Maybe NULL. | ||
407 | * @flags: Mount options. | ||
408 | * @data: Optional data. Maybe NULL. | ||
409 | * | ||
410 | * Returns 0 on success, negative value otherwise. | ||
411 | */ | ||
231 | static int tomoyo_sb_mount(char *dev_name, struct path *path, | 412 | static int tomoyo_sb_mount(char *dev_name, struct path *path, |
232 | char *type, unsigned long flags, void *data) | 413 | char *type, unsigned long flags, void *data) |
233 | { | 414 | { |
234 | return tomoyo_mount_permission(dev_name, path, type, flags, data); | 415 | return tomoyo_mount_permission(dev_name, path, type, flags, data); |
235 | } | 416 | } |
236 | 417 | ||
418 | /** | ||
419 | * tomoyo_sb_umount - Target for security_sb_umount(). | ||
420 | * | ||
421 | * @mnt: Pointer to "struct vfsmount". | ||
422 | * @flags: Unmount options. | ||
423 | * | ||
424 | * Returns 0 on success, negative value otherwise. | ||
425 | */ | ||
237 | static int tomoyo_sb_umount(struct vfsmount *mnt, int flags) | 426 | static int tomoyo_sb_umount(struct vfsmount *mnt, int flags) |
238 | { | 427 | { |
239 | struct path path = { mnt, mnt->mnt_root }; | 428 | struct path path = { mnt, mnt->mnt_root }; |
240 | return tomoyo_path_perm(TOMOYO_TYPE_UMOUNT, &path, NULL); | 429 | return tomoyo_path_perm(TOMOYO_TYPE_UMOUNT, &path, NULL); |
241 | } | 430 | } |
242 | 431 | ||
432 | /** | ||
433 | * tomoyo_sb_pivotroot - Target for security_sb_pivotroot(). | ||
434 | * | ||
435 | * @old_path: Pointer to "struct path". | ||
436 | * @new_path: Pointer to "struct path". | ||
437 | * | ||
438 | * Returns 0 on success, negative value otherwise. | ||
439 | */ | ||
243 | static int tomoyo_sb_pivotroot(struct path *old_path, struct path *new_path) | 440 | static int tomoyo_sb_pivotroot(struct path *old_path, struct path *new_path) |
244 | { | 441 | { |
245 | return tomoyo_path2_perm(TOMOYO_TYPE_PIVOT_ROOT, new_path, old_path); | 442 | return tomoyo_path2_perm(TOMOYO_TYPE_PIVOT_ROOT, new_path, old_path); |
@@ -280,6 +477,11 @@ static struct security_operations tomoyo_security_ops = { | |||
280 | /* Lock for GC. */ | 477 | /* Lock for GC. */ |
281 | struct srcu_struct tomoyo_ss; | 478 | struct srcu_struct tomoyo_ss; |
282 | 479 | ||
480 | /** | ||
481 | * tomoyo_init - Register TOMOYO Linux as a LSM module. | ||
482 | * | ||
483 | * Returns 0. | ||
484 | */ | ||
283 | static int __init tomoyo_init(void) | 485 | static int __init tomoyo_init(void) |
284 | { | 486 | { |
285 | struct cred *cred = (struct cred *) current_cred(); | 487 | struct cred *cred = (struct cred *) current_cred(); |
diff --git a/security/tomoyo/util.c b/security/tomoyo/util.c index e25f7ffd5ba7..c36bd1107fc8 100644 --- a/security/tomoyo/util.c +++ b/security/tomoyo/util.c | |||
@@ -1,9 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * security/tomoyo/util.c | 2 | * security/tomoyo/util.c |
3 | * | 3 | * |
4 | * Utility functions for TOMOYO. | 4 | * Copyright (C) 2005-2011 NTT DATA CORPORATION |
5 | * | ||
6 | * Copyright (C) 2005-2010 NTT DATA CORPORATION | ||
7 | */ | 5 | */ |
8 | 6 | ||
9 | #include <linux/slab.h> | 7 | #include <linux/slab.h> |
@@ -378,7 +376,7 @@ void tomoyo_normalize_line(unsigned char *buffer) | |||
378 | /** | 376 | /** |
379 | * tomoyo_correct_word2 - Validate a string. | 377 | * tomoyo_correct_word2 - Validate a string. |
380 | * | 378 | * |
381 | * @string: The string to check. May be non-'\0'-terminated. | 379 | * @string: The string to check. Maybe non-'\0'-terminated. |
382 | * @len: Length of @string. | 380 | * @len: Length of @string. |
383 | * | 381 | * |
384 | * Check whether the given string follows the naming rules. | 382 | * Check whether the given string follows the naming rules. |