diff options
| author | Alexei Starovoitov <ast@kernel.org> | 2026-10-18 15:28:51 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-10-18 15:28:51 +0000 |
| commit | 2c7935600733c2168b81d3f0f31247ed20d54be0 (patch) | |
| tree | 18fa2bafea471c3a1f294417a138a68f286e34e9 /tools/perf/scripts/python | |
| parent | 8cebaa3be829c88a59957900f8de98fed09daefe (diff) | |
| parent | 38dbc3047a2fa706f6b4485679eb5eb62ff55b87 (diff) | |
Merge branch 'bpf-zero-extend-the-index-in-inlined-bpf_get_func_arg'
Woojin Ji says:
====================
bpf: Zero-extend the index in inlined bpf_get_func_arg()
v2, from the review of v1:
- Shift the index as a 32-bit value instead of inserting an explicit
zero-extension (Alexei). The inlined sequence is one instruction shorter
and the bounds check is untouched, so no program is accepted or rejected
differently.
- The selftest is now a separate patch (Jiri). Patch 2 keeps Jiri's
Acked-by from v1; patch 1 does not, because the kernel patch changed.
v1, the problem: bpf_get_func_arg() takes a u32 index, but the inlined
expansion compared only the low 32 bits of R2 with the argument count and
then shifted the full 64-bit register to compute the context address. R2 is
ARG_ANYTHING, so an index of 1ULL << 32 passed the bounds check as index
zero while the load was performed at ctx + (1ULL << 35).
Patch 2 depends on patch 1: without it the wide index faults in the inlined
sequence and the guest panics.
Validation, re-run with this revision (the 32-bit shift kernel):
- Disposable x86_64 QEMU guest running a BTF-enabled kernel built with
clang 22, with tracing and bpf_testmod. test_progs output, verbatim:
#150 get_func_args_fsession_test:OK
#151 get_func_args_test:OK
Summary: 2/0 PASSED, 0 SKIPPED, 0/0 FAILED
The pairs in that line are top-level tests/subtests, so both tests pass
with nothing skipped or failed; TEST_PROGS_EXIT=0 and the guest dmesg is
clean.
- The same two tests on unpatched ff47652a4b66 fault in the inlined
sequence: a page fault in bpf_prog_..._test2, with the load performed at
ctx + (1ULL << 35), which panics the guest.
- bpftool xlated dumps of both test programs show the index shifted as a
32-bit value (w2 <<= 3) at all 32 inlined helper sites on this kernel,
and the 64-bit shift (r2 <<= 3) at all 32 on unpatched ff47652a4b66.
v1: https://lore.kernel.org/bpf/179221432098.1890560.17043109037413683447.get-func-arg-index@gmail.com/
---
====================
Link: https://patch.msgid.link/20261018-get-func-arg-v2-0-048848b3eddf@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
