diff options
author | Martin KaFai Lau <kafai@fb.com> | 2018-06-02 09:06:50 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2018-06-02 11:22:36 -0700 |
commit | b9308ae696b2c35e862636eec631d95ff958c33d (patch) | |
tree | e6ec045510d123dbb9f6e1502e4c5aa809e88f6e /kernel | |
parent | b4b21a05b8fe7288087691e993c913a41fd6eb4b (diff) | |
download | linux-b9308ae696b2c35e862636eec631d95ff958c33d.tar.bz2 |
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>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/bpf/btf.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 3d20aa1f4b54..84ad532f2854 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -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. */ |