From: Woojin Ji <random6.xyz@gmail.com>
To: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Woojin Ji <random6.xyz@gmail.com>
Subject: [PATCH bpf v2 0/2] bpf: Zero-extend the index in inlined bpf_get_func_arg()
Date: Sun, 18 Oct 2026 13:21:40 +0900 [thread overview]
Message-ID: <20261018-get-func-arg-v2-0-048848b3eddf@gmail.com> (raw)
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/
---
Woojin Ji (2):
bpf: Zero-extend the index in inlined bpf_get_func_arg()
selftests/bpf: Test out-of-range index bits in bpf_get_func_arg()
kernel/bpf/fixups.c | 2 +-
.../selftests/bpf/progs/get_func_args_test.c | 36 ++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
---
base-commit: ff47652a4b66c067c765a7ad464d930b5a9367cc
change-id: 20261018-get-func-arg-93c80d63ef45
Best regards,
--
Woojin Ji <random6.xyz@gmail.com>
next reply other threads:[~2026-10-18 4:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 4:21 Woojin Ji [this message]
2026-10-18 4:21 ` [PATCH bpf v2 1/2] bpf: Zero-extend the index in inlined bpf_get_func_arg() Woojin Ji
2026-10-18 4:55 ` bot+bpf-ci
2026-10-18 4:21 ` [PATCH bpf v2 2/2] selftests/bpf: Test out-of-range index bits in bpf_get_func_arg() Woojin Ji
2026-10-18 15:30 ` [PATCH bpf v2 0/2] bpf: Zero-extend the index in inlined bpf_get_func_arg() patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261018-get-func-arg-v2-0-048848b3eddf@gmail.com \
--to=random6.xyz@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.