summaryrefslogtreecommitdiff
path: root/tools/bpf
AgeCommit message (Collapse)Author
13 daystools/bpf: Remove legacy BPF toolsXia Yan
Remove bpf_asm, bpf_dbg and bpf_jit_disasm, along with the assembler's lexer and parser, as suggested by Daniel. These tools are old classic BPF and these days there is no need to keep them in kernel anymore. Drop their build and install rules, feature checks and ignore entries. Remove the tool-specific documentation and update the PTP classifier and packet socket test comments. Keep the classic BPF instruction descriptions and assembly examples. Keep the bpftool and resolve_btfids build and clean targets, and the bpftool install target. Suggested-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Xia Yan <yanxia@cmss.chinamobile.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/61f7315e-c835-425e-a99b-d2470ba9a875@iogearbox.net Link: https://lore.kernel.org/bpf/20261020095124.928021-1-yanxia@cmss.chinamobile.com
2026-10-17bpftool: Fail map dump for maps that can't be iteratedMaxim Skokov
"bpftool map dump" walks the map with bpf_map_get_next_key() and treats ENOENT as the end of the map. Map types that can't be iterated fail that call on the very first key: local storage and ringbuf with ENOTSUPP, bloom filter and arena with EOPNOTSUPP, queue and stack with EINVAL. bpftool then ends the walk without a word and prints what it prints for an empty map, "[]" with BTF or "Found 0 elements" without, and only the exit status tells that the map was not read. On a socket storage map that holds storage for a socket: # bpftool map dump pinned /sys/fs/bpf/sk_storage [] Ask for the first key before printing anything, and when that fails with anything but ENOENT, fail with the map type and the error instead of a dump: # bpftool map dump pinned /sys/fs/bpf/sk_storage Error: can't dump sk_storage map: Operation not supported # bpftool -j map dump pinned /sys/fs/bpf/sk_storage {"error":"can't dump sk_storage map: Operation not supported"} An error later in the walk is now reported too, as "bpftool map getnext" reports it, and the element count is printed only after a complete walk. Signed-off-by: Maxim Skokov <skokovmaksimevg@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Quentin Monnet <qmo@kernel.org> Link: https://patch.msgid.link/20261016194825.230433-3-skokovmaksimevg@gmail.com
2026-10-17bpftool: Print ENOTSUPP as "Operation not supported"Maxim Skokov
Some BPF commands return ENOTSUPP (524) to user space: iterating local storage maps, element operations on ringbuf maps, creating an LRU hash map without preallocation, freezing a struct_ops map, or running a program type that has no test_run. ENOTSUPP is kernel internal, so strerror() only gives "Unknown error 524": # bpftool map getnext pinned /sys/fs/bpf/sk_storage Error: can't get next key: Unknown error 524 Add a small helper that knows ENOTSUPP and use it where bpftool prints the error of map create, map element operations, map freeze and prog run. Suggested-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Maxim Skokov <skokovmaksimevg@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Quentin Monnet <qmo@kernel.org> Link: https://patch.msgid.link/20261016194825.230433-2-skokovmaksimevg@gmail.com
2026-10-16bpftool: Fix inverted tracefs validation when scanning /proc/mountsYuan Chen
The /proc/mounts fallback in get_tracefs_pipe() accepts only non-tracefs mount points, so a tracefs mounted outside the default locations is ignored: bpftool prog tracelog then mounts a second tracefs, or exits silently with --nomount. Negate the condition. Fixes: be3245e22d22 ("tools: bpftool: attempt to mount tracefs if required for tracelog cmd") Signed-off-by: Yuan Chen <chenyuan@kylinos.cn> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20261016015057.127061-1-chenyuan_fl@163.com
2026-10-15selftests/bpf: Remove the old test_bpf moduleDaniel Borkmann
The instruction tests of the test_bpf module live in the BPF selftests now, as the jit_insns test of test_progs, which BPF CI runs on every architecture it covers, and its skb_segment tests have a KUnit successor in net/core/net_test.c. Remove the module together with its Kconfig entry, the test_kmod.sh and test_bpf.sh wrappers of the bpf and net selftests, the config fragments and defconfigs that enabled it, as well as all other references to it and symbol exports in core kernel. For archs wanting to support BPF JITs, it's time they move over to the BPF selftests for proper coverage. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20261013171230.523677-19-daniel@iogearbox.net Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
2026-10-15resolve_btfids: Fix the --fatal_warnings exit statusPetr Pavlu
The resolve_btfids --fatal_warnings option is intended to make the tool exit with a non-zero status if any warnings are reported. main() initializes err to -1 and uses 'goto out' to return this status when a sub-operation fails. If no error occurs, 'if (!(fatal_warnings && warnings)) err = 0;' modifies the final status depending on whether any warnings have been reported. Commit 522397d05e7d ("resolve_btfids: Change in-place update with raw binary output") broke this logic by assigning the return values of newly added sub-operations to err. As a result, successful sub-operations overwrite the initial err value of -1 with 0, causing the tool to exit successfully even when --fatal_warnings is enabled and warnings have been reported. Fix the issue by setting the final value of err unconditionally, so the code doesn't depend on its previous value. Fixes: 522397d05e7d ("resolve_btfids: Change in-place update with raw binary output") Signed-off-by: Petr Pavlu <petr.pavlu@suse.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Ihor Solodrai <ihor.solodrai@linux.dev> Link: https://lore.kernel.org/bpf/20261008-resolve_btfids-warnings-v1-1-0d4e613ffa6e@suse.com
2026-10-12bpftool: Fix out-of-bounds read in kprobe_multi link info dumpYuan Chen
show_kprobe_multi_{plain,json}() walk the sorted kallsyms array against the sorted addr/cookie array with j as a cursor into the latter. The loop terminating condition is checked after the cursor has already been used to access the array: if (j++ == info->kprobe_multi.count) break; After all count entries have been printed, j has been bumped to count, but the loop keeps running and dereferences data[count] -- one element past the end of the calloc(count, sizeof(*data)) allocation -- while comparing every remaining kallsyms symbol. If the out-of-bounds value happens to match a symbol address, a bogus entry with a garbage addr/cookie pair is printed to boot. Fix the off-by-one by advancing the cursor before the comparison, so the loop terminates as soon as the last entry has been printed. Verified with an ASAN build of bpftool against a live kprobe_multi link of 3 symbols: before: ERROR: AddressSanitizer: heap-buffer-overflow READ of size 8 at link.c:860 (show_kprobe_multi_plain) and link.c:352 (show_kprobe_multi_json), 0 bytes after the 48-byte get_addr_cookie_array() allocation after: clean output, no ASAN report Fixes: edd7f49bb884 ("bpftool: Show kprobe_multi link info") Signed-off-by: Yuan Chen <chenyuan@kylinos.cn> Acked-by: Yafang Shao <laoar.shao@gmail.com> Acked-by: Quentin Monnet <qmo@kernel.org> Link: https://lore.kernel.org/bpf/20261010074435.1415234-1-chenyuan_fl@163.com Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
2026-10-11resolve_btfids: Populate BTF link sectionAlan Maguire
Allow the final BTF patch pass to populate one or more BTF link records. A link identifies the BTF section to be delivered, its carrier module, and the raw finalized BTF payload: --btf_link <section>:<module>:<raw-btf-file> Use the raw file size and SHA-256 digest to populate the corresponding <section>.link record. This avoids reparsing BTF during final ELF patching and supports inline vmlinux BTF linking. Signed-off-by: Alan Maguire <alan.maguire@oracle.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261009112324.1442319-3-alan.maguire@oracle.com
2026-10-11resolve_btfids: Build separate main and inline BTF objectsEduard Zingerman
Extract .BTF.inline via the following logic: - Traverse all types reachable from LOC_PARAM, LOC_PROTO, LOCSEC entries and mark them as having LOC color. - Traverse all types reachable from the remaining types and mark them as having MAIN or SHARED. - Create a new base BTF object and copy all MAIN/SHARED types there. - Create a new .BTF.inline object with base set to the new base BTF object, and copy all LOC types there. This way .BTF.inline can refer to types and strings in the new base, and strings used only by .BTF.inline remain in it. Additionally, all BTF_KIND_FUNC types that map to ELF symbols with the same name are forced to be in the base BTF. Same for types referenced from BTF id sets. Regular types referenced only from .BTF.inline remain in the base BTF, and sizes are 5 and 9.5Mb for vmlinux and vmlinux.inline respectively. Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Alan Maguire <alan.maguire@oracle.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261009112324.1442319-2-alan.maguire@oracle.com
2026-10-03bpftool: Skip pieces of variables in DATASECAlexei Starovoitov
The kernel accepts a variable in DATASEC that is smaller than its type. It's a piece of a variable that the compiler split, with the type of the whole variable. bpftool prints a variable by its type, so it reads past the piece and, when the piece is the last in the section, past the buffer with the value of the map: $ bpftool map dump pinned /sys/fs/bpf/piece ".bss": [{ "whole": 67305985 },{ "piece.0": { "a": [134678021,1994496712,32592,32,0,833,0,414764080 Only the first number is in the map. Skip the pieces in btf_dumper_datasec(), like btf_datasec_show() in the kernel does, and in show_prog_metadata(). Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20261002124714.180012-11-alexei.starovoitov@gmail.com Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
2026-09-30bpftool: Exit from the stream wait signal handler with _exit()Kumar Kartikeya Dwivedi
bpftool prog tracelog -w ends from its SIGINT, SIGHUP and SIGTERM handler, which calls exit(). exit() is not async-signal-safe: it runs atexit handlers and flushes stdio streams, and the signal may land while the read loop is inside fwrite() or fflush() on the stream being flushed. Whether that deadlocks or flushes a half-updated buffer depends on the C library. Call _exit() instead. The loop flushes every chunk as soon as it is printed, so the stdio buffer is empty except while a chunk is being written, and skipping the exit-time flush loses nothing. While here, note in the manual page that opening a stream as a file descriptor arrives in Linux 7.4, and restrict the -w/--wait description to the stdout/stderr form of the tracelog command, since the trace pipe form does not take the option. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Quentin Monnet <qmo@kernel.org> Link: https://lore.kernel.org/bpf/d64c6402-175f-4ea6-be6d-1a544a95c97c@qmon.net Link: https://lore.kernel.org/bpf/20260926154515.191689-1-memxor@gmail.com
2026-09-29bpftool: Update func representation to include function signatureAlan Maguire
Augment func= output for LOCSEC entries to include a mapping from function signature to where parameters are stored; for example: [290179] LOCSEC 'inline.text' vlen=524941 func='task_pid_nr(tsk [reg0])' func_type_id=136691 loc_proto_type_id=136693 offset=2097226 func='get_current()' func_type_id=136694 loc_proto_type_id=136695 offset=2097247 func='arch_static_branch(key [address 0x2e275e8], branch [const 0x0])' func_type_id=136697 loc_proto_type_id=136700 offset=2097296 Fixes: 321562c34d5b ("bpftool: Add ability to dump LOC_PARAM, LOC_PROTO and LOCSEC") Suggested-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Alan Maguire <alan.maguire@oracle.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Quentin Monnet <qmo@kernel.org> Link: https://patch.msgid.link/20260926175113.2368566-3-alan.maguire@oracle.com
2026-09-25bpftool: Add option to wait for program stream outputKumar Kartikeya Dwivedi
bpftool prog tracelog { stdout | stderr } PROG dumps the output buffered in a program stream and exits, which is all BPF_PROG_STREAM_READ_BY_FD allows. Waiting for further output means rerunning the command. Add a -w/--wait option that opens the stream with bpf_prog_stream_open() in its default blocking mode and keeps printing output as the program produces it. Flush each chunk as it arrives so redirected output is not held in stdio buffers while the next read blocks. Waiting is opt-in: the default dump keeps using BPF_PROG_STREAM_READ_BY_FD and exits once the buffered output is drained, so existing scripts behave the same on old and new kernels. A stream descriptor does not keep its program alive, so bpftool drops the program descriptor once the stream is open. Waiting then ends with EOF when the program is unloaded and otherwise runs until interrupted, as bpftool prog tracelog already does for the trace pipe. Exit from the SIGINT, SIGHUP and SIGTERM handlers like that command does. A flag set by the handler and checked before each read would miss a signal that lands between the check and the blocking read(), leaving bpftool asleep until the next print. Waiting requires BPF_PROG_STREAM_OPEN. The bpf() syscall fails with EINVAL for an unknown command, which bpftool reports as missing kernel support rather than degrading into a dump. Document the option and offer it in the bash completion. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Quentin Monnet <qmo@kernel.org> Link: https://patch.msgid.link/20260925045536.1480933-5-memxor@gmail.com
2026-09-24bpftool: Add support for BPF_F_PREORDER cgroup attach flagHui Su
Commit 4b82b181a26c ("bpf: Allow pre-ordering for bpf cgroup progs") introduced BPF_F_PREORDER to request pre-order execution across the cgroup hierarchy. Furthermore, attachments legitimately use combinations such as BPF_F_ALLOW_MULTI | BPF_F_PREORDER or BPF_F_ALLOW_OVERRIDE | BPF_F_PREORDER. With BPF_PROG_QUERY reporting the per-program BPF_F_PREORDER attribute, bpftool's exact-match formatter falls back to "unknown(40)" when BPF_F_PREORDER is present alone, or "unknown(41)" / "unknown(42)" when combined with BPF_F_ALLOW_OVERRIDE or BPF_F_ALLOW_MULTI. Additionally, do_attach() only accepts "multi" and "override", rejecting "preorder" with "unknown option". Before: $ bpftool cgroup show <cg> 1234 cgroup_inet_ingress unknown(42) test_prog $ bpftool cgroup attach <cg> cgroup_inet_ingress id 5678 multi preorder Error: unknown option: preorder After: $ bpftool cgroup show <cg> 1234 cgroup_inet_ingress multi,preorder test_prog $ bpftool cgroup attach <cg> cgroup_inet_ingress id 5678 multi preorder (attaches successfully) Refactor the attach flags formatter into a bitmask formatter that outputs comma-separated flag names for plain text while preserving unrecognized bits as "unknown(...)". Render attach flags as an array of flag names in JSON output. Accept "preorder" in do_attach(), update the cgroup documentation and synopsis to express valid flag combinations, and teach bash completion about them ("multi" or "override" optionally combined with "preorder"). Signed-off-by: Hui Su <sh_def@163.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Quentin Monnet <qmo@kernel.org> Link: https://patch.msgid.link/20260922025442.3176057-4-sh_def@163.com
2026-09-24bpftool: Add ability to dump LOC_PARAM, LOC_PROTO and LOCSECAlan Maguire
In raw mode ensure we can dump new BTF kinds in normal/json format. BTF_KIND_LOC_PARAMs are rendered as strings, for example a const value of 0x2a and a dereference of %r10 + 0x20: [12] LOC_PARAM '(anon)' size=4 flags=0x2 vlen=1 values='0x2a' [13] LOC_PARAM '(anon)' size=8 flags=0x38 vlen=2 values='*(reg10 + 0x20)' LOC_PROTOs render the associated values of each of their LOC_PARAMs for easier readability: [14] LOC_PROTO '(anon)' vlen=2 type_id=12 value='0x2a' type_id=13 value='*(reg10 + 0x20)' and LOCSEC shows function name associated with site: [15] LOCSEC 'inline.text' vlen=1 name='foo' func_type_id=5 loc_proto_type_id=14 offset=64 Registers are displayed in an architecture-neutral form; 'regN' where N is the DWARF register number, or 'fbreg' for the stack frame base. Signed-off-by: Alan Maguire <alan.maguire@oracle.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20260924111428.75957-10-alan.maguire@oracle.com
2026-09-24bpftool: Document support for multi-split BTFAlan Maguire
Document the ability to pass multiple levels of split BTF, using "-B base-btf" options. Signed-off-by: Alan Maguire <alan.maguire@oracle.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20260924111428.75957-9-alan.maguire@oracle.com
2026-09-24bpftool: Handle multi-split BTF by supporting multiple base BTFsAlan Maguire
For bpftool to be able to dump .BTF.inline data in /sys/kernel/btf/foo.inline for module foo, it needs to support multi-split BTF because the parent-child relationship of BTF inline data for modules is vmlinux BTF data module BTF data module BTF inline data So for example to dump BTF inline info for xfs we would run $ bpftool btf dump -B /sys/kernel/btf/vmlinux -B /sys/kernel/btf/xfs file /sys/kernel/btf/xfs.inline Multiple bases are specified with the vmlinux base BTF first (parent) followed by the xfs BTF (child), and finally the XFS BTF inline info. Update help text accordingly to reflect the ability to specify multiple in-order root-to-branch bases. Signed-off-by: Alan Maguire <alan.maguire@oracle.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20260924111428.75957-8-alan.maguire@oracle.com
2026-09-24bpftool: Fix sparse CPU IDs in prog profileHui Su
bpftool prog profile currently treats the number of possible CPUs as both the logical CPU ID range and the stride of the perf event array. That misses valid logical CPUs when the possible CPU mask is sparse, such as 0,2-3, and can use incorrect PERF_EVENT_ARRAY keys. Keep the compact possible CPU count for per-CPU result buffers, while enumerating the actual logical CPU IDs when creating per-CPU perf event groups. Use the maximum logical CPU ID plus one as the metric stride in the PERF_EVENT_ARRAY. This keeps the current per-CPU event grouping intact while separating the compact per-CPU buffer index from the logical CPU ID and event-array key. Report the logical CPU ID when a per-CPU event was not counted. Fixes: 47c09d6a9f67 ("bpftool: Introduce "prog profile" command") Signed-off-by: Hui Su <sh_def@163.com> Link: https://lore.kernel.org/bpf/20260813160858.1042834-3-sh_def@163.com/ Link: https://lore.kernel.org/bpf/20260923004243.969919-3-sh_def@163.com Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
2026-09-24bpftool: Fix CPU IDs in per-CPU map outputHui Su
bpftool uses dense per-CPU value-buffer slots when printing per-CPU map values. It also uses the slot index as the CPU ID, which produces incorrect labels when the possible CPU mask is sparse, such as 0,2-3. Parse the possible CPU mask and use the corresponding logical CPU ID in plain, JSON, and BTF-formatted output. Keep the dense slot index for accessing the per-CPU value buffer. Pass the parsed CPU count together with the CPU ID array so that the printed CPU IDs and loop bounds come from the same possible-CPU mask. Propagate CPU-ID lookup and map output errors through the shared output path to its callers. Fixes: 71bb428fe2c1 ("tools: bpf: add bpftool") Signed-off-by: Hui Su <sh_def@163.com> Link: https://lore.kernel.org/bpf/20260813155131.1022745-3-sh_def@163.com/ Link: https://lore.kernel.org/bpf/20260923004243.969919-2-sh_def@163.com Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
2026-09-21bpftool: Read ring buffer maps with event_pipeTianyi Chen
map event_pipe only accepts perf event arrays, leaving no built-in way to inspect records produced through the BPF ring buffer API. Extend it to consume queued and live BPF_MAP_TYPE_RINGBUF records in plain or JSON output, retaining the existing perf event array path. Ring buffers have a shared consumer position and no implicit CPU or timestamp. Document that this command consumes records rather than observing them passively, and reject perf-only CPU/index selectors. A producer can keep ring_buffer__poll() busy after a stop signal, so return -EINTR from the record callback when stopping. Keep stdio out of the shared signal handler and preserve callback output errors. Signed-off-by: Tianyi Chen <hi@tychen.cc> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Tested-by: Quentin Monnet <qmo@kernel.org> Link: https://github.com/libbpf/bpftool/issues/54 Link: https://lore.kernel.org/bpf/20260921073556.99421-2-hi@tychen.cc
2026-09-21bpftool: Compute map size of light skeletons at runtimeLeon Hwang
bpftool rounds memory-mapped data map sizes to the host page size when generating a light skeleton. The generated code therefore uses a 64K mapping size when bpftool runs on a 64K-page host, even if the skeleton runs on a 4K-page target. The target rejects the oversized map mmap(), causing failure of loading the light skeleton. When try to run 64K-page selftests on 4K-page VM, the error message does not provide the reason about page size. test_atomics:PASS:atomics skeleton open 0 nsec test_atomics:FAIL:atomics skeleton load unexpected error: -12 (errno 22) #15 atomics:FAIL Pass the original map value size and max entries to the generated code and round mmap size to the runtime page size in the user-space light skeleton helpers. This keeps generated light skeletons independent of the build host page size. Fixes: d510296d331a ("bpftool: Use syscall/loader program in "prog load" and "gen skeleton" command.") Signed-off-by: Leon Hwang <leon.hwang@linux.dev> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Quentin Monnet <qmo@kernel.org> Link: https://lore.kernel.org/bpf/20260915161450.96249-1-leon.hwang@linux.dev
2026-09-17bpftool: Scale counters and report cycles per runMykyta Yatsenko
Perf counters undercount when the PMU multiplexes them. Scale each per-CPU value before aggregation. Per-CPU event groups make PMU ratios use matching scheduling intervals. Keep run_cnt as the total number of program executions, independent of counter scheduling. Keep JSON value raw, report the scaled value in value_scaled, and document the output. Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20260916-bpftool_cyles_per_run-v4-3-f2de02c480d5@meta.com
2026-09-17bpftool: Group profile events by CPUMykyta Yatsenko
Independently scheduled perf events can cover different intervals, making derived ratios inconsistent. Open one event group per CPU and enable it only after all selected metrics have joined. Fail the profile setup when a selected event cannot join its group. Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20260916-bpftool_cyles_per_run-v4-2-f2de02c480d5@meta.com
2026-09-17bpftool: Accept zero perf counter snapshotsMykyta Yatsenko
A perf counter can be zero at fentry when PMU multiplexing has not scheduled the event. Do not reject that sample. Use enabled time to distinguish a successful snapshot. Read directly into the per-CPU map value. Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20260916-bpftool_cyles_per_run-v4-1-f2de02c480d5@meta.com
2026-09-14bpftool: Adopt bpf_program__add_flags() helperToke Høiland-Jørgensen
Adopt the newly added bpf_program__add_flags() helper to non-destructively add the BPF_F_XDP_DEV_BOUND_ONLY flag to XDP programs. Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Quentin Monnet <qmo@kernel.org> Acked-by: Ihor Solodrai <ihor.solodrai@linux.dev> Link: https://lore.kernel.org/bpf/20260912084109.432834-4-toke@redhat.com
2026-09-06Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf 7.3-rc2Alexei Starovoitov
Cross-merge BPF and other fixes after downstream PR. Conflicts: kernel/bpf/backtrack.c include/linux/bpf_verifier.h Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2026-09-02bpftool: Set BPF_F_XDP_DEV_BOUND_ONLY flag non-destructivelyToke Høiland-Jørgensen
When setting the XDP hints ifname, bpftool would set the BPF_F_XDP_DEV_BOUND_ONLY without looking at the existing program flags, overriding any other flag values. This was always a destructive action, but after we change libbpf to carry the frags section flag in prog_flags, this can impact bpftool loading of XDP frags programs. Change the flag setting to be non-destructive by OR'ing it with the existing flags. Fixes: f46392ee3dec ("bpftool: Specify XDP Hints ifname when loading program") Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com> Link: https://lore.kernel.org/bpf/20260901-libbpf-frags-flags-v3-1-4eb6f14968b0@redhat.com
2026-08-29bpftool: Don't drop a type in the sorted C dumpIhor Solodrai
The C dump sorts types by default, so that generated headers are diffable. The sorted dump emits one type fewer than the unsorted dump of the same BTF. dump_btf_c() starts its loop at index 1 to skip the void type at BTF type ID 0. That holds for the unsorted dump, where the array index is the type ID, but not after qsort(): position 0 is then the lowest ranked type, and btf_type_rank() ranks an anonymous enum 0 while void takes the default rank of 10. So the enum is skipped, and void is emitted instead as a no-op. Fixes: 94133cf24bb3 ("bpftool: Introduce btf c dump sorting") Acked-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Link: https://lore.kernel.org/r/20260828215207.3105313-7-ihor.solodrai@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2026-08-29bpftool: Support ML-DSA program signingDaniel Borkmann
Add bpftool support for ML-DSA program signing and drop the flag for ML-DSA keys on affected OpenSSL versions, the same way as commit 0ad9a71933e7 ("modsign: Enable ML-DSA module signing"). Also, an ML-DSA-87 signature is 4627 bytes on its own, so the blob does not fit into the 4 KiB of MAX_SIG_SIZE anymore and signing would fail otherwise. Bump to 16 KiB. MAX_SIG_SIZE only sizes the buffer for what bpftool itself emits (unrelated to BPF_PROG_MAX_SIGNATURE_SIZE). Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/r/20260828175227.1537793-5-daniel@iogearbox.net Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2026-08-27bpftool: Fix bypass of the batch line length check by commentsYuan Chen
do_batch() strips trailing comments by truncating the line at '#' before checking whether fgets() filled the buffer. If a batch line longer than the buffer contains a '#' within the first sizeof(buf) - 1 bytes, the truncation makes strlen(buf) smaller and the line-length check is bypassed. The unread remainder of the line then stays in the file stream and is parsed and executed as a separate command on the next loop iteration. Continuation lines handled below are affected the same way: an overlong continuation line containing '#' bypasses the "command is too long" check, and its unread remainder is executed as a separate command. Move the line-length checks before the comment is stripped, so they see the full line as read from the file and overlong lines are rejected regardless of comments. A line that fills the buffer exactly is now rejected as well, which is fine: batch command lines are not expected to come anywhere near the buffer limit. Fixes: 71bb428fe2c1 ("tools: bpf: add bpftool") Signed-off-by: Yuan Chen <chenyuan@kylinos.cn> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20260824092657.1789956-3-chenyuan_fl@163.com
2026-08-27bpftool: Fix spurious batch file read errorYuan Chen
do_batch() checks errno after the read loop to detect read failures, but fgets() does not clear errno on success, so a stale errno left by a previously executed command (e.g. map dump's EBADF from a double close) makes bpftool report a batch file read failure and exit with an error even though every command succeeded. Clear errno before each fgets() call, so the post-loop check only sees the outcome of the last read: zero on success or EOF, E2BIG for an overlong line, and a genuine errno when fgets() fails. Since errno is now reset before every read in batch mode, drop the USE_LIBCAP errno reset in main() that existed only to keep errno clean for the batch mode. Fixes: 71bb428fe2c1 ("tools: bpf: add bpftool") Signed-off-by: Yuan Chen <chenyuan@kylinos.cn> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20260824092657.1789956-2-chenyuan_fl@163.com
2026-08-22Merge tag 'perf-tools-for-v7.3-2026-08-21' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools Pull perf tools updates from Namhyung Kim: "perf c2c: - Add 'function view' in perf c2c report TUI (switched by pressing 'TAB' in the cacheline view) to organize samples around functions rather than cachelines in 3-level hierarchy: Level 1: Read-side function (sorted by estimated Cycles %) Level 2: Contending writer functions (sorted by Store count) Level 3: Shared cacheline addresses Users can navigate the entries and fold/unfold using 'e' key. An example output would look like below: Shared Data Functions Table (19 entries, sorted on Cycles %) Cycles Store % count Function / Contending function / Cacheline ---------------------------------------------------------------------- + 35.67% 876 + [k] cpupri_set + 24.31% 424 + [k] pull_rt_task - 16.53% 555 - [k] dequeue_pushable_task 145 - [k] pull_rt_task 145 0xff2d0082809da080 139 - [k] enqueue_pushable_task 70 0xff2d00a2071f9640 69 0xff2d0082809da000 python module support: - Extend "perf" python module so that it can be fully functional. The goal is to run scripts directly, not by 'perf script' command. This would give better performance as well as more control to build standalone programs with UI. - Add LiveSession helper (perf_live.py) to enable live event collection directly from Python using perf.evlist and perf.parse_events. perf stat: - Add --hide-zero-events option to suppress zero-count events - Reject conflicting --field-separator and --json-output options - Fix duplicate event output with --for-each-cgroup perf sched latency: - Add -H/--histogram and --hist-mode (log|linear) options to show scheduler wait latency histograms - Add --time option to filter analysis by time span in 'perf sched latency' ARM CoreSight: - Synthesize callchains for instruction samples from CoreSight trace using thread stack ('--itrace=g...') - Support call indentation ('perf script -F +callindent') to display call depth hierarchy on branch samples - Decode ETE (Embedded Trace Extension) exception packets Build system: - Add 'make install-build-deps' target to install required packages - Parallelize JSON and metric pre-computation in jevents.py for faster builds Vendor event/metric updates: - Add Intel Nova Lake events and update tables for existing models - Update AMD Zen 5 and Zen 6 core events - Update Arm64 Tegra410 metrics and PowerPC hcalls Internal changes and fixes: - Harden trace-event and synthetic event parsing against corrupted data - Fix unwinding of multi-threaded processes in libdw unwinder - Fix memory leaks in various commands and python bindings - Speed up 'perf test' shell tests" * tag 'perf-tools-for-v7.3-2026-08-21' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools: (232 commits) perf vendor events arm64: Fix Tegra410 Olympus event 0x0197 perf vendor events arm64: fix swapped MetricGroup for Tegra410 L1 prefetcher metrics perf evlist: Warn when 'sleep' workload is used without system-wide (-a) option perf c2c: document function view in perf-c2c man page perf c2c: add function view browser UI and cacheline detail perf c2c: build and finalize the function view hierarchy perf c2c: add function view hierarchy entry creation perf c2c: add function view stats merge and memory management perf c2c: add HPP list parsing for function view columns perf c2c: add column rendering for function view perf c2c: add function view model skeleton perf c2c: extract shared data structures into util/c2c.h perf test sample-parsing: Validate PERF_FORMAT_GROUP values without LOST perf dso: Replace assert with runtime check in dso__read_symbol() perf dso: Guard against cache underflow on short reads in dso_cache__memcpy() perf dso: Use stored fd error instead of stale errno in file_read() and file_size() perf dso: Guard close() against invalid fd in dso__decompress_kmodule_path() perf dso: Guard against errno==0 when dso__get_filename() returns NULL perf build: install-build-deps: add RHEL family devel package mapping perf build: Remove leftover feature tests for removed cxx and clang support ...
2026-08-13bpftool: Fix double close in map dumpYuan Chen
map_dump() closes the map fd in its error path, and do_dump() then closes the same fd again after a successful dump. Closing an already closed fd leaves errno set to EBADF, which poisons later errno checks such as the batch file read check in do_batch(). Let do_dump() own the fd and remove the close from map_dump(). The same double-close pattern exists in do_show_subset(): both show_map_close_json() and show_map_close_plain() already close the fd, so drop the extra close() there as well. Also propagate the error when bpf_map_get_info_by_fd() fails on a subsequent map in do_dump(): set err = -1 before breaking out of the loop, so a later failure is not silently hidden after an earlier iteration succeeded. Fixes: 99f9863a0c45f ("bpftool: Match maps by name") Signed-off-by: Yuan Chen <chenyuan@kylinos.cn> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20260810142224.2907373-2-chenyuan_fl@163.com
2026-08-13bpftool: Generate skeleton for global percpu dataLeon Hwang
Enhance bpftool to generate skeletons that properly handle global percpu variables. The generated skeleton now includes a dedicated structure for percpu data, allowing users to initialize and access percpu variables more efficiently. For global percpu variables, the skeleton now includes a nested structure, e.g.: struct test_global_percpu_data { struct bpf_object_skeleton *skeleton; struct bpf_object *obj; struct { struct bpf_map *percpu; } maps; // ... struct test_global_percpu_data__percpu { int data; char run; struct { char set; int i; int nums[7]; } struct_data; int nums[7]; } *percpu; // ... }; * The "struct test_global_percpu_data__percpu *percpu" points to initialized data, which is actually "maps.percpu->mmaped". * Before loading the skeleton, updating the "struct test_global_percpu_data__percpu *percpu" modifies the initial value of the corresponding global percpu variables. * After loading the skeleton, "maps.percpu->mmaped" has been marked as read-only in libbpf. If users want to update the global percpu variables, they have to update the "maps.percpu" map instead. * For lightweight skeleton, "lskel->percpu" will be protected by "mprotect(p, sz, PROT_READ)". * For subskeleton, those variables of global percpu data will be skipped. Assisted-by: Codex:gpt-5.5-xhigh Signed-off-by: Leon Hwang <leon.hwang@linux.dev> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Quentin Monnet <qmo@kernel.org> Link: https://lore.kernel.org/bpf/20260813152324.97937-7-leon.hwang@linux.dev
2026-08-12resolve_btfids: Emit arena attributes from kfunc parameter suffixesKumar Kartikeya Dwivedi
Kfunc declarations can identify arena arguments through parameter name suffixes without repeating KF_ARENA_ARG flags in their BTF ID sets. resolve_btfids currently misses those arguments when synthesizing the address_space(1) attributes used by generated vmlinux.h files. Teach the arena prototype rewrite to recognize __arena and __arena__nullable directly on each parameter. Keep KF_ARENA_ARG1 and KF_ARENA_ARG2 handling for explicitly flagged kfuncs, while allowing suffixes on any argument without synthesizing kfunc flags. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://patch.msgid.link/20260812193842.2879226-2-memxor@gmail.com Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
2026-08-08bpf: Do not print a newline after disassembly in bpf_verbose_insn()Eduard Zingerman
At the moment there are more callsites that want bpf_verbose_insn() to not print a newline after the instruction, than callsites that want a newline. Drop '\n' from disasm.c. Non-functional change. The changes in bpftool are verified by writing a bpf program using a variety of instructions and comparing `prog dump xlated` output in the following modes: plain, opcodes, visual, visual opcodes. The output before and after the changes is identical. Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Quentin Monnet <qmo@kernel.org> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20260807-static-zext-v4-1-b6c270013c77@gmail.com
2026-08-06docs, resolve_btfids: Document kfunc BTF annotation emissionIhor Solodrai
resolve_btfids now emits the bpf_kfunc and bpf_fastcall BTF decl tags and the arena address_space(1) type attribute for kfuncs, which were previously produced by pahole. Reflect this in the in-tree comments and documentation. Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com> Link: https://patch.msgid.link/20260807032029.78092-7-ihor.solodrai@linux.dev Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
2026-08-06resolve_btfids: Emit bpf_kfunc and bpf_fastcall decl tagsIhor Solodrai
Emit the bpf_kfunc decl tag for every discovered kfunc, and bpf_fastcall for kfuncs flagged KF_FASTCALL. These were previously produced by pahole under --btf_features=decl_tag_kfuncs. resolve_btfids now discovers kfuncs from the BTF ID sets [1] and becomes the source of truth for their annotations. Drop decl_tag_kfuncs pahole feature flag from scripts/Makefile.btf [1] https://lore.kernel.org/all/20260722233518.778854-1-ihor.solodrai@linux.dev/ Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Acked-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://patch.msgid.link/20260807032029.78092-5-ihor.solodrai@linux.dev Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
2026-08-06resolve_btfids: Process KF_ARENA_* flags in resolve_btfidsIhor Solodrai
For kfuncs flagged with KF_ARENA_RET, KF_ARENA_ARG1 or KF_ARENA_ARG2, the address_space(1) attribute (a type tag with kflag=1) must be emitted for the corresponding type in BTF. This was previously done by pahole via the "attributes" BTF feature [1]. Implement the emission of the arena attributes in resolve_btfids: for flagged kfuncs create a new function prototype with updated BTF types. The original proto may be shared with sibling FUNCs, so it is not modified in place. Emission is unconditional: kbuild controls the pahole flags, so the input BTF is expected to not have these attributes. Invalid declarations are reported as errors. Drop the "attributes" pahole feature from scripts/Makefile.btf resolve_btfids now emits them for all supported pahole versions. [1] https://lore.kernel.org/dwarves/20250228194654.1022535-1-ihor.solodrai@linux.dev/ Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Link: https://patch.msgid.link/20260807032029.78092-3-ihor.solodrai@linux.dev Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
2026-08-06resolve_btfids: Deduplicate BTF after btf2btf transformationsIhor Solodrai
btf2btf() adds new types to the BTF: the KF_IMPLICIT_ARGS transform synthesizes an _impl FUNC together with its FUNC_PROTO and copies of the kfunc's decl tags. Nothing deduplicates them afterwards. pahole runs btf__dedup() on its own output, but that happens before resolve_btfids sees the BTF, so any type the tool itself creates is emitted as-is, even when a structurally identical type is already present. Call btf__dedup() at the start of finalize_btf(), so that base distillation and the by-name sort both operate on the canonical set of types. On an x86_64 build with the BPF selftests config this removes 17 duplicate FUNC_PROTOs from vmlinux BTF. The dedup call increases runtime of resolve_btfids on vmlinux by 30-40%. The performance hit is an acceptable cost to keep kernel BTF deduped [1]. [1] https://lore.kernel.org/bpf/986e6f4e-4b51-4440-a37c-9624906d7370@linux.dev/ Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Link: https://patch.msgid.link/20260807032029.78092-2-ihor.solodrai@linux.dev Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
2026-07-30resolve_btfids: Enforce consistent kfunc flags across BTF ID setsIhor Solodrai
A kfunc may be listed in several BTF ID sets, which is expected because different kfuncs are available to BPF programs depending on their type. However kfunc flags across different BTF ID sets must be consistent [1]. The flags should be considered a part of the kfunc declaration, because they influence its BTF representation and verifier handling. Enforce the kfunc flag consistency in resolve_btifds by hard failing on error and blocking kernel (or module) build. [1] https://lore.kernel.org/bpf/9b2196dd-443b-4632-ae11-030cdbdc59b4@linux.dev/ Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/bpf/20260722233518.778854-9-ihor.solodrai@linux.dev
2026-07-30resolve_btfids: Discover kfuncs from BTF ID setsIhor Solodrai
collect_kfuncs() currently uses bpf_kfunc decl tags to identify the list of kfuncs. The decl tags are generated by pahole, which makes current implementation implicitly rely on those tags being generated. The authoritative source, used by the the BPF verifier for kfunc registration, of functions being BPF kfuncs are BTF_KFUNCS_START()/END() declarations. These are BTF_ID_SET8 under the hood. Currently resolve_btfids reads kfunc flags from these sets, and populates them with BTF IDs. Implement kfunc discovery from BTF_ID_SET8 symbols in resolve_btfids, removing the dependency on pahole's emmission of decl tags. Walk BTF_ID_KIND_SET8 sets, and use the address-to-symbol index to look up set entry's BTF_ID symbol name (before .BTF_ids is patched), recording the paired flags directly. This makes find_kfunc_flags() helper unnecessary, so it's removed. Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/bpf/20260722233518.778854-8-ihor.solodrai@linux.dev
2026-07-30resolve_btfids: Fix the _impl lookup for module BTFIhor Solodrai
process_kfunc_with_implicit_args() skips generating <name>_impl function when one already exists for backwards compatibility. It uses btf__find_by_name_kind(), which searches the base BTF before the split BTF. When resolve_btfids processes a module, a same-named _impl in vmlinux would be found and the module's own counterpart would not be created. Fix by using btf__find_by_name_kind_own() for the lookup. Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/bpf/20260722233518.778854-6-ihor.solodrai@linux.dev
2026-07-30resolve_btfids: Keep collected kfuncs in a rbtreeIhor Solodrai
Store collected kfuncs in a rbtree keyed by BTF ID instead of a dynamically grown array. This allows for efficient deduplication for kfuncs declared in multiple sets, which is needed for subsequent patches [1]. [1] https://lore.kernel.org/bpf/CAEf4BzaLzX3mXvQzxv+gbmZOh84XvYofLjMSWFYghNjS-ohEZg@mail.gmail.com/ Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/bpf/20260722233518.778854-4-ihor.solodrai@linux.dev
2026-07-30resolve_btfids: Index BTF ID symbols by addressIhor Solodrai
Keep an address-sorted index of parsed .BTF_ids symbols so that the original BTF_ID symbol name can be recovered from an entry address. Use the index in find_kfunc_flags() to scan BTF_SET8_KFUNCS entries directly and match each entry back to the requested kfunc. Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com> Reviewed-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/bpf/20260722233518.778854-3-ihor.solodrai@linux.dev
2026-07-30resolve_btfids: Implement generic ensure_mem() to grow arraysIhor Solodrai
push_*() helpers in resolve_btfids contain copy-pasted array growth logic. Factor it out into ensure_mem() - a simplified variant of libbpf_ensure_mem(), and use it in the helpers. Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/bpf/20260722233518.778854-2-ihor.solodrai@linux.dev
2026-07-25tools/build: selftests: Remove some duplicate toolchain definitionsJames Clark
Try to remove some, but not all duplicate toolchain definitions. In these instances, their makefiles already include tools/scripts/Makefile.include which defines these in a consistent way. STRIP is the only one that was set with an '=', but I don't think it was significant so that difference can be dropped. Signed-off-by: James Clark <james.clark@linaro.org> Reviewed-by: Ian Rogers <irogers@google.com> Acked-by: Ihor Solodrai <ihor.solodrai@linux.dev> Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
2026-07-20bpftool: Skip prog/map that disappears while looking it up by nameJiayuan Chen
Looking up a prog or map by name walks the whole id space. There is a window between bpf_prog_get_next_id()/bpf_map_get_next_id() and getting an fd for that id in which an unrelated object can be freed, and the lookup then fails with ENOENT and aborts the whole command. Skip such ids and keep walking, the same way do_show() already does. Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev> Link: https://lore.kernel.org/bpf/20260720071520.396363-1-jiayuan.chen@linux.dev Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
2026-07-08bpftool: Cover loader metadata with the program signatureDaniel Borkmann
bpftool_prog_sign() signed only the loader instructions. The metadata blob the loader installs was left to an in-loader hash check, which the kernel now performs at load time over insns || metadata. Sign that same concatenation: pass the metadata blob (gen_loader_opts data) through to bpftool_prog_sign() and feed insns || metadata to CMS_final(). The excl_prog_hash stays a digest of the instructions alone; it binds the metadata map to the loader and is matched against prog->digest by the verifier, independent of what the signature covers. The signed artifact is now plain data: both bytes the signature covers are embedded verbatim in the generated skeleton, so signing and verifying an lskel is an ordinary CMS operation that a signer or auditor can perform (or reproduce) offline, without analyzing loader bytecode to establish what the signature actually attests to. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Quentin Monnet <qmo@kernel.org> Link: https://lore.kernel.org/bpf/20260708075343.358712-6-daniel@iogearbox.net Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
2026-07-08bpftool: Check EVP_Digest when computing excl_prog_hashDaniel Borkmann
bpftool_prog_sign() ignores the return value of EVP_Digest(). If the digest computation fails (context allocation failure, or a digest fetch failure under OpenSSL), EVP_Digest() returns 0 and leaves the output buffer untouched, but the function still reports success. Fixes: 40863f4d6ef2 ("bpftool: Add support for signing BPF programs") Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Quentin Monnet <qmo@kernel.org> Link: https://lore.kernel.org/bpf/20260708075343.358712-5-daniel@iogearbox.net Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>