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=1796145895; b=pKkDTR190q9D7dn27j+RR0Z3iJlwGk7hJrLIs/DR7xc0bttH32UaFHNt7RFLx0+H0YM6 zEi7qCpb7hEx2TsHTsT81L+KYLKgmSvXizwy8qxx5Kcxese21O9ZfsCOygH/+hO7LMY+o XXb2W93Nx+C7VWDQeSg9/YsZCNQVQyjJVIwPw1oOpCABQtGhh13Qxrug8vTewwa7KOjfW iY88L9WS8EA24QXK5mTD7dxHst/iKCFmLHoQFLB/j5U4A6l6n5wsE56HJG8tqYsYvBttn nRdOaVpbl83tpzBETKT4yeWgeBWlGO6lIQbbu+T0aGC4tNDuuDUWw/gwKPypkw1XzaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796145895; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=BDS6rOQtWBNAnWXyW9o+tr7wAKsoTy4tLJnyZOrElcA=; b=3LT8dEcf/F5xA2BCTAioC3iGU2CEjHU5V9s+xsUnsHZMK0RxVyHQFeb8TaOEKfiUgIN4 BJmJLtoEWaCjvw8PQ6OLv9hAr54iXJ+b19R+zsASB4fpfAoPtBGY6pXLVVEIN+56LlVnO 1A+9aBd0OgGdf+mTmiW9Ld72jU1x4sKan982NJ2iaTe5YA55FlPKxIUqbibArKZkDKRJ0 zO95jnumuHM3asmWVZ+6uO8G0k/I3HFFjFwjOsnIAt7lhaSkgFyQfN/6Be1DgtUIjelEA iQnlChGLAUNb0PnbE5MNBs6kOg1KwGwqbsjhGzpoQ2IyOwoF8T/CgD64P2HnF5cy79Q== 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=Ahr1ueEe; 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 BE087606A32A for ; Tue, 1 Dec 2026 17:24:55 +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=Ahr1ueEe Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D4D11F0089C; Tue, 1 Dec 2026 17:24:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796145895; bh=BDS6rOQtWBNAnWXyW9o+tr7wAKsoTy4tLJnyZOrElcA=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Ahr1ueEe20+kqS++X1pIqSgh/mLeb8cH2qOwHCIMlJPHN7s7MQwEkOsHcq2rCM/uw 9kuoqgECUvDEjjvumsy3X7sJ45J4sVA44ZwiUgr4/V23ebYuXW0B8dp3/+TCDv6Gi3 iVZXjrHL0fhu3Ciwbw8YRiafonAFxbHIm6IqEuRNbLM1123QyCPhT/N2wjblxeLYLd GOEFRYxmQGNpgjaQuNI4dNV7Io4WQPPocZSHe3SqoLwAscFB7zat7lgmMh4LLxMT8a y+0vmRssI9MQtxUSn2mlBbg1jVoMSQj9ayyKyvgL37BUorXmsp9tpLd6NQ6CNZcGr5 DTXHd0G8Ij+Ug== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 7/7] powerpc32/bpf: don't fold MOV into jump targets Reply-To: sashiko-reviews@lists.linux.dev To: "Lukas Stockner" , bpf@vger.kernel.org In-Reply-To: <20261201165313.413960-8-lukas@lukasstockner.de> References: <20261201165313.413960-1-lukas@lukasstockner.de> <20261201165313.413960-8-lukas@lukasstockner.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 17:24:54 +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: - [High] bpf: jump_target lost across verifier patching in bpf_insn_is_jump_target() - [High] powerpc32/bpf: bpf_insn_is_jump_target() returns false when env is NULL -- commit fa51b274b4205b85901c47e5fab0c0ea5cb7a081 Author: Lukas Stockner powerpc32/bpf: don't fold MOV into jump targets This commit adds bpf_insn_is_jump_target() and uses it in the 32-bit PowerPC BPF JIT to avoid folding a preceding BPF_MOV into an ALU instruction when t= he ALU instruction is a jump target. > diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c > index facb0d6d2e8d8..466c20a7aa5ad 100644 > --- a/kernel/bpf/core.c > +++ b/kernel/bpf/core.c > @@ -1984,6 +1984,15 @@ bool bpf_insn_is_indirect_target(const struct bpf_= verifier_env *env, const struc > return env->insn_aux_data[insn_idx].indirect_target; > } > =20 > +bool bpf_insn_is_jump_target(const struct bpf_verifier_env *env, const s= truct bpf_prog *prog, > + int insn_idx) > +{ > + if (!env) > + return false; [Severity: High] Should bpf_insn_is_jump_target() return true when env is NULL? Classic BPF programs migrated via bpf_migrate_filter() call bpf_prog_select_runtime() with env =3D=3D NULL. Returning false allows bpf_jit_build_body() to still fold a preceding BPF_MOV64_REG(BPF_REG_A, ...) (such as from BPF_MISC | BPF_TXA) into a jump-target ALU instruction on BPF_REG_A, corrupting the accumulator when a branch jumps to that ALU instruction. > + insn_idx +=3D prog->aux->subprog_start; > + return env->insn_aux_data[insn_idx].jump_target; > +} [Severity: High] Can env->insn_aux_data[insn_idx].jump_target be cleared or stale by the time the JIT runs? jump_target is populated during bpf_check_cfg(), before verifier instruction patching. When a jump-target instruction is expanded into a multi-instruct= ion patch, jumps are redirected to slot[p->target], but patch_list_adj_aux() copies the old aux entry to slot[p->self] and only moves indirect_target and nospec to slot[p->target]: kernel/bpf/fixups.c:patch_list_adj_aux() { ... /* jumps to the replaced insn land on p->target, so the barrier goes befor= e it */ if (p->target !=3D p->self) { slot[p->target].indirect_target =3D last->indirect_target; slot[p->target].nospec =3D last->nospec; last->indirect_target =3D last->nospec =3D 0; } } Because bpf_jit_needs_zext() is true on PowerPC, bpf_opt_subreg_zext_lo32_rnd_hi32() expands any zero-extended 32-bit ALU instruction into the ALU instruction at slot[0] (p->target) followed by BPF_ZEXT_REG at slot[1] (p->self). That leaves jump_target cleared on the actual jump target at slot[0], so bpf_insn_is_jump_target() returns false a= nd bpf_jit_build_body() still folds a preceding BPF_MOV into it. Similarly, when a jump-target instruction is deleted (p->len =3D=3D 0, such= as in bpf_opt_remove_nops()), patch_list_remap_aux() drops its jump_target flag instead of propagating it to the next surviving instruction. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201165313.4139= 60-1-lukas@lukasstockner.de?part=3D7