summaryrefslogtreecommitdiffstats
path: root/tools/memory-model
diff options
context:
space:
mode:
authorKumar Kartikeya Dwivedi <memxor@gmail.com>2021-09-24 04:37:25 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2021-09-28 09:29:03 +0200
commitbcfd367c2839f2126c048fe59700ec1b538e2b06 (patch)
tree397eeacdd5ef79e20ea7eecec3ebc85d0100f359 /tools/memory-model
parentMAINTAINERS: Add btf headers to BPF (diff)
downloadlinux-bcfd367c2839f2126c048fe59700ec1b538e2b06.tar.xz
linux-bcfd367c2839f2126c048fe59700ec1b538e2b06.zip
libbpf: Fix segfault in static linker for objects without BTF
When a BPF object is compiled without BTF info (without -g), trying to link such objects using bpftool causes a SIGSEGV due to btf__get_nr_types accessing obj->btf which is NULL. Fix this by checking for the NULL pointer, and return error. Reproducer: $ cat a.bpf.c extern int foo(void); int bar(void) { return foo(); } $ cat b.bpf.c int foo(void) { return 0; } $ clang -O2 -target bpf -c a.bpf.c $ clang -O2 -target bpf -c b.bpf.c $ bpftool gen obj out a.bpf.o b.bpf.o Segmentation fault (core dumped) After fix: $ bpftool gen obj out a.bpf.o b.bpf.o libbpf: failed to find BTF info for object 'a.bpf.o' Error: failed to link 'a.bpf.o': Unknown error -22 (-22) Fixes: a46349227cd8 (libbpf: Add linker extern resolution support for functions and global variables) Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20210924023725.70228-1-memxor@gmail.com
Diffstat (limited to 'tools/memory-model')
0 files changed, 0 insertions, 0 deletions