From: Martin KaFai Lau Date: Wed, 12 Sep 2018 17:29:11 +0000 (-0700) Subject: bpf: btf: Fix end boundary calculation for type section X-Git-Tag: v4.19~169^2~19^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4b1c5d917d34f705096bb7dd8a2bd19b0881970e;p=platform%2Fkernel%2Flinux-rpi3.git bpf: btf: Fix end boundary calculation for type section The end boundary math for type section is incorrect in btf_check_all_metas(). It just happens that hdr->type_off is always 0 for now because there are only two sections (type and string) and string section must be at the end (ensured in btf_parse_str_sec). However, type_off may not be 0 if a new section would be added later. This patch fixes it. Fixes: f80442a4cd18 ("bpf: btf: Change how section is supported in btf_header") Reported-by: Dmitry Vyukov Signed-off-by: Martin KaFai Lau Acked-by: Yonghong Song Signed-off-by: Daniel Borkmann --- diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 2590700..138f030 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -1844,7 +1844,7 @@ static int btf_check_all_metas(struct btf_verifier_env *env) hdr = &btf->hdr; cur = btf->nohdr_data + hdr->type_off; - end = btf->nohdr_data + hdr->type_len; + end = cur + hdr->type_len; env->log_type_id = 1; while (cur < end) {