diff mbox series

[bpf-next,v2] bpf: fix bpftool without skeleton code enabled

Message ID 159375071997.14984.17404504293832961401.stgit@john-XPS-13-9370
State Accepted
Delegated to: BPF Maintainers
Headers show
Series [bpf-next,v2] bpf: fix bpftool without skeleton code enabled | expand

Commit Message

John Fastabend July 3, 2020, 4:31 a.m. UTC
Fix segfault from bpftool by adding emit_obj_refs_plain when skeleton
code is disabled.

Tested by deleting BUILD_BPF_SKELS in Makefile. We found this doing
backports for Cilium when a testing image pulled in latest bpf-next
bpftool, but kept using an older clang-7.

# ./bpftool prog show
Error: bpftool built without PID iterator support
3: cgroup_skb  tag 7be49e3934a125ba  gpl
        loaded_at 2020-07-01T08:01:29-0700  uid 0
Segmentation fault

Reported-by: Joe Stringer <joe@wand.net.nz>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Yonghong Song <yhs@fb.com>
---
 tools/bpf/bpftool/pids.c |    1 +
 1 file changed, 1 insertion(+)

Comments

Daniel Borkmann July 3, 2020, 9:22 p.m. UTC | #1
On 7/3/20 6:31 AM, John Fastabend wrote:
> Fix segfault from bpftool by adding emit_obj_refs_plain when skeleton
> code is disabled.
> 
> Tested by deleting BUILD_BPF_SKELS in Makefile. We found this doing
> backports for Cilium when a testing image pulled in latest bpf-next
> bpftool, but kept using an older clang-7.
> 
> # ./bpftool prog show
> Error: bpftool built without PID iterator support
> 3: cgroup_skb  tag 7be49e3934a125ba  gpl
>          loaded_at 2020-07-01T08:01:29-0700  uid 0
> Segmentation fault
> 
> Reported-by: Joe Stringer <joe@wand.net.nz>
> Signed-off-by: John Fastabend <john.fastabend@gmail.com>
> Acked-by: Yonghong Song <yhs@fb.com>

Applied, thanks!
diff mbox series

Patch

diff --git a/tools/bpf/bpftool/pids.c b/tools/bpf/bpftool/pids.c
index 2709be4de2b1..7d5416667c85 100644
--- a/tools/bpf/bpftool/pids.c
+++ b/tools/bpf/bpftool/pids.c
@@ -19,6 +19,7 @@  int build_obj_refs_table(struct obj_refs_table *table, enum bpf_obj_type type)
 	return -ENOTSUP;
 }
 void delete_obj_refs_table(struct obj_refs_table *table) {}
+void emit_obj_refs_plain(struct obj_refs_table *table, __u32 id, const char *prefix) {}
 
 #else /* BPFTOOL_WITHOUT_SKELETONS */