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=1796551925; b=RwOeix6AtHJGJNYXt5SWth4bgF/iWZUzk4nNJ3ihWGtCpjCFhIGmEUscsgsrggxAmORD X5uuuoppomTJsamtvcYZSyCWDtsmAaSNHzdYMIVRNTQ5SPY0eWusVtMe8u8y9RFYtjZTH OiEKsAE55ZFPg0oxhLh7xgdZ3jzc6eCKMqDIoRr0CIuettgTCc+4bCxMOirRv4seO4fBc 2FkbxceKo6922aGBnRPNqX4iHBSv6+B/Kds14OgqCtlHj4SG1ChBK3VWfmLsnPflHLlyh 4ywC3oZHRKcZCDAYcuqknwdMPVlYqZ79zNEPbwf+oga9GmCkiG39sCBffVlCAk4IddQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796551925; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=oPvermkbbwHEVXM6Kp9UnBwBxbApvIe3HldNGTdG7tA=; b=yzmcJ5Nf8JV7VBZ+Nt71DIY7osIRPi1qKOsP9RyfCN7BKtB2dHtxwrM5XdP0u0VWvpIl yD2Gq9JjMqPeaLh2EP4QmtuiSKGU4xjlGjdg1kA8zxd2RmVUgod5pFnGY+dTipY8jle+G oLOVjFwgafMj0jrYNlIU4r4kHLDVJxVSc7mtxQwTroIMyjqEepEIwbcnU2wP/tEJoBpwj 8eEv5ZrVqDSDvmDipP6n4MT0ljG+1CNmrYpjLgRiKuMFSGn2gQGb7XqgyqnQuK7LfE+KK m6lJxbaep8TEVdAK5Lcz9+FCJvbArCJbgUlbOXpcc1fpwXMJrtvecSxHtFpZISpwMhA== 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=iyxqfT1X; 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 DFD37606A31F for ; Sun, 6 Dec 2026 10:12:04 +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=iyxqfT1X Received: by smtp.kernel.org (Postfix) with ESMTPSA id 623751F00A07; Sun, 6 Dec 2026 10:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796551924; bh=oPvermkbbwHEVXM6Kp9UnBwBxbApvIe3HldNGTdG7tA=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=iyxqfT1Xsl16DEhlicvJKCLTyk4CsxFN6HudYo9ZSmBvjyIgBjz+nBiaE7P1jtSWM prBDcGK1qMT9XzS2Ty5kbP5jcb5z8/48jjzq36yPG/JBdtb2sbe+QdsXB0mVBDFG50 T5jcFH9vJuNy7LOCgavDbkuASVGQ4795EHclV0/6LbDKWdPWiKgQIGVxT14Us3R7TU Kk2sFIXXY/hGfU1hW4zMegv6xQNxHOhIpBsuRiUDCZ+X2jeGroUAmaIoGF+vPPAppr JDRXEY3BEV30/WqOpsV45d2/xpqSqCPN2iFZsZEmVgrGoySNoaLoXXXH63wgSNGvvL ijl2XrdwqZrHQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH bpf-next 5/6] bpf, arm64: Defer trampoline creation instruction sync Reply-To: sashiko-reviews@lists.linux.dev To: "Xu Kuohai" , bpf@vger.kernel.org In-Reply-To: <5bcb02d50e4690d53db0e108e03d892ac0c2cf89.1796545068.git.xukuohai@huawei.com> References: <5bcb02d50e4690d53db0e108e03d892ac0c2cf89.1796545068.git.xukuohai@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 06 Dec 2026 10:12:03 +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, arm64: bpf_arch_text_synchronize() misses local isb() on CPU migration -- commit 3e973e1a645e674c6e02bd2b7e8f11e0c65b2a35 Author: Xu Kuohai bpf, arm64: Defer trampoline creation instruction sync This commit switches arch_prepare_bpf_trampoline() to use bpf_arch_text_copy_nosync() so instruction synchronization is deferred to generic code, and returns immediately when prepare_trampoline() fails. > diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c > index 76d25947ace65..7b5519f1159cc 100644 > --- a/arch/arm64/net/bpf_jit_comp.c > +++ b/arch/arm64/net/bpf_jit_comp.c > @@ -4002,6 +4002,8 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_im= age *im, void *ro_image, [ ... ] > if (ret > 0) > ret *=3D AARCH64_INSN_SIZE; > =20 > - tmp =3D bpf_arch_text_copy(ro_image, image, size); > + tmp =3D bpf_arch_text_copy_nosync(ro_image, image, size); [Severity: Medium] Can task migration between bpf_arch_text_copy_nosync() and bpf_arch_text_synchronize() leave the destination CPU without a context synchronization event before it executes the new trampoline? aarch64_insn_copy_nosync() runs caches_clean_inval_pou(), which emits isb only on the local CPU. Because preemption is enabled and callers sleep before bpf_arch_text_synchronize() (e.g. kvfree() here, or the allocations in __bpf_struct_ops_map_update_elem()), the task can migrate: CPU0 CPU1 (speculatively prefetches recycled bpf_prog_pack ROX slot) arch_prepare_bpf_trampoline() bpf_arch_text_copy_nosync() caches_clean_inval_pou() isb (CPU0 only) kvfree(image) ... (task migrates) ----------> __switch_to() (dsb, no isb) bpf_arch_text_synchronize() kick_all_cpus_sync() (skips CPU1) dummy_ops_call_op() <-- stale insns On arm64, __switch_to() emits dsb(ish) without guaranteeing an isb, and bpf_arch_text_synchronize() only calls kick_all_cpus_sync(). That calls smp_call_function(), which skips the calling CPU and does not guarantee a local isb on the sender (e.g. on GICv2, or when no remote IPI is sent). If CPU1 then executes the new trampoline (such as dummy_ops_call_op() right after bpf_arch_text_synchronize() in bpf_struct_ops_test_run()), it can execute stale prefetched instructions from the recycled bpf_prog_pack slot, trapping on AARCH64_BREAK_FAULT or running old code. Disabling preemption around kick_all_cpus_sync() and issuing a local isb() in bpf_arch_text_synchronize() would ensure the calling CPU is synchronized as well. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796545068.gi= t.xukuohai@huawei.com?part=3D5