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 32DA31BF37 for ; Thu, 1 May 2025 14:15:14 +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=1746108914; cv=none; b=jF+s+DEidebL0BdLz/+6/qjBrx0ualK1C/z0W1md8XFJ0JmUDrEiQhXNI1c3Jdie2yvDYl2Uf/mRuhE7yTaGW2F5kL1eBuTHuGLuVQPsGlt54xojYfncZq3pg6Oia14gt5t0lAELsJw3u7/S/xvKOOi3wp7nYr48szYK1Tr4SHE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746108914; c=relaxed/simple; bh=kJqR/+K7fyLtEAqJO+tSv/5CbHjTjetZTXjHScu+PqQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tTfV/xweE29ov5SjJH9bXvK3IMyqU1SEUPxkODZ21aydzcT0nyEjQTuu/l+WeSrHB/PTDYnNvSCiCc1FcHH8WkLOKBhQfY0JcDXBhXLOCWKVvMa0NuoG+N5aFdxrddaBDDws6GzHzPribp6F0L2FMcMc1HdWTbuO8fSFjL7U3lg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fAH35jpo; 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="fAH35jpo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2080C4CEE3; Thu, 1 May 2025 14:15:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1746108914; bh=kJqR/+K7fyLtEAqJO+tSv/5CbHjTjetZTXjHScu+PqQ=; h=From:To:Cc:Subject:Date:Reply-to:From; b=fAH35jpoTggbmGUjutuEiQk1NR3PpkXaLBKlhrJHn5zIWszi+AEk/Ja9iR6aYuLTa 2ahpN6GWILEDarkyppIh9VmkZ4F2UT9/29nJ64i9BgHo8smqC7wBrUR3+E5nQ01fwJ uaL7XERyyc/uW7dBGK5seFQC1Gs3Y81UpGNgHORg= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49851: riscv: fix reserved memory setup Date: Thu, 1 May 2025 16:10:41 +0200 Message-ID: <2025050144-CVE-2022-49851-6309@gregkh> X-Mailer: git-send-email 2.49.0 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=5254; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=AOXhw7sxU1rNopx8uqsVd0+XHGf7rzTSn1TAmYIttTM=; b=owGbwMvMwCRo6H6F97bub03G02pJDBnCDSvWT33hFSE+a+57/415soeahO61cQuv/XLy4MTIs 9+Ds5nlO2JZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiugoMC2Ycbkw/qq24c95j u5lM/xQO7r1Qk8Mwz4wzev+7vQ+FPcIvmyZoPj2TJJFxEwA= 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: fix reserved memory setup Currently, RISC-V sets up reserved memory using the "early" copy of the device tree. As a result, when trying to get a reserved memory region using of_reserved_mem_lookup(), the pointer to reserved memory regions is using the early, pre-virtual-memory address which causes a kernel panic when trying to use the buffer's name: Unable to handle kernel paging request at virtual address 00000000401c31ac Oops [#1] Modules linked in: CPU: 0 PID: 0 Comm: swapper Not tainted 6.0.0-rc1-00001-g0d9d6953d834 #1 Hardware name: Microchip PolarFire-SoC Icicle Kit (DT) epc : string+0x4a/0xea ra : vsnprintf+0x1e4/0x336 epc : ffffffff80335ea0 ra : ffffffff80338936 sp : ffffffff81203be0 gp : ffffffff812e0a98 tp : ffffffff8120de40 t0 : 0000000000000000 t1 : ffffffff81203e28 t2 : 7265736572203a46 s0 : ffffffff81203c20 s1 : ffffffff81203e28 a0 : ffffffff81203d22 a1 : 0000000000000000 a2 : ffffffff81203d08 a3 : 0000000081203d21 a4 : ffffffffffffffff a5 : 00000000401c31ac a6 : ffff0a00ffffff04 a7 : ffffffffffffffff s2 : ffffffff81203d08 s3 : ffffffff81203d00 s4 : 0000000000000008 s5 : ffffffff000000ff s6 : 0000000000ffffff s7 : 00000000ffffff00 s8 : ffffffff80d9821a s9 : ffffffff81203d22 s10: 0000000000000002 s11: ffffffff80d9821c t3 : ffffffff812f3617 t4 : ffffffff812f3617 t5 : ffffffff812f3618 t6 : ffffffff81203d08 status: 0000000200000100 badaddr: 00000000401c31ac cause: 000000000000000d [] vsnprintf+0x1e4/0x336 [] vprintk_store+0xf6/0x344 [] vprintk_emit+0x56/0x192 [] vprintk_default+0x16/0x1e [] vprintk+0x72/0x80 [] _printk+0x36/0x50 [] print_reserved_mem+0x1c/0x24 [] paging_init+0x528/0x5bc [] setup_arch+0xd0/0x592 [] start_kernel+0x82/0x73c early_init_fdt_scan_reserved_mem() takes no arguments as it operates on initial_boot_params, which is populated by early_init_dt_verify(). On RISC-V, early_init_dt_verify() is called twice. Once, directly, in setup_arch() if CONFIG_BUILTIN_DTB is not enabled and once indirectly, very early in the boot process, by parse_dtb() when it calls early_init_dt_scan_nodes(). This first call uses dtb_early_va to set initial_boot_params, which is not usable later in the boot process when early_init_fdt_scan_reserved_mem() is called. On arm64 for example, the corresponding call to early_init_dt_scan_nodes() uses fixmap addresses and doesn't suffer the same fate. Move early_init_fdt_scan_reserved_mem() further along the boot sequence, after the direct call to early_init_dt_verify() in setup_arch() so that the names use the correct virtual memory addresses. The above supposed that CONFIG_BUILTIN_DTB was not set, but should work equally in the case where it is - unflatted_and_copy_device_tree() also updates initial_boot_params. The Linux kernel CVE team has assigned CVE-2022-49851 to this issue. Affected and fixed versions =========================== Issue introduced in 5.4 with commit 922b0375fc93fb1a20c5617e37c389c26bbccb70 and fixed in 5.10.155 with commit 94ab8f88feb75e3b1486102c0c9c550f37d9d137 Issue introduced in 5.4 with commit 922b0375fc93fb1a20c5617e37c389c26bbccb70 and fixed in 5.15.79 with commit 518e49f0590de66555503aabe199ba8d3f2e24ac Issue introduced in 5.4 with commit 922b0375fc93fb1a20c5617e37c389c26bbccb70 and fixed in 6.0.9 with commit 93598deb101540c4f9e7de15099ea8255b965fc2 Issue introduced in 5.4 with commit 922b0375fc93fb1a20c5617e37c389c26bbccb70 and fixed in 6.1 with commit 50e63dd8ed92045eb70a72d7ec725488320fb68b Issue introduced in 5.3.8 with commit f18ed5bee7bb8a0e99e1c7e7d45e0e51d3497248 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-2022-49851 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/setup.c arch/riscv/mm/init.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/94ab8f88feb75e3b1486102c0c9c550f37d9d137 https://git.kernel.org/stable/c/518e49f0590de66555503aabe199ba8d3f2e24ac https://git.kernel.org/stable/c/93598deb101540c4f9e7de15099ea8255b965fc2 https://git.kernel.org/stable/c/50e63dd8ed92045eb70a72d7ec725488320fb68b