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 B360A34545 for ; Fri, 25 Jul 2025 13:20:29 +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=1753449629; cv=none; b=DK6cC0ENdD46wSMfqDSW3mU5SmRkbwJaLm2ZCN9ZuVh5R/qeMgR9Gztn9105HiAldcCZueh1oNm8c73w70tRaRu1O6xwwxxva6XNvrTjB5kYcn646/S2mh9j1rmIpHytZDVW3wH5THTUm1CHVaicLtFBI17PQ/SOJnqwzu9U9FU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753449629; c=relaxed/simple; bh=4ZoQs/y19qp7Qa4uvI1FjdstXQGWdUT8VeOxjy3vMkk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=l8cqxuX05sGxvnkTONFURxLUVgIPqTxvIe0iC9VCasiJ9TH+Tqo62/WeIs8VCWRA1nlYDsrddLrzz2eJhrIlHLo8GfArqL4yrM+1wZGL5Kvz1on46DUlxEchoc6TEcANBpxSXZ6luFhK9eceHm2/mjQ6QZG1pQm4dPkqNG4nlf8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=f9JuhMt1; 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="f9JuhMt1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA562C4CEE7; Fri, 25 Jul 2025 13:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1753449629; bh=4ZoQs/y19qp7Qa4uvI1FjdstXQGWdUT8VeOxjy3vMkk=; h=From:To:Cc:Subject:Date:Reply-to:From; b=f9JuhMt1CU2Rt/oCK3X5kL/Q0PhgreyKmUfJI6j0ruBy7BWhz3HGGKc8YqK+Yjy2p kEOXRewgPU0bv0mOYRt/U9+bcWByz4EXYZKwuqUnGW9a5OjzbnpnghevZXXlgDHV0J StXxZj+j11hZaqVyG7xxorWF1r6YidrH+LG420mo= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-38407: riscv: cpu_ops_sbi: Use static array for boot_data Date: Fri, 25 Jul 2025 15:20:21 +0200 Message-ID: <2025072520-CVE-2025-38407-98b5@gregkh> X-Mailer: git-send-email 2.50.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=5784; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=YdUu5h2hSq0H22tp2p93t0jixXmO3mQNl+oHJIX0950=; b=owGbwMvMwCRo6H6F97bub03G02pJDBnNLVO2h+kuWfxpnSD7Bp99qUe/bqgyfsem8G2GUYPsr 87dCVkxHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjAR3gcM86yWMCX9q5G2PWDJ 9oPl/ps8r/ppLQyzmBqFZ2Z+6HvmzbFE5mNm2kwFWfftAA== 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: cpu_ops_sbi: Use static array for boot_data Since commit 6b9f29b81b15 ("riscv: Enable pcpu page first chunk allocator"), if NUMA is enabled, the page percpu allocator may be used on very sparse configurations, or when requested on boot with percpu_alloc=page. In that case, percpu data gets put in the vmalloc area. However, sbi_hsm_hart_start() needs the physical address of a sbi_hart_boot_data, and simply assumes that __pa() would work. This causes the just started hart to immediately access an invalid address and hang. Fortunately, struct sbi_hart_boot_data is not too large, so we can simply allocate an array for boot_data statically, putting it in the kernel image. This fixes NUMA=y SMP boot on Sophgo SG2042. To reproduce on QEMU: Set CONFIG_NUMA=y and CONFIG_DEBUG_VIRTUAL=y, then run with: qemu-system-riscv64 -M virt -smp 2 -nographic \ -kernel arch/riscv/boot/Image \ -append "percpu_alloc=page" Kernel output: [ 0.000000] Booting Linux on hartid 0 [ 0.000000] Linux version 6.16.0-rc1 (dram@sakuya) (riscv64-unknown-linux-gnu-gcc (GCC) 14.2.1 20250322, GNU ld (GNU Binutils) 2.44) #11 SMP Tue Jun 24 14:56:22 CST 2025 ... [ 0.000000] percpu: 28 4K pages/cpu s85784 r8192 d20712 ... [ 0.083192] smp: Bringing up secondary CPUs ... [ 0.086722] ------------[ cut here ]------------ [ 0.086849] virt_to_phys used for non-linear address: (____ptrval____) (0xff2000000001d080) [ 0.088001] WARNING: CPU: 0 PID: 1 at arch/riscv/mm/physaddr.c:14 __virt_to_phys+0xae/0xe8 [ 0.088376] Modules linked in: [ 0.088656] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.16.0-rc1 #11 NONE [ 0.088833] Hardware name: riscv-virtio,qemu (DT) [ 0.088948] epc : __virt_to_phys+0xae/0xe8 [ 0.089001] ra : __virt_to_phys+0xae/0xe8 [ 0.089037] epc : ffffffff80021eaa ra : ffffffff80021eaa sp : ff2000000004bbc0 [ 0.089057] gp : ffffffff817f49c0 tp : ff60000001d60000 t0 : 5f6f745f74726976 [ 0.089076] t1 : 0000000000000076 t2 : 705f6f745f747269 s0 : ff2000000004bbe0 [ 0.089095] s1 : ff2000000001d080 a0 : 0000000000000000 a1 : 0000000000000000 [ 0.089113] a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000000 [ 0.089131] a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000 [ 0.089155] s2 : ffffffff8130dc00 s3 : 0000000000000001 s4 : 0000000000000001 [ 0.089174] s5 : ffffffff8185eff8 s6 : ff2000007f1eb000 s7 : ffffffff8002a2ec [ 0.089193] s8 : 0000000000000001 s9 : 0000000000000001 s10: 0000000000000000 [ 0.089211] s11: 0000000000000000 t3 : ffffffff8180a9f7 t4 : ffffffff8180a9f7 [ 0.089960] t5 : ffffffff8180a9f8 t6 : ff2000000004b9d8 [ 0.089984] status: 0000000200000120 badaddr: ffffffff80021eaa cause: 0000000000000003 [ 0.090101] [] __virt_to_phys+0xae/0xe8 [ 0.090228] [] sbi_cpu_start+0x6e/0xe8 [ 0.090247] [] __cpu_up+0x1e/0x8c [ 0.090260] [] bringup_cpu+0x42/0x258 [ 0.090277] [] cpuhp_invoke_callback+0xe0/0x40c [ 0.090292] [] __cpuhp_invoke_callback_range+0x68/0xfc [ 0.090320] [] _cpu_up+0x11a/0x244 [ 0.090334] [] cpu_up+0x52/0x90 [ 0.090384] [] bringup_nonboot_cpus+0x78/0x118 [ 0.090411] [] smp_init+0x34/0xb8 [ 0.090425] [] kernel_init_freeable+0x148/0x2e4 [ 0.090442] [] kernel_init+0x1e/0x14c [ 0.090455] [] ret_from_fork_kernel+0xe/0xf0 [ 0.090471] [] ret_from_fork_kernel_asm+0x16/0x18 [ 0.090560] ---[ end trace 0000000000000000 ]--- [ 1.179875] CPU1: failed to come online [ 1.190324] smp: Brought up 1 node, 1 CPU The Linux kernel CVE team has assigned CVE-2025-38407 to this issue. Affected and fixed versions =========================== Issue introduced in 6.8 with commit 6b9f29b81b155af023da95f560f738f29722b306 and fixed in 6.12.37 with commit f5fe094f35a37adea40b2fd52c99bb1333be9b07 Issue introduced in 6.8 with commit 6b9f29b81b155af023da95f560f738f29722b306 and fixed in 6.15.6 with commit 02c725cd55eb5052b88eeaa3f60a391ef4dcaec5 Issue introduced in 6.8 with commit 6b9f29b81b155af023da95f560f738f29722b306 and fixed in 6.16-rc5 with commit 2b29be967ae456fc09c320d91d52278cf721be1e 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-38407 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/kernel/cpu_ops_sbi.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/f5fe094f35a37adea40b2fd52c99bb1333be9b07 https://git.kernel.org/stable/c/02c725cd55eb5052b88eeaa3f60a391ef4dcaec5 https://git.kernel.org/stable/c/2b29be967ae456fc09c320d91d52278cf721be1e