]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
libbpf: set BTF FD for prog only when there is supported .BTF.ext data
authorAndrii Nakryiko <andriin@fb.com>
Thu, 1 Aug 2019 07:24:05 +0000 (00:24 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Sep 2019 09:35:10 +0000 (10:35 +0100)
commitb8a132a4c4b6e97c8f157623167c8d5a5b75c1ab
tree6d0bda5719d2fa2dde87a0c6687ad0eccd93899b
parenta65fb2895af4a11b2ca0457926ae24c5feeaab6b
libbpf: set BTF FD for prog only when there is supported .BTF.ext data

[ Upstream commit 3415ec643e7bd644b03026efbe2f2b36cbe9b34b ]

5d01ab7bac46 ("libbpf: fix erroneous multi-closing of BTF FD")
introduced backwards-compatibility issue, manifesting itself as -E2BIG
error returned on program load due to unknown non-zero btf_fd attribute
value for BPF_PROG_LOAD sys_bpf() sub-command.

This patch fixes bug by ensuring that we only ever associate BTF FD with
program if there is a BTF.ext data that was successfully loaded into
kernel, which automatically means kernel supports func_info/line_info
and associated BTF FD for progs (checked and ensured also by BTF
sanitization code).

Fixes: 5d01ab7bac46 ("libbpf: fix erroneous multi-closing of BTF FD")
Reported-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/lib/bpf/libbpf.c