diff options
Diffstat (limited to 'security/tomoyo/path_group.c')
-rw-r--r-- | security/tomoyo/path_group.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/security/tomoyo/path_group.c b/security/tomoyo/path_group.c index 7838f7681297..5b71d8868453 100644 --- a/security/tomoyo/path_group.c +++ b/security/tomoyo/path_group.c | |||
@@ -54,6 +54,15 @@ struct tomoyo_path_group *tomoyo_get_path_group(const char *group_name) | |||
54 | return !error ? group : NULL; | 54 | return !error ? group : NULL; |
55 | } | 55 | } |
56 | 56 | ||
57 | static bool tomoyo_same_path_group(const struct tomoyo_acl_head *a, | ||
58 | const struct tomoyo_acl_head *b) | ||
59 | { | ||
60 | return container_of(a, struct tomoyo_path_group_member, head) | ||
61 | ->member_name == | ||
62 | container_of(b, struct tomoyo_path_group_member, head) | ||
63 | ->member_name; | ||
64 | } | ||
65 | |||
57 | /** | 66 | /** |
58 | * tomoyo_write_path_group_policy - Write "struct tomoyo_path_group" list. | 67 | * tomoyo_write_path_group_policy - Write "struct tomoyo_path_group" list. |
59 | * | 68 | * |
@@ -65,7 +74,6 @@ struct tomoyo_path_group *tomoyo_get_path_group(const char *group_name) | |||
65 | int tomoyo_write_path_group_policy(char *data, const bool is_delete) | 74 | int tomoyo_write_path_group_policy(char *data, const bool is_delete) |
66 | { | 75 | { |
67 | struct tomoyo_path_group *group; | 76 | struct tomoyo_path_group *group; |
68 | struct tomoyo_path_group_member *member; | ||
69 | struct tomoyo_path_group_member e = { }; | 77 | struct tomoyo_path_group_member e = { }; |
70 | int error = is_delete ? -ENOENT : -ENOMEM; | 78 | int error = is_delete ? -ENOENT : -ENOMEM; |
71 | char *w[2]; | 79 | char *w[2]; |
@@ -77,25 +85,9 @@ int tomoyo_write_path_group_policy(char *data, const bool is_delete) | |||
77 | e.member_name = tomoyo_get_name(w[1]); | 85 | e.member_name = tomoyo_get_name(w[1]); |
78 | if (!e.member_name) | 86 | if (!e.member_name) |
79 | goto out; | 87 | goto out; |
80 | if (mutex_lock_interruptible(&tomoyo_policy_lock)) | 88 | error = tomoyo_update_policy(&e.head, sizeof(e), is_delete, |
81 | goto out; | 89 | &group->member_list, |
82 | list_for_each_entry_rcu(member, &group->member_list, head.list) { | 90 | tomoyo_same_path_group); |
83 | if (member->member_name != e.member_name) | ||
84 | continue; | ||
85 | member->head.is_deleted = is_delete; | ||
86 | error = 0; | ||
87 | break; | ||
88 | } | ||
89 | if (!is_delete && error) { | ||
90 | struct tomoyo_path_group_member *entry = | ||
91 | tomoyo_commit_ok(&e, sizeof(e)); | ||
92 | if (entry) { | ||
93 | list_add_tail_rcu(&entry->head.list, | ||
94 | &group->member_list); | ||
95 | error = 0; | ||
96 | } | ||
97 | } | ||
98 | mutex_unlock(&tomoyo_policy_lock); | ||
99 | out: | 91 | out: |
100 | tomoyo_put_name(e.member_name); | 92 | tomoyo_put_name(e.member_name); |
101 | tomoyo_put_path_group(group); | 93 | tomoyo_put_path_group(group); |