]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Fix crash if SEC("freplace") programs don't have attach_prog_fd set
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 9 Sep 2022 19:30:52 +0000 (12:30 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 16 Sep 2022 20:39:37 +0000 (22:39 +0200)
commita7d986f5542bcbeaf8a56636b9a7587822fd20ac
tree7b6539a5913cb136e857889f7ddd07b1f719affa
parent14e59549692046ddffada4a82e807a3e6db998a4
libbpf: Fix crash if SEC("freplace") programs don't have attach_prog_fd set

Fix SIGSEGV caused by libbpf trying to find attach type in vmlinux BTF
for freplace programs. It's wrong to search in vmlinux BTF and libbpf
doesn't even mark vmlinux BTF as required for freplace programs. So
trying to search anything in obj->vmlinux_btf might cause NULL
dereference if nothing else in BPF object requires vmlinux BTF.

Instead, error out if freplace (EXT) program doesn't specify
attach_prog_fd during at the load time.

Fixes: 2c0c27c59f8f ("libbpf: Support attachment of BPF tracing programs to kernel modules")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220909193053.577111-3-andrii@kernel.org
tools/lib/bpf/libbpf.c