linux/tools/bpf/bpftool
Yichong Chen bda6a7308e bpftool: Fix vmlinux BTF leak in cgroup commands
bpftool cgroup show and tree call libbpf_find_kernel_btf() to
resolve attach_btf names, but never release the returned BTF object.

For cgroup tree, do_show_tree_fn() is called once for each cgroup
visited by nftw(). When more than one cgroup has attached programs,
each callback overwrites btf_vmlinux with a new object and loses the
previous allocation.

Load vmlinux BTF only once during a tree walk and release it when
cgroup show or tree completes. Reset btf_vmlinux_id at the same time
so batch mode starts with clean state.

Fixes: 596f5fb2ea ("bpftool: implement cgroup tree for BPF_LSM_CGROUP")
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/r/24357C69B4405079+20260617090117.280222-1-chenyichong@uniontech.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2026-06-21 18:02:10 -07:00
..
bash-completion bpftool: add missing fsession to the usage and docs of bpftool 2026-04-12 12:42:38 -07:00
Documentation bpftool: Add rhash map documentation 2026-06-05 08:00:08 -07:00
skeleton
.gitignore
btf_dumper.c bpftool: Support 24-bit vlen 2026-04-20 17:52:48 -07:00
btf.c bpftool: Support 24-bit vlen 2026-04-20 17:52:48 -07:00
cfg.c
cfg.h
cgroup.c bpftool: Fix vmlinux BTF leak in cgroup commands 2026-06-21 18:02:10 -07:00
common.c bpftool: add fsession support 2026-01-24 18:49:36 -08:00
feature.c
gen.c bpftool: Fix typo in struct_ops map FD generation for light skeleton 2026-05-28 14:19:15 -07:00
iter.c
jit_disasm.c bpftool: Enable aarch64 ISA extensions for JIT disassembly 2026-03-24 08:44:29 -07:00
json_writer.c
json_writer.h
link.c
main.c bpftool: Allow explicitly skip llvm, libbfd and libcrypto dependencies 2026-03-16 14:14:14 -07:00
main.h bpftool: Allow explicitly skip llvm, libbfd and libcrypto dependencies 2026-03-16 14:14:14 -07:00
Makefile bpftool: Append extra host flags 2026-06-14 17:32:53 -07:00
map_perf_ring.c
map.c bpftool: Add rhash map documentation 2026-06-05 08:00:08 -07:00
net.c bpftool: Use libbpf error code for flow dissector query 2026-06-03 15:30:23 -07:00
netlink_dumper.c
netlink_dumper.h
perf.c
pids.c
prog.c bpftool: add missing fsession to the usage and docs of bpftool 2026-04-12 12:42:38 -07:00
sign.c bpftool: Allow bpftool to build with openssl < 3 2025-11-24 10:00:16 -08:00
struct_ops.c
token.c bpftool: Fix UAF in get_delegate_value 2025-09-19 15:37:30 -07:00
tracelog.c
xlated_dumper.c
xlated_dumper.h