Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 019EA285C8D for ; Tue, 28 Oct 2025 11:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761652441; cv=none; b=SxAM+Cq2pjrVZecdLgFmv94u6rVI/AVeyex5qWudqu5nbH0wmiJGdnm+vvboT6YQWFr2GshPx1FK7M+ejLz0rZCUaNhj/u3hzHP8nklVvk11fqR4P+djrbkdOfK2vtABM2UUsAyPPBLcv4drKB5DtjFnbz6rHDkWgPrMhEWpRfs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761652441; c=relaxed/simple; bh=yWnTHv98LsXUxLoBZUZ8XFliwPbMeEmJ9kcSMBpaZLM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=c5IioCz3iFpIztvWSGExdWn0TusfQoS9bFriOo1mXvQZton7kojTamwnFhLnd4k6JeyTG8cq5bRU1mEYFlPCPN2gzngOArRY5O+pEL2JaYGkuUe7Sav7c6rpzdkTkRZRV09EoO/XOs5JrFAyWb1bLTK8lief20eYd+Ah4v8OG68= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QVPtqfwu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="QVPtqfwu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D4EBC4CEE7; Tue, 28 Oct 2025 11:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761652440; bh=yWnTHv98LsXUxLoBZUZ8XFliwPbMeEmJ9kcSMBpaZLM=; h=From:To:Cc:Subject:Date:Reply-to:From; b=QVPtqfwuhFecZ2EEcjUPsnCzPvM1db0qN6zLFQy+g0b/0qHgyMgxg8r0M5ECKFjZ1 NKWAF53NTti3te3txrqMgxjJPysGC0/j/HhjutL2l3IUohfOqPf94NMJN05V+t3lNl Z3K3U14TKL7HchOnSB0vmWxbEbza2QwA1OWqzi54= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-40079: riscv, bpf: Sign extend struct ops return values properly Date: Tue, 28 Oct 2025 12:48:56 +0100 Message-ID: <2025102820-CVE-2025-40079-6b2a@gregkh> X-Mailer: git-send-email 2.51.1 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=5139; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=oodYSsnH2Fj2WI9n6463zzv8Ih//j+pGYjOq9Pyy5ac=; b=owGbwMvMwCRo6H6F97bub03G02pJDJkMa1vSeNZMP7J5huQCgWfc6768lptn2saQGzk7v/T+r o8OdrWsHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRRi2G+UXzvz6cb3oluDDi ssa3Dbo+6gdyhBgWXNe+ubCn2WlpYfxWhhkMNu1p25PmAgA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: riscv, bpf: Sign extend struct ops return values properly The ns_bpf_qdisc selftest triggers a kernel panic: Unable to handle kernel paging request at virtual address ffffffffa38dbf58 Current test_progs pgtable: 4K pagesize, 57-bit VAs, pgdp=0x00000001109cc000 [ffffffffa38dbf58] pgd=000000011fffd801, p4d=000000011fffd401, pud=000000011fffd001, pmd=0000000000000000 Oops [#1] Modules linked in: bpf_testmod(OE) xt_conntrack nls_iso8859_1 [...] [last unloaded: bpf_testmod(OE)] CPU: 1 UID: 0 PID: 23584 Comm: test_progs Tainted: G W OE 6.17.0-rc1-g2465bb83e0b4 #1 NONE Tainted: [W]=WARN, [O]=OOT_MODULE, [E]=UNSIGNED_MODULE Hardware name: Unknown Unknown Product/Unknown Product, BIOS 2024.01+dfsg-1ubuntu5.1 01/01/2024 epc : __qdisc_run+0x82/0x6f0 ra : __qdisc_run+0x6e/0x6f0 epc : ffffffff80bd5c7a ra : ffffffff80bd5c66 sp : ff2000000eecb550 gp : ffffffff82472098 tp : ff60000096895940 t0 : ffffffff8001f180 t1 : ffffffff801e1664 t2 : 0000000000000000 s0 : ff2000000eecb5d0 s1 : ff60000093a6a600 a0 : ffffffffa38dbee8 a1 : 0000000000000001 a2 : ff2000000eecb510 a3 : 0000000000000001 a4 : 0000000000000000 a5 : 0000000000000010 a6 : 0000000000000000 a7 : 0000000000735049 s2 : ffffffffa38dbee8 s3 : 0000000000000040 s4 : ff6000008bcda000 s5 : 0000000000000008 s6 : ff60000093a6a680 s7 : ff60000093a6a6f0 s8 : ff60000093a6a6ac s9 : ff60000093140000 s10: 0000000000000000 s11: ff2000000eecb9d0 t3 : 0000000000000000 t4 : 0000000000ff0000 t5 : 0000000000000000 t6 : ff60000093a6a8b6 status: 0000000200000120 badaddr: ffffffffa38dbf58 cause: 000000000000000d [] __qdisc_run+0x82/0x6f0 [] __dev_queue_xmit+0x4c0/0x1128 [] neigh_resolve_output+0xd0/0x170 [] ip6_finish_output2+0x226/0x6c8 [] ip6_finish_output+0x10c/0x2a0 [] ip6_output+0x5e/0x178 [] ip6_xmit+0x29a/0x608 [] inet6_csk_xmit+0xe6/0x140 [] __tcp_transmit_skb+0x45c/0xaa8 [] tcp_connect+0x9ce/0xd10 [] tcp_v6_connect+0x4ac/0x5e8 [] __inet_stream_connect+0xd8/0x318 [] inet_stream_connect+0x3e/0x68 [] __sys_connect_file+0x50/0x88 [] __sys_connect+0x96/0xc8 [] __riscv_sys_connect+0x20/0x30 [] do_trap_ecall_u+0x256/0x378 [] handle_exception+0x14a/0x156 Code: 892a 0363 1205 489c 8bc1 c7e5 2d03 084a 2703 080a (2783) 0709 ---[ end trace 0000000000000000 ]--- The bpf_fifo_dequeue prog returns a skb which is a pointer. The pointer is treated as a 32bit value and sign extend to 64bit in epilogue. This behavior is right for most bpf prog types but wrong for struct ops which requires RISC-V ABI. So let's sign extend struct ops return values according to the function model and RISC-V ABI([0]). [0]: https://riscv.org/wp-content/uploads/2024/12/riscv-calling.pdf The Linux kernel CVE team has assigned CVE-2025-40079 to this issue. Affected and fixed versions =========================== Issue introduced in 6.6 with commit 25ad10658dc1068a671553ff10e19a812c2a3783 and fixed in 6.12.53 with commit 92751937f12a7d34ad492577a251c94a55e97e72 Issue introduced in 6.6 with commit 25ad10658dc1068a671553ff10e19a812c2a3783 and fixed in 6.17.3 with commit 918a399501e28e0cc36dbd1fcfb4208f8aa1e4d1 Issue introduced in 6.6 with commit 25ad10658dc1068a671553ff10e19a812c2a3783 and fixed in 6.18-rc1 with commit fd2e08128944a7679e753f920e9eda72057e427c Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2025-40079 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: arch/riscv/net/bpf_jit_comp64.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/92751937f12a7d34ad492577a251c94a55e97e72 https://git.kernel.org/stable/c/918a399501e28e0cc36dbd1fcfb4208f8aa1e4d1 https://git.kernel.org/stable/c/fd2e08128944a7679e753f920e9eda72057e427c