diff options
Diffstat (limited to 'security/tomoyo/common.c')
-rw-r--r-- | security/tomoyo/common.c | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c index 642e0e565dfc..e331e699cf54 100644 --- a/security/tomoyo/common.c +++ b/security/tomoyo/common.c | |||
@@ -900,9 +900,11 @@ static struct tomoyo_profile *tomoyo_find_or_assign_new_profile(const unsigned | |||
900 | ptr = tomoyo_profile_ptr[profile]; | 900 | ptr = tomoyo_profile_ptr[profile]; |
901 | if (ptr) | 901 | if (ptr) |
902 | goto ok; | 902 | goto ok; |
903 | ptr = tomoyo_alloc_element(sizeof(*ptr)); | 903 | ptr = kmalloc(sizeof(*ptr), GFP_KERNEL); |
904 | if (!ptr) | 904 | if (!tomoyo_memory_ok(ptr)) { |
905 | kfree(ptr); | ||
905 | goto ok; | 906 | goto ok; |
907 | } | ||
906 | for (i = 0; i < TOMOYO_MAX_CONTROL_INDEX; i++) | 908 | for (i = 0; i < TOMOYO_MAX_CONTROL_INDEX; i++) |
907 | ptr->value[i] = tomoyo_control_array[i].current_value; | 909 | ptr->value[i] = tomoyo_control_array[i].current_value; |
908 | mb(); /* Avoid out-of-order execution. */ | 910 | mb(); /* Avoid out-of-order execution. */ |
@@ -1120,6 +1122,7 @@ static int tomoyo_update_manager_entry(const char *manager, | |||
1120 | saved_manager = tomoyo_save_name(manager); | 1122 | saved_manager = tomoyo_save_name(manager); |
1121 | if (!saved_manager) | 1123 | if (!saved_manager) |
1122 | return -ENOMEM; | 1124 | return -ENOMEM; |
1125 | new_entry = kmalloc(sizeof(*new_entry), GFP_KERNEL); | ||
1123 | mutex_lock(&tomoyo_policy_lock); | 1126 | mutex_lock(&tomoyo_policy_lock); |
1124 | list_for_each_entry_rcu(ptr, &tomoyo_policy_manager_list, list) { | 1127 | list_for_each_entry_rcu(ptr, &tomoyo_policy_manager_list, list) { |
1125 | if (ptr->manager != saved_manager) | 1128 | if (ptr->manager != saved_manager) |
@@ -1132,15 +1135,16 @@ static int tomoyo_update_manager_entry(const char *manager, | |||
1132 | error = -ENOENT; | 1135 | error = -ENOENT; |
1133 | goto out; | 1136 | goto out; |
1134 | } | 1137 | } |
1135 | new_entry = tomoyo_alloc_element(sizeof(*new_entry)); | 1138 | if (!tomoyo_memory_ok(new_entry)) |
1136 | if (!new_entry) | ||
1137 | goto out; | 1139 | goto out; |
1138 | new_entry->manager = saved_manager; | 1140 | new_entry->manager = saved_manager; |
1139 | new_entry->is_domain = is_domain; | 1141 | new_entry->is_domain = is_domain; |
1140 | list_add_tail_rcu(&new_entry->list, &tomoyo_policy_manager_list); | 1142 | list_add_tail_rcu(&new_entry->list, &tomoyo_policy_manager_list); |
1143 | new_entry = NULL; | ||
1141 | error = 0; | 1144 | error = 0; |
1142 | out: | 1145 | out: |
1143 | mutex_unlock(&tomoyo_policy_lock); | 1146 | mutex_unlock(&tomoyo_policy_lock); |
1147 | kfree(new_entry); | ||
1144 | return error; | 1148 | return error; |
1145 | } | 1149 | } |
1146 | 1150 | ||
@@ -2148,35 +2152,6 @@ static int tomoyo_close_control(struct file *file) | |||
2148 | } | 2152 | } |
2149 | 2153 | ||
2150 | /** | 2154 | /** |
2151 | * tomoyo_alloc_acl_element - Allocate permanent memory for ACL entry. | ||
2152 | * | ||
2153 | * @acl_type: Type of ACL entry. | ||
2154 | * | ||
2155 | * Returns pointer to the ACL entry on success, NULL otherwise. | ||
2156 | */ | ||
2157 | void *tomoyo_alloc_acl_element(const u8 acl_type) | ||
2158 | { | ||
2159 | int len; | ||
2160 | struct tomoyo_acl_info *ptr; | ||
2161 | |||
2162 | switch (acl_type) { | ||
2163 | case TOMOYO_TYPE_SINGLE_PATH_ACL: | ||
2164 | len = sizeof(struct tomoyo_single_path_acl_record); | ||
2165 | break; | ||
2166 | case TOMOYO_TYPE_DOUBLE_PATH_ACL: | ||
2167 | len = sizeof(struct tomoyo_double_path_acl_record); | ||
2168 | break; | ||
2169 | default: | ||
2170 | return NULL; | ||
2171 | } | ||
2172 | ptr = tomoyo_alloc_element(len); | ||
2173 | if (!ptr) | ||
2174 | return NULL; | ||
2175 | ptr->type = acl_type; | ||
2176 | return ptr; | ||
2177 | } | ||
2178 | |||
2179 | /** | ||
2180 | * tomoyo_open - open() for /sys/kernel/security/tomoyo/ interface. | 2155 | * tomoyo_open - open() for /sys/kernel/security/tomoyo/ interface. |
2181 | * | 2156 | * |
2182 | * @inode: Pointer to "struct inode". | 2157 | * @inode: Pointer to "struct inode". |