From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: <bot+bpf-ci@kernel.org>, <bpf@vger.kernel.org>
Cc: <ast@kernel.org>, <andrii@kernel.org>, <daniel@iogearbox.net>,
<eddyz87@gmail.com>, <emil@etsalapatis.com>, <tj@kernel.org>,
<kkd@meta.com>, <kernel-team@meta.com>, <martin.lau@kernel.org>,
<yonghong.song@linux.dev>, <mason@kernel.org>,
<ihor.solodrai@linux.dev>
Subject: Re: [PATCH bpf-next v1 01/18] bpf: Add accessors for verifier stack slots
Date: Wed, 23 Sep 2026 22:04:45 +0200 [thread overview]
Message-ID: <DLMYRPN1E0EQ.1XSYMJIAKSM85@gmail.com> (raw)
In-Reply-To: <731653ff84bafb19361b62836f366d369799041bf18166b016dc7ff13eff5b73@mail.kernel.org>
On Wed Sep 23, 2026 at 9:57 PM CEST, bot+bpf-ci wrote:
>> bpf: Add accessors for verifier stack slots
>>
>> The verifier indexes a frame's stack state directly through
>> state->stack[spi] and computes the number of tracked slots as
>> allocated_stack / BPF_REG_SIZE in every file that touches stack slots.
>> Route all of these through two helpers, bpf_stack_slot() and
>> bpf_stack_nr_slots(), so the layout of the per-frame stack state is
>> visible in one place and can change without touching every user.
>> Both take a const frame: the slot accessor returns the slot through the
>> frame's stack pointer, so read-only code such as the state printer can
>> use it without giving up its qualifiers. Functions that look up the
>> same slot repeatedly now fetch it once.
>>
>> No functional change.
>>
>> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
>
> The commit message makes two universal claims that the tree does not back
> up after this patch.
>
> 1) "Route all of these through two helpers ... so the layout of the
> per-frame stack state is visible in one place and can change without
> touching every user."
>
> At least two users of struct bpf_func_state::stack still depend on the raw
> layout:
>
> drivers/net/ethernet/netronome/nfp/bpf/verifier.c:nfp_bpf_map_update_value_ok():
>
> state = env->cur_state->frame[reg3->frameno];
> ...
> soff = -(off + i) - 1;
> stack_entry = &state->stack[soff / BPF_REG_SIZE];
>
This is correct, will fix.
> This is the exact state->stack[spi] indexing the message says was removed.
> It was not converted.
>
> kernel/bpf/diagnostics.c:reg_to_target(), which this patch edits (the nslots
> line), still does raw pointer arithmetic that assumes stack is a flat array:
>
> start = (unsigned long)state->stack;
> end = (unsigned long)(state->stack + nslots);
> ...
> spi = ((const char *)reg - (const char *)state->stack) /
> sizeof(*state->stack);
>
> If bpf_stack_slot() ever stops being &frame->stack[spi], both sites will
> silently compute wrong slots. So the stated goal (the layout can change
> without touching every user) does not hold yet.
>
> Nothing later in 277f2757dee8..7757cddf610a changes the helpers, the layout,
> or the nfp code, so this is not a runtime bug in the series. It is an
> incomplete conversion, or a message that needs narrowing.
>
Yep, also needs fixing.
> 2) "Functions that look up the same slot repeatedly now fetch it once."
>
> Several converted functions still call the accessor twice for the same
> index:
>
> bpf_get_spilled_reg():
>
> (1 << bpf_stack_slot(frame, slot)->slot_type[BPF_REG_SIZE - 1]) & mask)
> return &bpf_stack_slot(frame, slot)->spilled_ptr;
>
> bpf_mark_all_scalars_precise():
>
> if (!bpf_is_spilled_reg(bpf_stack_slot(func, j)))
> reg = &bpf_stack_slot(func, j)->spilled_ptr;
>
> bpf_mark_chain_precision():
>
> if (!bpf_is_spilled_scalar_reg(bpf_stack_slot(func, i))) {
> reg = &bpf_stack_slot(func, i)->spilled_ptr;
>
> The same pattern appears in states.c (propagate_precision,
> iter_active_depths_differ, mark_all_scalars_imprecise) and verifier.c
> (check_stack_write_var_off, get_constant_map_key, collect_linked_regs,
> widen_imprecise_scalars). Only some functions, such as
> print_verifier_state(), were changed to fetch once.
>
This is less serious, but will fix.
> Should nfp_bpf_map_update_value_ok() be converted to bpf_stack_slot(), and
> reg_to_target() given a note or helper for its address-range check?
> Otherwise the changelog could be narrowed to match what the patch actually
> does.
>
>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/35909853278
next prev parent reply other threads:[~2026-09-23 20:04 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 19:11 [PATCH bpf-next v1 00/18] Raise BPF program stack size to 2KiB Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 01/18] bpf: Add accessors for verifier stack slots Kumar Kartikeya Dwivedi
2026-09-23 19:57 ` bot+bpf-ci
2026-09-23 20:04 ` Kumar Kartikeya Dwivedi [this message]
2026-09-23 19:11 ` [PATCH bpf-next v1 02/18] bpf: Widen the stack slot index in the jump history Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 03/18] bpf: Store linked registers in the jump history as an array Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 04/18] bpf: Track backtracking stack slots with bitmaps Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 05/18] bpf: Track scratched stack slots with a bitmap Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 06/18] bpf: Treat unknown-size stack reads as reaching the frame top Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 07/18] bpf: Size liveness stack masks by the stack each frame uses Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 08/18] bpf: Grow the verifier id scratch on demand Kumar Kartikeya Dwivedi
2026-09-23 19:24 ` sashiko-bot
2026-09-23 19:29 ` Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 09/18] selftests/bpf: Cover the tail call caller stack depth limit Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 10/18] selftests/bpf: Check that narrow stack stores define no slot Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 11/18] selftests/bpf: Check liveness merge of masks with different widths Kumar Kartikeya Dwivedi
2026-09-23 19:26 ` sashiko-bot
2026-09-23 19:29 ` Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 12/18] bpf: Size the per-frame verifier structures for a 2 KiB stack Kumar Kartikeya Dwivedi
2026-09-23 20:12 ` bot+bpf-ci
2026-09-23 20:27 ` Kumar Kartikeya Dwivedi
2026-09-23 22:55 ` Alexei Starovoitov
2026-09-23 19:11 ` [PATCH bpf-next v1 13/18] bpf: Bound program stack use by a per-program limit Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 14/18] selftests/bpf: Add load conditions on the program stack limit Kumar Kartikeya Dwivedi
2026-09-23 20:12 ` bot+bpf-ci
2026-09-23 20:27 ` Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 15/18] selftests/bpf: Give the 512-byte stack boundary tests a 2 KiB twin Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 16/18] bpf, x86: Allow programs 2 KiB of stack Kumar Kartikeya Dwivedi
2026-09-23 20:12 ` bot+bpf-ci
2026-09-23 20:28 ` Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 17/18] bpf, arm64: " Kumar Kartikeya Dwivedi
2026-09-23 19:11 ` [PATCH bpf-next v1 18/18] selftests/bpf: Test the 2 KiB stack budget Kumar Kartikeya Dwivedi
2026-09-23 20:12 ` bot+bpf-ci
2026-09-23 20:28 ` Kumar Kartikeya Dwivedi
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=DLMYRPN1E0EQ.1XSYMJIAKSM85@gmail.com \
--to=memxor@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@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=kernel-team@meta.com \
--cc=kkd@meta.com \
--cc=martin.lau@kernel.org \
--cc=mason@kernel.org \
--cc=tj@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.