From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796104281; b=dzyZw1/S/yADFTTiz2Xwjdhjg1PgSypKZt0u2SpvEOzRjwWr8FzPH/V2S89UqTA83+Ga 1MzEo7/Hec/J+O/S/kIXYVICrJwimjylvRg54tWqFfihGn3MqaT74rCl98UTg5R1itjB/ 6JGK49n82YH9oo3Yam0WATrznL1jTe1Ii/9u1XNMrjG8r7uLzpZPzoCFTwmqmgmzq/cYn 9npZPYtEzQWDfHkcdfsYL7fmywzf/d9InoKHV6m3Wu3ic4C9kjE2RYHJRVfnI+AoQKESx dfZvnKCe9yDvcLPokaud2N2T2YQXK7arjamHqjRclkZQBPuMDYU3OELR01Oe0vN81rw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796104281; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=hIp0vPX1fLgimg42kLPVqOTRJSESP4iU4Neuc8FKoUM=; b=H+JH1noAHYZciJ7TLisx3stx9ow6QoNVegKF98i9FH0NyNL3BH67xsruh83qm8+nGkxa 8RPB8Y9af5B2tcfpEqFZ8sV7+87gcN/15dMdWsIVzvNeh8jZXcpDiCpKPUFw01X0BSS9+ CC4dQPpIYJL/nmCXUwVjqNjQCsfXVxaFRCuZ76iVkT4PuD5hiY5FLhUfhlAY6vbrg/3a1 qa3DEFnFVF/a/2ZFeyBKo0lfyO6RND77yolkiGwQ/qGms9KVMTXSPFZLMLp0K3+gL9KzF uNW7+MkkhVZuAMGqK7XlEPR5jf1nGmd1MeRADcFqrCWb4nhzs7/bRAYjkp4C6G5NRIA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GdjScd73; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26AF7606A31A for ; Tue, 1 Dec 2026 05:51:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GdjScd73 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 964ED1F00893; Tue, 1 Dec 2026 05:51:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796104280; bh=hIp0vPX1fLgimg42kLPVqOTRJSESP4iU4Neuc8FKoUM=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=GdjScd73qj/ZA/sil9tN4H/6S5ClWK7goRgR4lEYftsCVEtANxqjXQJj+GMJOgsOR LMrTF9vDyX9DkKw6AQliYcYEOSjJrOpQk2GlBbqrBFmwoykQPxBoD+hxLyL8vlDapi GpYVLrNsUuARySjpymllG0EZwCaS+TKDSEjk+sktG5M6nFZt3GG9UQDei0he1z1F6V IVfB6kWdSLKj8c2vC0aYFxQrILN+PopAwMa/I2gW+q5N0XiI2CUk53lwpKhOF1uM76 C1fnrZwyzgpo6cWVhPPV7w3XhBQoArv0LsP4tqcdHK9EKjeTUtGh/8KKp781iznHjG nyPalUkhJCjiw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH bpf-next v1 39/73] bpf: Refuse freplace on a function that can unwind Reply-To: sashiko-reviews@lists.linux.dev To: "Kumar Kartikeya Dwivedi" , bpf@vger.kernel.org In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 05:51:20 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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, i= nt i, const struct bpf_pad_ > * The main pass looked at more ways to unwind than the program has in t= he end: a loop that has a > * trip count after all has no may_goto. Find the subprogs that get unwi= nd_exit: those that are > * left at a site. A call is a site if it calls one of them. The main pa= ss asks the same when a > - * global subprog unwinds, see settle_late_unwinds(). > + * global subprog unwinds, see settle_late_unwinds(). The main program l= eaves 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_verifie= r_env *env) > changed =3D false; > for (s =3D 0; s < env->subprog_cnt; s++) { > sub =3D &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 =3D 0; s < env->subprog_cnt; s++, sub++) { unwinds =3D sub->can_unwind; sub->can_unwind =3D initial->subprogs[s].can_unwind; late |=3D unwinds && !initial->subprogs[s].did_unwind && bpf_subprog_is_global(env, s); sub->did_unwind =3D unwinds; } env->pads_late =3D late; } For the main program (s =3D=3D 0), bpf_subprog_is_global(env, 0) is true, w= hile initial->subprogs[0].did_unwind remains false across pass restarts because check_funcs() only propagates did_unwind into initial->subprogs[i] for i >=3D 1. When a global subprog (s >=3D 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 =3D=3D 0 iteration of settle_late_unwin= ds() sets env->pads_late =3D 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 >=3D 3), do_check_all() restarts the pass repeatedly until bpf_check_limits() fails with -E2BIG. Starting the loop in settle_late_unwinds() at s =3D 1 (or excluding s =3D= =3D 0 from the late calculation) would avoid treating subprog 0 as a late-unwindi= ng global subprog. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796099737.gi= t.memxor@gmail.com?part=3D39