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 4464631961F for ; Fri, 19 Sep 2025 15:29:39 +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=1758295779; cv=none; b=We6eGa1VGdLSehETtrTNvDNKQfeMPyNM2ERagWvPxnDGs+KxtBgJNGlcz+gs1sI9HgETwsnlNkq4w1DtSzANECb07Vobzv515xWnRWM+6fXJds2eJ4NIHynY8lr+4aP7u8jZNUw0ecCOUTsrOWZuewKSWW5ShCy5P3C6hgxK9tg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758295779; c=relaxed/simple; bh=rkT79x93fB0lB+cjq9kCwH7uSxNnEy8wxR0ZIb1caEc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fYnEGnzs85Vj8j+ky+O3xmz3vY/aCJLK9lVsyS2VGcXiWPlrKocFz1TNvrwCU0zYrB5En6CyJcvSH5Q9qrq0jSrkp3PfiQnQEE6e0GJ5cKwsvTdQIgShbdptq60cvAr4BD2inuxPRPl2zCUjDvndBFyzrZlE5EIJ7z0N24duces= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=y13YNkXz; 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="y13YNkXz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A523FC4CEF0; Fri, 19 Sep 2025 15:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1758295779; bh=rkT79x93fB0lB+cjq9kCwH7uSxNnEy8wxR0ZIb1caEc=; h=From:To:Cc:Subject:Date:Reply-to:From; b=y13YNkXzu+sN5jVGHHx5O03YYx0RoIzksg6F3jYlMqtgvKWngCGc4DxPjbM6R4r25 PdOyaJWoH7qTw4aMbJ2B0+nNg6yAzw/fNbtX2CGSaZIUUjxVidA4dtIBUJdN6L4aFl Uh2bJpsimITZlomV5WHa7t4GA9J3tPQoXTElLQXk= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-39844: mm: move page table sync declarations to linux/pgtable.h Date: Fri, 19 Sep 2025 17:28:08 +0200 Message-ID: <2025091903-CVE-2025-39844-7583@gregkh> X-Mailer: git-send-email 2.51.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=7032; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=o4p8X+mHbViYzVZFzCUNpLgu1Dh44BSIH75Dg0F6JQU=; b=owGbwMvMwCRo6H6F97bub03G02pJDBlny5p1jdQFNY74CS+rSDjHtl2Mz2f9rlnHO7xr8+/KT g7LfZLSEcvCIMjEICumyPJlG8/R/RWHFL0MbU/DzGFlAhnCwMUpABOprmOYX5Ype1rq5+FlFusS je5O8RBkS7wbzDCHt+/XpRaNrcfWH7wfysXf9kV+m9daAA== 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: mm: move page table sync declarations to linux/pgtable.h During our internal testing, we started observing intermittent boot failures when the machine uses 4-level paging and has a large amount of persistent memory: BUG: unable to handle page fault for address: ffffe70000000034 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 0 P4D 0 Oops: 0002 [#1] SMP NOPTI RIP: 0010:__init_single_page+0x9/0x6d Call Trace: __init_zone_device_page+0x17/0x5d memmap_init_zone_device+0x154/0x1bb pagemap_range+0x2e0/0x40f memremap_pages+0x10b/0x2f0 devm_memremap_pages+0x1e/0x60 dev_dax_probe+0xce/0x2ec [device_dax] dax_bus_probe+0x6d/0xc9 [... snip ...] It turns out that the kernel panics while initializing vmemmap (struct page array) when the vmemmap region spans two PGD entries, because the new PGD entry is only installed in init_mm.pgd, but not in the page tables of other tasks. And looking at __populate_section_memmap(): if (vmemmap_can_optimize(altmap, pgmap)) // does not sync top level page tables r = vmemmap_populate_compound_pages(pfn, start, end, nid, pgmap); else // sync top level page tables in x86 r = vmemmap_populate(start, end, nid, altmap); In the normal path, vmemmap_populate() in arch/x86/mm/init_64.c synchronizes the top level page table (See commit 9b861528a801 ("x86-64, mem: Update all PGDs for direct mapping and vmemmap mapping changes")) so that all tasks in the system can see the new vmemmap area. However, when vmemmap_can_optimize() returns true, the optimized path skips synchronization of top-level page tables. This is because vmemmap_populate_compound_pages() is implemented in core MM code, which does not handle synchronization of the top-level page tables. Instead, the core MM has historically relied on each architecture to perform this synchronization manually. We're not the first party to encounter a crash caused by not-sync'd top level page tables: earlier this year, Gwan-gyeong Mun attempted to address the issue [1] [2] after hitting a kernel panic when x86 code accessed the vmemmap area before the corresponding top-level entries were synced. At that time, the issue was believed to be triggered only when struct page was enlarged for debugging purposes, and the patch did not get further updates. It turns out that current approach of relying on each arch to handle the page table sync manually is fragile because 1) it's easy to forget to sync the top level page table, and 2) it's also easy to overlook that the kernel should not access the vmemmap and direct mapping areas before the sync. # The solution: Make page table sync more code robust and harder to miss To address this, Dave Hansen suggested [3] [4] introducing {pgd,p4d}_populate_kernel() for updating kernel portion of the page tables and allow each architecture to explicitly perform synchronization when installing top-level entries. With this approach, we no longer need to worry about missing the sync step, reducing the risk of future regressions. The new interface reuses existing ARCH_PAGE_TABLE_SYNC_MASK, PGTBL_P*D_MODIFIED and arch_sync_kernel_mappings() facility used by vmalloc and ioremap to synchronize page tables. pgd_populate_kernel() looks like this: static inline void pgd_populate_kernel(unsigned long addr, pgd_t *pgd, p4d_t *p4d) { pgd_populate(&init_mm, pgd, p4d); if (ARCH_PAGE_TABLE_SYNC_MASK & PGTBL_PGD_MODIFIED) arch_sync_kernel_mappings(addr, addr); } It is worth noting that vmalloc() and apply_to_range() carefully synchronizes page tables by calling p*d_alloc_track() and arch_sync_kernel_mappings(), and thus they are not affected by this patch series. This series was hugely inspired by Dave Hansen's suggestion and hence added Suggested-by: Dave Hansen. Cc stable because lack of this series opens the door to intermittent boot failures. This patch (of 3): Move ARCH_PAGE_TABLE_SYNC_MASK and arch_sync_kernel_mappings() to linux/pgtable.h so that they can be used outside of vmalloc and ioremap. The Linux kernel CVE team has assigned CVE-2025-39844 to this issue. Affected and fixed versions =========================== Issue introduced in 5.13 with commit 8d400913c231bd1da74067255816453f96cd35b0 and fixed in 5.15.192 with commit 732e62212f49d549c91071b4da7942ee3058f7a2 Issue introduced in 5.13 with commit 8d400913c231bd1da74067255816453f96cd35b0 and fixed in 6.1.151 with commit eceb44e1f94bd641b2a4e8c09b64c797c4eabc15 Issue introduced in 5.13 with commit 8d400913c231bd1da74067255816453f96cd35b0 and fixed in 6.6.105 with commit 6797a8b3f71b2cb558b8771a03450dc3e004e453 Issue introduced in 5.13 with commit 8d400913c231bd1da74067255816453f96cd35b0 and fixed in 6.12.46 with commit 4f7537772011fad832f83d6848f8eab282545bef Issue introduced in 5.13 with commit 8d400913c231bd1da74067255816453f96cd35b0 and fixed in 6.16.6 with commit 469f9d22751472b81eaaf8a27fcdb5a70741c342 Issue introduced in 5.13 with commit 8d400913c231bd1da74067255816453f96cd35b0 and fixed in 6.17-rc5 with commit 7cc183f2e67d19b03ee5c13a6664b8c6cc37ff9d 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-39844 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: include/linux/pgtable.h include/linux/vmalloc.h 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/732e62212f49d549c91071b4da7942ee3058f7a2 https://git.kernel.org/stable/c/eceb44e1f94bd641b2a4e8c09b64c797c4eabc15 https://git.kernel.org/stable/c/6797a8b3f71b2cb558b8771a03450dc3e004e453 https://git.kernel.org/stable/c/4f7537772011fad832f83d6848f8eab282545bef https://git.kernel.org/stable/c/469f9d22751472b81eaaf8a27fcdb5a70741c342 https://git.kernel.org/stable/c/7cc183f2e67d19b03ee5c13a6664b8c6cc37ff9d