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=1796133068; b=jx51RrEc7GS6MYZB5wj8QimG1jD8mn2atCzRCmTkQEYKWIdMGZTQhyhtq8ohxVaI4/Rn M+Hd1WwKBIl7yaHxkiwkYzSQrVI95YsyPlegXsQVhOWolx7Jul/J3lvMRgbUpI7Qx+Bu5 q1huT435EmTlmtnYl6vz7jBSxw7uPpA7jq9HZwbfl+QE2OPo0jlZN2L9jPwNg019HeLoF ZrVyYxmYzkAMdsAvP98tzUVWgwM6pCC43D0OdQZcR4d2MEKw2FRDubIIXQH69mw1wfNmF mmrNZZJOArCmG6TzNCllO2mwbPkTPM6i9dw3YPvfErWCwv14CqHXTYpP/yw+QTi8azA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796133068; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=bS7w0uH1XeFOGfJmkwvIthBmQXpvrVsbHhu3zu55Yj8=; b=0dbc7kVmYnfHT2kYxoWtrS8aaHfj/0ydXG2PpfgcvoCzJA8lOaewtgRGtXgmSJtT8Nju SSqQ7NV/FF9wqTAwrMoGhQO070nVgA/lLk3ifjvSpE3UyluP/rrnrupXU3c3amt+Uw6xp uTIbU4kYVaw0zfP9apXoci1aEI+NZksCJlPKW7EdVGkJDtYFOMAb5EJeelIYSzrCs6OIR 3+pSiLirGtG2kf1d07By3xKbQ/YcU8LeS62aJADoJ7zmoRDHiYhz+QEzMVOntUy3CQCBM cwJ7d/b4cbvzi473IZBCXcWDUvc82ppS4NIb1rveju97vbQ/J3EIVy/gypUYMxFKXvQ== 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=GKRUCCrj; 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 525DE606A31A for ; Tue, 1 Dec 2026 13:51:08 +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=GKRUCCrj Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DEC21F00897; Tue, 1 Dec 2026 13:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796133067; bh=bS7w0uH1XeFOGfJmkwvIthBmQXpvrVsbHhu3zu55Yj8=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=GKRUCCrjA+PYsOS3Hq/dwvpFtzQ0XFf4M5OrdvtfBZUOQXNlZDOPzKJjFYwDbP+1x AVNznd2L5oJHbBiRunddQe0gvIrb6luGsHqA06OUD1c5sEqaVHKZYsXp6EEIwBg/7Z CINnuW5JgytjxfC7eWLQO2hmSs6wP4NvACnb38sCG1tOsiVfYMaoV7Ih+9MDkhZMZb 48d3rPZnZ3hDgDBjl3h+ZbVEliVZC10cXMXmaHw+t6BPyPuOYyy/cfO30Prx0hI8Us zw5dhsrbTIBzAiso9KBxke+q2LuG9mmwEP7ZnYSWuFC9OwejolYdGRtV+rT2e6phnS fDsmjIYjd549g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH bpf-next 1/4] riscv, bpf: Fix forward jump offset calculation during JIT passes Reply-To: sashiko-reviews@lists.linux.dev To: "Pu Lehui" , bpf@vger.kernel.org In-Reply-To: <20261201133404.2227100-2-pulehui@huaweicloud.com> References: <20261201133404.2227100-1-pulehui@huaweicloud.com> <20261201133404.2227100-2-pulehui@huaweicloud.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 13:51:07 +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 no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Critical] riscv, bpf: UHMUL and SHMUL miscompilation in bpf_jit_emit_insn() [1] -- commit de0e129fdf81e58df6e6ff584831841fe64b9d55 Author: Pu Lehui riscv, bpf: Fix forward jump offset calculation during JIT passes This commit preserves the previous pass's instruction offsets in ctx->offset[] during instruction emission and extends ctx->offset[] to prog->len + 1 entries so forward branch and epilogue jump calculations do not mix offsets from different JIT passes. > diff --git a/arch/riscv/net/bpf_jit_comp32.c b/arch/riscv/net/bpf_jit_com= p32.c > index a9e0bd5cc81d2..a32fb59b74e93 100644 > --- a/arch/riscv/net/bpf_jit_comp32.c > +++ b/arch/riscv/net/bpf_jit_comp32.c [ ... ] > @@ -1305,7 +1304,7 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, = struct rv_jit_context *ctx, > if (i =3D=3D ctx->prog->len - 1) > break; > =20 > - rvoff =3D epilogue_offset(ctx); > + rvoff =3D rv_offset(i, ctx->prog->len - 1 - i, ctx); > emit_jump_and_link(RV_REG_ZERO, rvoff, false, ctx); > break; [Severity: Critical] This problem wasn't introduced by this patch, but in bpf_jit_emit_insn(), does the BPF_ALU64 | BPF_MUL handling miscompile [1] 64-bit UHMUL and SHMUL instructions by ignoring insn->off? arch/riscv/net/bpf_jit_comp32.c:bpf_jit_emit_insn() { ... case BPF_ALU64 | BPF_MUL | BPF_X: case BPF_ALU64 | BPF_MUL | BPF_K: case BPF_ALU64 | BPF_LSH | BPF_X: case BPF_ALU64 | BPF_RSH | BPF_X: case BPF_ALU64 | BPF_ARSH | BPF_X: if (BPF_SRC(code) =3D=3D BPF_K) { emit_imm32(tmp2, imm, ctx); src =3D tmp2; } emit_alu_r64(dst, src, ctx, BPF_OP(code)); break; ... } BPF cpuv4 encodes UHMUL and SHMUL as BPF_ALU64 | BPF_MUL with a non-zero insn->off, but bpf_jit_emit_insn() passes only BPF_OP(code) to emit_alu_r64(), which always emits the low 64 bits of the product. The JITed value then diverges from the verifier's register bounds, allowing out-of-bounds memory accesses. [1] https://sashiko.dev/#/bug/linux-1ce6a684-cefb-42c5-b3ec-d9542a7923f7 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201133404.2227= 100-1-pulehui@huaweicloud.com?part=3D1