bpf: btf: Check array t->size
This patch ensures array's t->size is 0. The array size is decided by its individual elem's size and the number of elements. Hence, t->size is not used and it must be 0. A test case is added to test_btf.c Signed-off-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:

committed by
Alexei Starovoitov

parent
b4b21a05b8
commit
b9308ae696
@@ -1342,6 +1342,11 @@ static s32 btf_array_check_meta(struct btf_verifier_env *env,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (t->size) {
|
||||
btf_verifier_log_type(env, t, "size != 0");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Array elem type and index type cannot be in type void,
|
||||
* so !array->type and !array->index_type are not allowed.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user