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=1796446272; b=noHlfst/lWflYSpzKXJfbfRXm8JkvFMoT0eXWFPrqB117lttJUdeVW0SDjQy+p2wzbmB SQorXjPtrs0xfAyhRBC6hfhWjhtHMApF6T6AoaRbEx+4J1YDx9lpjjT/gUJ75E4Y9sMnA gHlF49SGyvaEa1vgN9oS/HZSWWR8WpupJKHMUCR1dBlDZxhmfU6Y3yNxq6Jg/5AKUze/+ zBjS3gjjQm3Z0SAJDfuDdLcvhMe7cnG8VuLgnAtxn4vpCgJPdsHlDoj50x1n23KUIvLBw bf1wkPNAgg+adiV3aAFduSfZ8OtO7voGHCls6Jq8FI+ctvlgfqeLeqCEr/H0UOHvzJg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796446272; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=MOTlZc8MnT71NukjgPmiOVDH9+K9ay8B2WRVcjLKFVE=; b=PSyOOOBGSycV9kKGl5n3ix8/mimcBHQMzjnVygp7dcAo+7pZpVNJWOOcANdD72lucMM6 vKUzXpCNGA652KUgX+r+geBKR/L/+7VOvHFtZFAvxhFu1/PV8pQmvB3ei2axvBHjgdBNy JErIm6YdxbeNwjtcYjzV55RmA5utbvQgIUe+zDrFag1XYoS6uHfe71nPCPce05+AFw0Pl aiwnM3NpuhxSAs0+XzE/4JWjIzt573iz4liz28neYqxLHYeGLJetLYv2/CnvvydbWlR+v AYW2yecmy/1K3ghDwIkScEmOxGPYRnJs+H76vhnPQKdA6qCHz0sdTxCnnX1/H1fuOWQ== 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="TnTquO/J"; 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 4C9C5606A32D for ; Sat, 5 Dec 2026 04:51:12 +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=TnTquO/J Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB3181F0092B; Sat, 5 Dec 2026 04:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796446271; bh=MOTlZc8MnT71NukjgPmiOVDH9+K9ay8B2WRVcjLKFVE=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=TnTquO/Jh7ooJ5P9baQsnTRrgnVPi3AaYY17hRdCNKm37qCxuY2ENrQZoIlrxjPvj 9p1+HF24qwYFAfUORSF3AZzLQkzLpWWwdGqzEXqofnzISOSfHcNATbslpRhMYYC8zj CHsPBLo+M6RjAtwFuGxcyAEROQXf/g7Cx6Ji3vtYorgTCwQpHJsK34FdDif32pCuhn U6J3Vu/p77Mr4W/LB5Il6bAm1UdmZdsWK/SiGrkn6rEV3YV6nV5svbFcFmoU37sDZZ vwzf0J6kBUn4UjYMVYqN6mITMxQTaoEkaLMHiw8StmRuLkZ9LGIpmezJ6ROlo0sy5q ugWOj1dCR+4dw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH bpf-next 7/7] selftests/bpf: Test may_goto state across calls and clobbers of %r11 Reply-To: sashiko-reviews@lists.linux.dev To: "Alexei Starovoitov" , bpf@vger.kernel.org In-Reply-To: <20261205033801.1046411-8-alexei.starovoitov@gmail.com> References: <20261205033801.1046411-1-alexei.starovoitov@gmail.com> <20261205033801.1046411-8-alexei.starovoitov@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 04:51:11 +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 2 potential issues to consider: - [Medium] selftests/bpf: fetch_fault_in_loop() fails on arm64 CPUs without LSE atomics - [Low] selftests/bpf: nests() 2s bailout lacks iteration guard for 131071 trips -- commit 5645b13a4a71b76c527f8d3a4d37bbf30c734be9 Author: Alexei Starovoitov selftests/bpf: Test may_goto state across calls and clobbers of %r11 This commit adds BPF selftests verifying that timed may_goto loops still cancel across callback helpers, traced functions, instructions that clobber %r11, and nested program invocations, and checks that freplace on such programs is refused. > diff --git a/tools/testing/selftests/bpf/progs/timed_may_goto.c b/tools/t= esting/selftests/bpf/progs/timed_may_goto.c > index 250ea6ca4d9ed..037ddb81d38f5 100644 > --- a/tools/testing/selftests/bpf/progs/timed_may_goto.c > +++ b/tools/testing/selftests/bpf/progs/timed_may_goto.c > @@ -256,6 +256,88 @@ int loop_not_inlined(void *ctx) [ ... ] > +/* The arena has no pages. The access is skipped and fetches 0. */ > +static bool less_faults(struct bpf_rb_node *a, const struct bpf_rb_node = *b) > +{ > + __u64 *p =3D (void *)__PAGE_SIZE, n =3D zero; > + > + asm volatile ("r0 =3D %[arena] ll" :: __imm_addr(arena) : "r0"); > + bpf_addr_space_cast(p, 0, 1); > + while (n < 1 << 24 && can_loop) > + n +=3D 1 + __sync_fetch_and_or(p, 1); > + stuck_ret =3D n > 100 && n < 1 << 24; > + return false; > +} > + > +SEC("tc") > +__description("timed may_goto: fault of a fetching atomic in a loop") > +__success __retval(1) > +int fetch_fault_in_loop(void *ctx) > +{ > + return run_stuck(less_faults) ?: stuck_ret; > +} [Severity: Medium] Will fetch_fault_in_loop() fail to load on arm64 CPUs without LSE atomics? timed_may_goto.c builds for both x86 and arm64, and fetch_fault_in_loop() expects unconditional load success. On arm64 without ARM64_HAS_LSE_ATOMICS, bpf_jit_supports_insn() rejects fetching arena atomics (LL/SC does not support BPF_PROBE_ATOMIC), so atomic_ptr_type_ok() returns -EACCES. Restricting fetch_fault_in_loop() with __arch_x86_64 (matching arena_atomics.c) or skipping when LSE is unavailable would avoid failing the suite on non-LSE arm64 hosts. [ ... ] > diff --git a/tools/testing/selftests/bpf/progs/timed_may_goto_user.c b/to= ols/testing/selftests/bpf/progs/timed_may_goto_user.c > index a1a13c9b8236e..709c3a12ea402 100644 > --- a/tools/testing/selftests/bpf/progs/timed_may_goto_user.c > +++ b/tools/testing/selftests/bpf/progs/timed_may_goto_user.c > @@ -242,25 +242,29 @@ int spin_under_timer(void *ctx) [ ... ] > +/* The prog runs on top of itself on each trip. That doesn't give it mor= e time. */ > +SEC("tcx/egress") > +int nests(struct __sk_buff *skb) > { > - int i, n =3D 10; > + __u64 t0 =3D bpf_ktime_get_ns(); > =20 > - for (i =3D 0; i < TRIES; i++) > - n +=3D replaced_global(zero); > - return n; > + if (nested) { > + nested_cnt =3D counts_to_1000(); > + return 2; > + } > + nested =3D 1; > + while (can_loop) { > + bpf_clone_redirect(skb, 1, 0); > + /* give up, so that the test fails and doesn't lock up */ > + if (bpf_ktime_get_ns() - t0 > 2000 * 1000 * 1000) > + break; > + } > + return 10; > } [Severity: Low] Can the 2-second bailout in nests() fire before may_goto has a chance to unwind? Because the first bpf_may_goto_slowpath() call at trip 65,535 only initializes the start time and reloads 65,534 trips, nests() cannot unwind until trip 131,071. Each outer trip runs bpf_clone_redirect() (skb_clone(), pskb_expand_head(), and tcx egress dispatch) plus counts_to_1000() and two bpf_ktime_get_ns() calls. On debug kernels or slow virtualized guests, the 2-second timeout can expire first and return 10, spuriously failing test_nested(). Guarding the timeout check with an outer iteration count of at least two slowpath rounds (as loop_calls_subprog_with_65534_iterations() in timed_may_goto.c does) would prevent false failures. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205033801.1046= 411-1-alexei.starovoitov@gmail.com?part=3D7