aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf
diff options
context:
space:
mode:
authorMauricio Vasquez B <mauricio.vasquez@polito.it>2018-10-18 09:16:20 -0400
committerAlexei Starovoitov <ast@kernel.org>2018-10-19 16:24:31 -0400
commit2ea864c58f19bf70a0e2415f9f1c53814e07f1b4 (patch)
treed0de5b3fcc6a4b37ebeb4fc56b0196895cdbc023 /kernel/bpf
parentc9d29f4658a5a6d2c2ba2afeb20ff763fc6286f9 (diff)
bpf/verifier: add ARG_PTR_TO_UNINIT_MAP_VALUE
ARG_PTR_TO_UNINIT_MAP_VALUE argument is a pointer to a memory zone used to save the value of a map. Basically the same as ARG_PTR_TO_UNINIT_MEM, but the size has not be passed as an extra argument. This will be used in the following patch that implements some new helpers that receive a pointer to be filled with a map value. Signed-off-by: Mauricio Vasquez B <mauricio.vasquez@polito.it> Acked-by: Song Liu <songliubraving@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/bpf')
-rw-r--r--kernel/bpf/verifier.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 3f93a548a642..d84c91ac3b70 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2117,7 +2117,8 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 regno,
2117 } 2117 }
2118 2118
2119 if (arg_type == ARG_PTR_TO_MAP_KEY || 2119 if (arg_type == ARG_PTR_TO_MAP_KEY ||
2120 arg_type == ARG_PTR_TO_MAP_VALUE) { 2120 arg_type == ARG_PTR_TO_MAP_VALUE ||
2121 arg_type == ARG_PTR_TO_UNINIT_MAP_VALUE) {
2121 expected_type = PTR_TO_STACK; 2122 expected_type = PTR_TO_STACK;
2122 if (!type_is_pkt_pointer(type) && type != PTR_TO_MAP_VALUE && 2123 if (!type_is_pkt_pointer(type) && type != PTR_TO_MAP_VALUE &&
2123 type != expected_type) 2124 type != expected_type)
@@ -2187,7 +2188,8 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 regno,
2187 err = check_helper_mem_access(env, regno, 2188 err = check_helper_mem_access(env, regno,
2188 meta->map_ptr->key_size, false, 2189 meta->map_ptr->key_size, false,
2189 NULL); 2190 NULL);
2190 } else if (arg_type == ARG_PTR_TO_MAP_VALUE) { 2191 } else if (arg_type == ARG_PTR_TO_MAP_VALUE ||
2192 arg_type == ARG_PTR_TO_UNINIT_MAP_VALUE) {
2191 /* bpf_map_xxx(..., map_ptr, ..., value) call: 2193 /* bpf_map_xxx(..., map_ptr, ..., value) call:
2192 * check [value, value + map->value_size) validity 2194 * check [value, value + map->value_size) validity
2193 */ 2195 */
@@ -2196,9 +2198,10 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 regno,
2196 verbose(env, "invalid map_ptr to access map->value\n"); 2198 verbose(env, "invalid map_ptr to access map->value\n");
2197 return -EACCES; 2199 return -EACCES;
2198 } 2200 }
2201 meta->raw_mode = (arg_type == ARG_PTR_TO_UNINIT_MAP_VALUE);
2199 err = check_helper_mem_access(env, regno, 2202 err = check_helper_mem_access(env, regno,
2200 meta->map_ptr->value_size, false, 2203 meta->map_ptr->value_size, false,
2201 NULL); 2204 meta);
2202 } else if (arg_type_is_mem_size(arg_type)) { 2205 } else if (arg_type_is_mem_size(arg_type)) {
2203 bool zero_size_allowed = (arg_type == ARG_CONST_SIZE_OR_ZERO); 2206 bool zero_size_allowed = (arg_type == ARG_CONST_SIZE_OR_ZERO);
2204 2207