From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v1 39/73] bpf: Refuse freplace on a function that can unwind
Date: Tue, 01 Dec 2026 05:51:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-242639@kernel.org> (raw)
In-Reply-To: <a09358564d03e7a1da849fa23b256545ad6983f7.1796099737.git.memxor@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] bpf: false late unwinds for subprog 0 in
settle_late_unwinds()
--
commit 4a1e048f994fc17a773dbe271079f0b7119352ca
Author: Alexei Starovoitov <ast@kernel.org>
bpf: Refuse freplace on a function that can unwind
This commit marks subprog 0 as able to unwind when it has an unwind or
cancellation site and rejects freplace attachment to functions (including
the main program) that can unwind.
> diff --git a/kernel/bpf/fixups.c b/kernel/bpf/fixups.c
> index 75ad6f567e145..a20830a628e75 100644
> --- a/kernel/bpf/fixups.c
> +++ b/kernel/bpf/fixups.c
> @@ -650,7 +650,8 @@ bool bpf_site_is_used(struct bpf_verifier_env *env, int i, const struct bpf_pad_
> * The main pass looked at more ways to unwind than the program has in the end: a loop that has a
> * trip count after all has no may_goto. Find the subprogs that get unwind_exit: those that are
> * left at a site. A call is a site if it calls one of them. The main pass asks the same when a
> - * global subprog unwinds, see settle_late_unwinds().
> + * global subprog unwinds, see settle_late_unwinds(). The main program leaves with exit: it is
> + * marked for bpf_check_attach_target(), see bpf_insert_sites().
> */
> void bpf_mark_subprogs_that_unwind(struct bpf_verifier_env *env)
> {
> @@ -664,7 +665,7 @@ void bpf_mark_subprogs_that_unwind(struct bpf_verifier_env *env)
> changed = false;
> for (s = 0; s < env->subprog_cnt; s++) {
> sub = &env->subprog_info[s];
> - if (sub->can_unwind || !sub->bail_unwinds)
> + if (sub->can_unwind || (s && !sub->bail_unwinds))
> continue;
[Severity: Medium]
Can setting subprog_info[0].can_unwind here cause settle_late_unwinds() to
falsely keep env->pads_late set?
bpf_mark_subprogs_that_unwind() is also called by settle_late_unwinds() at
the end of check_funcs() whenever env->pads_late was set during the pass:
kernel/bpf/verifier.c:settle_late_unwinds() {
...
bpf_mark_subprogs_that_unwind(env);
for (s = 0; s < env->subprog_cnt; s++, sub++) {
unwinds = sub->can_unwind;
sub->can_unwind = initial->subprogs[s].can_unwind;
late |= unwinds && !initial->subprogs[s].did_unwind &&
bpf_subprog_is_global(env, s);
sub->did_unwind = unwinds;
}
env->pads_late = late;
}
For the main program (s == 0), bpf_subprog_is_global(env, 0) is true, while
initial->subprogs[0].did_unwind remains false across pass restarts because
check_funcs() only propagates did_unwind into initial->subprogs[i] for
i >= 1.
When a global subprog (s >= 1) speculatively triggers unwind_frame() on a
loop whose guard is later dropped by bpf_flow_drop_guards(), and subprog 0
has any kept site of its own, the s == 0 iteration of settle_late_unwinds()
sets env->pads_late = true. In pass 0 this forces an unnecessary pass
restart; if reached on a later pass where bpf_flow_new_pass() no longer
updates loop->guarded (flow->start_cnt >= 3), do_check_all() restarts the
pass repeatedly until bpf_check_limits() fails with -E2BIG.
Starting the loop in settle_late_unwinds() at s = 1 (or excluding s == 0
from the late calculation) would avoid treating subprog 0 as a late-unwinding
global subprog.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796099737.git.memxor@gmail.com?part=39
next prev parent reply other threads:[~2026-12-01 5:51 UTC|newest]
Thread overview: 119+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 4:38 [PATCH bpf-next v1 00/73] Cancellations Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 01/73] bpf: Refuse a program that is too large for bpf_prog->pages Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 02/73] bpf: Require CAP_PERFMON for unwind_exit and unwind_goto Kumar Kartikeya Dwivedi
2026-12-01 5:25 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 03/73] bpf: Reject bpf_percpu_obj_drop() of a type with special fields Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 04/73] bpf: Drop the edge after bpf_throw() from the control flow graph Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 05/73] bpf: Let a helper call its callback with an unwind label Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 06/73] bpf, x86, arm64: Add landings that redo what follows a helper call Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 07/73] bpf: Let a callback unwind out of a helper that has an unwind label Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 08/73] bpf: Let the inlined bpf_loop pass on a callback that unwinds Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 09/73] bpf: Give the helpers that call a callback an unwind label Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 10/73] bpf: Let the comparator of bpf_rbtree_add unwind Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 11/73] bpf: Let a state leave its frame at may_goto without an exit insn Kumar Kartikeya Dwivedi
2026-12-01 5:25 ` sashiko-bot
2026-12-01 4:38 ` [PATCH bpf-next v1 12/73] bpf: Choose what a cancelled program returns by its type Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 13/73] bpf: Emit landing pads that leave RCU sections Kumar Kartikeya Dwivedi
2026-12-01 5:41 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 14/73] bpf: Release locks and irq flags in landing pads Kumar Kartikeya Dwivedi
2026-12-01 5:41 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 15/73] bpf: Add unwind_goto after calls of subprogs Kumar Kartikeya Dwivedi
2026-12-01 5:41 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 16/73] bpf: Let the kernel cancel a program in a global subprog Kumar Kartikeya Dwivedi
2026-12-01 5:41 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 17/73] bpf: Release references in landing pads Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 18/73] bpf: Release iterators and dynptrs " Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 19/73] bpf: Check pointers for NULL " Kumar Kartikeya Dwivedi
2026-12-01 5:41 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 20/73] bpf: Let the kernel cancel a frame that holds references Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 21/73] bpf: Add unwind_goto after helpers with a callback Kumar Kartikeya Dwivedi
2026-12-01 5:41 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 22/73] bpf: Let a may_goto that the verifier adds go to its landing pad only Kumar Kartikeya Dwivedi
2026-12-01 5:41 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 23/73] bpf: Record why a callee is cancelled when its call gets no landing pad Kumar Kartikeya Dwivedi
2026-12-01 5:26 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 24/73] bpf: Record what each call acquires and releases Kumar Kartikeya Dwivedi
2026-12-01 5:31 ` sashiko-bot
2026-12-01 4:38 ` [PATCH bpf-next v1 25/73] bpf: Add hidden stack slots for landing pads Kumar Kartikeya Dwivedi
2026-12-01 5:40 ` sashiko-bot
2026-12-01 5:42 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 26/73] bpf: Use hidden slots for a pointer that has no location at a site Kumar Kartikeya Dwivedi
2026-12-01 5:25 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 27/73] bpf: Restore the sections of the call when a frame is cancelled Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 28/73] bpf: Let hidden slots follow what a subprog does for its caller Kumar Kartikeya Dwivedi
2026-12-01 5:41 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 29/73] bpf: Let a callee hold a reference that its call hands over Kumar Kartikeya Dwivedi
2026-12-01 5:41 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 30/73] bpf: Let a call clear the hidden slot of what its callee releases Kumar Kartikeya Dwivedi
2026-12-01 4:38 ` [PATCH bpf-next v1 31/73] bpf: Give a callee a hidden slot for the reference that it is handed Kumar Kartikeya Dwivedi
2026-12-01 5:26 ` bot+bpf-ci
2026-12-01 4:38 ` [PATCH bpf-next v1 32/73] bpf: Give unwind_goto a 32 bit offset and prepare it for arena accesses Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 33/73] bpf, x86: Go to the landing pad when an access to arena faults Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 34/73] bpf, arm64: " Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 35/73] bpf: Let a register be the location of a lock in a global variable Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 36/73] bpf: Cancel a program at a fault in arena Kumar Kartikeya Dwivedi
2026-12-01 5:52 ` sashiko-bot
2026-12-01 4:39 ` [PATCH bpf-next v1 37/73] bpf: Share one landing pad among accesses to arena where nothing is held Kumar Kartikeya Dwivedi
2026-12-01 5:41 ` bot+bpf-ci
2026-12-01 4:39 ` [PATCH bpf-next v1 38/73] bpf: Keep R0, R6-R9 and the stack live at a call of bpf_throw() Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 39/73] bpf: Refuse freplace on a function that can unwind Kumar Kartikeya Dwivedi
2026-12-01 5:25 ` bot+bpf-ci
2026-12-01 5:51 ` sashiko-bot [this message]
2026-12-01 4:39 ` [PATCH bpf-next v1 40/73] bpf: Let landing pads pass on the value of unwind_exit Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 41/73] bpf: Keep a reference of the caller that a function finds NULL Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 42/73] bpf: Make bpf_throw() cancel the program through landing pads Kumar Kartikeya Dwivedi
2026-12-01 5:41 ` bot+bpf-ci
2026-12-01 4:39 ` [PATCH bpf-next v1 43/73] bpf, x86: Remove the exception boundary Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 44/73] bpf, arm64: " Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 45/73] s390/bpf: " Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 46/73] powerpc64/bpf: " Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 47/73] bpf: Remove the stack walk of bpf_throw() Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 48/73] bpf: Find at a site that a frame holds more than a landing pad releases Kumar Kartikeya Dwivedi
2026-12-01 5:25 ` bot+bpf-ci
2026-12-01 4:39 ` [PATCH bpf-next v1 49/73] bpf: Cancel the program when the time of its own may_goto is up Kumar Kartikeya Dwivedi
2026-12-01 5:42 ` bot+bpf-ci
2026-12-01 6:09 ` sashiko-bot
2026-12-01 4:39 ` [PATCH bpf-next v1 50/73] bpf: Reject a program that has no landing pad for a fault in arena Kumar Kartikeya Dwivedi
2026-12-01 5:26 ` bot+bpf-ci
2026-12-01 4:39 ` [PATCH bpf-next v1 51/73] bpf: Log why a call is a site and which functions cannot be cancelled Kumar Kartikeya Dwivedi
2026-12-01 5:25 ` bot+bpf-ci
2026-12-01 4:39 ` [PATCH bpf-next v1 52/73] bpf: Add cancel_goto and cancel_exit, which only the verifier emits Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 53/73] bpf: Give the unwind label of a helper a second way in Kumar Kartikeya Dwivedi
2026-12-01 5:26 ` bot+bpf-ci
2026-12-01 4:39 ` [PATCH bpf-next v1 54/73] bpf, x86: Put the landing of unwind_goto after the function Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 55/73] bpf, x86: Return to cancel_goto at cancel_exit Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 56/73] bpf, arm64: " Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 57/73] bpf: Use cancel_exit to leave a frame that the kernel cancels Kumar Kartikeya Dwivedi
2026-12-01 5:42 ` bot+bpf-ci
2026-12-01 5:59 ` sashiko-bot
2026-12-01 4:39 ` [PATCH bpf-next v1 58/73] bpf: Check that a helper whose callback may unwind has an unwind label Kumar Kartikeya Dwivedi
2026-12-01 5:26 ` bot+bpf-ci
2026-12-01 5:47 ` sashiko-bot
2026-12-01 4:39 ` [PATCH bpf-next v1 59/73] bpf: Find the landing pads of a program that can only clean up Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 60/73] bpf: Don't let hidden stack words turn on the private stack Kumar Kartikeya Dwivedi
2026-12-01 5:25 ` bot+bpf-ci
2026-12-01 4:39 ` [PATCH bpf-next v1 61/73] bpf: Add a landing pad per site for frames that are cancelled already Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 62/73] bpf: Verify a cleanup pad for a frame that is cancelled Kumar Kartikeya Dwivedi
2026-12-01 5:41 ` bot+bpf-ci
2026-12-01 4:39 ` [PATCH bpf-next v1 63/73] bpf: Reject a program whose cleanup pad a cancellation cannot enter Kumar Kartikeya Dwivedi
2026-12-01 5:25 ` bot+bpf-ci
2026-12-01 4:39 ` [PATCH bpf-next v1 64/73] bpf: Find the code that a cleanup pad can reach Kumar Kartikeya Dwivedi
2026-12-01 5:41 ` bot+bpf-ci
2026-12-01 4:39 ` [PATCH bpf-next v1 65/73] bpf: Emit the stub, the entry and the remainder of a cleanup pad Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 66/73] bpf: Let the entry of a cleanup pad save the pointers of the frame Kumar Kartikeya Dwivedi
2026-12-01 5:42 ` bot+bpf-ci
2026-12-01 4:39 ` [PATCH bpf-next v1 67/73] bpf: Run the cleanup pads of a program when the kernel cancels it Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 68/73] bpf: End the path at a call of a global subprog that never returns Kumar Kartikeya Dwivedi
2026-12-01 5:26 ` bot+bpf-ci
2026-12-01 4:39 ` [PATCH bpf-next v1 69/73] bpf: Tell struct_ops when a program was cancelled Kumar Kartikeya Dwivedi
2026-12-01 5:26 ` bot+bpf-ci
2026-12-01 5:59 ` sashiko-bot
2026-12-01 4:39 ` [PATCH bpf-next v1 70/73] bpf: Tell struct_ops when cancel_exit returns to the kernel Kumar Kartikeya Dwivedi
2026-12-01 4:39 ` [PATCH bpf-next v1 71/73] bpf: Let a struct_ops say what a cancelled program returns Kumar Kartikeya Dwivedi
2026-12-01 5:25 ` bot+bpf-ci
2026-12-01 5:47 ` sashiko-bot
2026-12-01 4:39 ` [PATCH bpf-next v1 72/73] bpf: Give cancelled tcp_congestion_ops programs values that TCP can take Kumar Kartikeya Dwivedi
2026-12-01 5:46 ` sashiko-bot
2026-12-01 4:39 ` [PATCH bpf-next v1 73/73] sched_ext: Treat a cancelled program as a scheduler error Kumar Kartikeya Dwivedi
2026-12-01 5:25 ` bot+bpf-ci
2026-12-01 7:04 ` Tejun Heo
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=sashiko-outbox-242639@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=memxor@gmail.com \
--cc=sashiko-reviews@lists.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.