summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorMartin KaFai Lau2018-06-02 18:06:50 +0200
committerAlexei Starovoitov2018-06-02 20:22:36 +0200
commitb9308ae696b2c35e862636eec631d95ff958c33d (patch)
treee6ec045510d123dbb9f6e1502e4c5aa809e88f6e /kernel
parentMerge branch 'bpf-sockmap-test-fixes' (diff)
downloadkernel-qcow2-linux-b9308ae696b2c35e862636eec631d95ff958c33d.tar.gz
kernel-qcow2-linux-b9308ae696b2c35e862636eec631d95ff958c33d.tar.xz
kernel-qcow2-linux-b9308ae696b2c35e862636eec631d95ff958c33d.zip
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.c5
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.
*/