]> git.baikalelectronics.ru Git - kernel.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)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 1 Aug 2019 20:10:45 +0000 (13:10 -0700)
commit8b50b52522acfcf967865b83196159a685b6d920
tree61ba0d59447f209b532a7a5481c202209d75d278
parent6988fd32241722174fedf17459e3f7e7485f23d8
libbpf: set BTF FD for prog only when there is supported .BTF.ext data

9c380a89d0df ("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: 9c380a89d0df ("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>
tools/lib/bpf/libbpf.c