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 bpftool: Fix typo in MAX_NUM_METRICS macro name 2024-06-03 16:58:27 +02:00
.gitignore bpftool: Fix SPDX tag for Makefiles and .gitignore 2021-11-10 09:00:52 -08:00
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 bpftool: Fix control flow graph segfault during edge creation 2025-01-10 14:16:13 -08:00
cfg.h bpftool: Support printing opcodes and source file references in CFG 2023-04-05 21:27:27 -07:00
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 bpftool: Refactor kernel config reading into common helper 2025-09-02 17:20:54 +02:00
gen.c bpftool: Fix typo in struct_ops map FD generation for light skeleton 2026-05-28 14:19:15 -07:00
iter.c bpftool: Use appropriate permissions for map access 2025-06-20 11:13:03 -07:00
jit_disasm.c bpftool: Enable aarch64 ISA extensions for JIT disassembly 2026-03-24 08:44:29 -07:00
json_writer.c tools: bpftool: json: Fix backslash escape typo in jsonw_puts 2023-03-29 09:48:45 -07:00
json_writer.h tools: bpftool: json: Fix backslash escape typo in jsonw_puts 2023-03-29 09:48:45 -07:00
link.c bpftool: Add CET-aware symbol matching for x86_64 architectures 2025-09-02 17:20:54 +02:00
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 bpftool: Use appropriate permissions for map access 2025-06-20 11:13:03 -07:00
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 bpftool: Using the right format specifiers 2025-03-17 13:50:56 -07:00
netlink_dumper.h bpftool: Extend net dump with tcx progs 2023-07-19 10:07:28 -07:00
perf.c bpftool: fix perf help message 2023-08-11 20:54:29 -07:00
pids.c bpftool: ensure task comm is always NUL-terminated 2024-11-05 17:12:29 -08:00
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 bpftool: Mount bpffs on provided dir instead of parent dir 2024-04-04 15:37:12 -07:00
token.c bpftool: Fix UAF in get_delegate_value 2025-09-19 15:37:30 -07:00
tracelog.c bpftool: Search for tracefs at /sys/kernel/tracing first 2025-09-15 10:10:28 -07:00
xlated_dumper.c bpftool: Using the right format specifiers 2025-03-17 13:50:56 -07:00
xlated_dumper.h bpftool: Dump the kernel symbol's module name 2023-07-11 20:07:50 -07:00