From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: Amery Hung <ameryhung@gmail.com>,
Emil Tsalapatis <emil@etsalapatis.com>,
Nicholas Carlini <npc@anthropic.com>,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH bpf-next v2 00/11] bpf: Scope callback arguments to their frame
Date: Tue, 20 Oct 2026 11:32:48 -0700 [thread overview]
Message-ID: <d2369629-846e-4fd8-b567-a0fd8863256c@linux.dev> (raw)
In-Reply-To: <DM6EVHTVM3IR.3RCFLKV9WC80J@gmail.com>
On 10/16/26 9:42 AM, Alexei Starovoitov wrote:
> On Fri, Oct 09, 2026 at 01:27 PM Ihor Solodrai <ihor.solodrai@linux.dev> wrote:
>> Introduce REF_TYPE_FRAME for this use case: a reference owned by a
>> callee frame, dropped when the frame is popped. Tie each argument to
>> this reference so callback return invalidates it and its descendants.
>
> Another idea...
> The id is owned by the frame. Can we keep it in bpf_func_state
> like diag_frame_id ?
> release_reference() already takes ids that are not in refs[].
> See unmark_stack_slots_dynptr().
> Clones copy parent_id and slices hang off dynptr's id, so both are
> reached.
Slices are not reached. A slice's parent_id is the dynptr id, and the
walk from frame_id finds that id only while the dynptr is still in a
register or a stack slot. R1 is caller-saved, so the bpf_dynptr_data()
call that creates the slice usually clobbers it.
This can be fixed in your diff with:
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index bc12df55d2e2..57859c3baeeb 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -11470,6 +11470,7 @@ void mark_frame_scoped_arg(struct bpf_verifier_env *env, struct bpf_func_state *
{
if (!callee->frame_id)
callee->frame_id = ++env->id_gen;
+ callee->regs[regno].id = callee->frame_id;
callee->regs[regno].parent_id = callee->frame_id;
}
i.e. the reg is its own parent again.
> All setters have callee already, so no need for patches 1-3,
> REF_TYPE_FRAME, frameno in refs[], the reg that is its own parent, etc.
I don't quite understand the concern with the series as is.
I'm guessing a new weird REF_TYPE in refs[] which is not an actual
acquirable object gives an ick. Or is it the plumbing?
I take it you agree that we need some kind of frame-tied lifetime
tracking, right?
I added some refactoring patches in attempt to avoid growing
bpf_func_state vs v1 (Eduard mentioned we create a lot of these
objects), and that is what you've just suggested.
frame_id approach is fine with me, just want to understand the choices
we are making.
Thanks!
> [...]
prev parent reply other threads:[~2026-10-20 18:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 20:27 Ihor Solodrai
2026-10-09 20:27 ` [PATCH bpf-next v2 01/11] bpf: Set up callee state outside of setup_func_entry() Ihor Solodrai
2026-10-09 20:27 ` [PATCH bpf-next v2 02/11] bpf: Pass the owning verifier state to callback setters Ihor Solodrai
2026-10-09 20:27 ` [PATCH bpf-next v2 03/11] bpf: Append complete reference states Ihor Solodrai
2026-10-09 20:27 ` [PATCH bpf-next v2 04/11] bpf: Separate reference removal from descendant invalidation Ihor Solodrai
2026-10-09 20:27 ` [PATCH bpf-next v2 05/11] bpf: Share map-backed callback register setup Ihor Solodrai
2026-10-09 20:27 ` [PATCH bpf-next v2 06/11] bpf: Rely on callback frame initialization defaults Ihor Solodrai
2026-10-09 20:27 ` [PATCH bpf-next v2 07/11] bpf: Introduce REF_TYPE_FRAME in the verifier Ihor Solodrai
2026-10-09 20:27 ` [PATCH bpf-next v2 08/11] bpf: Scope the bpf_user_ringbuf_drain() dynptr to its callback frame Ihor Solodrai
2026-10-09 20:27 ` [PATCH bpf-next v2 09/11] selftests/bpf: Cover the user ringbuf callback dynptr lifetime Ihor Solodrai
2026-10-09 20:27 ` [PATCH bpf-next v2 10/11] bpf: Scope the bpf_for_each_map_elem() array key to the callback frame Ihor Solodrai
2026-10-09 20:27 ` [PATCH bpf-next v2 11/11] selftests/bpf: Cover callback-frame map key lifetime Ihor Solodrai
2026-10-16 16:42 ` [PATCH bpf-next v2 00/11] bpf: Scope callback arguments to their frame Alexei Starovoitov
2026-10-20 18:32 ` Ihor Solodrai [this message]
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=d2369629-846e-4fd8-b567-a0fd8863256c@linux.dev \
--to=ihor.solodrai@linux.dev \
--cc=alexei.starovoitov@gmail.com \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=memxor@gmail.com \
--cc=npc@anthropic.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®