]> git.ipfire.org Git - thirdparty/linux.git/commit
Merge branch 'libbpf-bpftool-support-merging-split-btfs'
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 5 Mar 2026 22:53:37 +0000 (14:53 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 5 Mar 2026 23:03:05 +0000 (15:03 -0800)
commit8a2a3aaf90cf671caaca88fe57362c8b169ef392
tree34c6353b8d98ea735f4bd2158c8a9ad335d3ef2d
parent4faa1893807cfc9363b19624f8666e07e7e42f59
parentfefeeec6123587c6b08884865042988d40405bd2
Merge branch 'libbpf-bpftool-support-merging-split-btfs'

Josef Bacik says:

====================
libbpf/bpftool: support merging split BTFs

v1: https://lore.kernel.org/bpf/cover.1771605821.git.josef@toxicpanda.com/
v2: https://lore.kernel.org/bpf/cover.1771616227.git.josef@toxicpanda.com/
v3: https://lore.kernel.org/bpf/cover.1771622266.git.josef@toxicpanda.com/
v4: https://lore.kernel.org/bpf/cover.1771625484.git.josef@toxicpanda.com/
v5: https://lore.kernel.org/bpf/cover.1771950922.git.josef@toxicpanda.com/

v1->v2:
- Added a btf__dedup() call to btf__add_btf() to ensure that we don't have
  duplicate types in the merged BTF.
v2->v3:
- AI review got confused about the UAF comment, so the comment was expanded to
  clarify the UAF potential.
- Fixed potential clobbering of errno in the error path.
v3->v4:
- Fixed a potential silent corruption pointed out by the AI review bot.
v4->v5:
- Addressed Andrii's comments for 1/3.
- Addressed Alan and Quentin's comments for 2/3.
- Addressed Alan's comments for 3/3.
- Added my Signed-off-by for the third patch.
- Made sure to validate everything still worked.
v5->v6:
- Fixed the missed is_prefix comment.
- Fixed the removed warning about skipping vmlinux.

--- Original email ---

Hello,

I'm extending systing to do introspection on vfio devices, which requires having
the structs I need from the kernel available in userspace. Normally these are
loadable modules, but in the case of vfio there's multiple structs across
multiple modules. Normally you'd do the following to generate your vmlinux.h
with a module

bpftool btf dump file /sys/kernel/btf/<module> format c \
--base /sys/kernel/btf/vmlinux > vmlinux.h

but if you need multiple modules you have to hack together multiple dumps and
merge them together. This patch series adds support for merging multiple BTF
sources together, so you can do

bpftool btf dump file /sys/kernel/btf/<module1> \
file /sys/kernel/btf/<module2> format c \
--base /sys/kernel/btf/vmlinux > vmlinux.h

I tested this with my usecase and it works. Thanks,

Josef
====================

Link: https://patch.msgid.link/cover.1772657690.git.josef@toxicpanda.com
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>