]> git.hungrycats.org Git - linux/commit
bpf: btf: Fix end boundary calculation for type section
authorMartin KaFai Lau <kafai@fb.com>
Wed, 12 Sep 2018 17:29:11 +0000 (10:29 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Oct 2018 07:18:15 +0000 (09:18 +0200)
commitd2440a0b06727aa19b2d9d937ff4754ec2f469be
tree681576ae80e0e66f3682f232d0812050d4b8b0ec
parentaeaca3563bea4d36b373949097e091f76505204f
bpf: btf: Fix end boundary calculation for type section

[ Upstream commit 4b1c5d917d34f705096bb7dd8a2bd19b0881970e ]

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 <dvyukov@google.com>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/bpf/btf.c