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 DA1052DC33B for ; Thu, 4 Dec 2025 15:33:27 +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=1764862407; cv=none; b=E3Nq9q77T17FFzH1O2DhcGdQ4aSPx7WqLeBsR2JJ3s5QgxgUjz7Ueukt3I50EpF6a9Ai7hzUv5J5+/oSpNfF6ex1LBPAbkZ3gkNqNwmia1QU2mtqCOyFKhTuB/uHI/AIqnvrhO0PROZ/DhrUdg16MhmP8nZhDwCshnsCKyvjswg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764862407; c=relaxed/simple; bh=8jkfHNQR6LuKt/ZnqG6poyYPlzWI5xZarr51F/DZksU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ecy7ZxS2wHd/SGO3P1x2aWsgldF/sBt4v24PFtBKG42EtrmwEvDIuiYR4K0tq9sA6qnVfEnme+ZiE/375SrEx3eGtkYCpsZsfTkbXHzoBPOWrwOZnVYQ9vGgbrRnymO0g1j1j15aa+uSIDtBdbXPwBoAk3Y5ZqZ9f/CIfDTmo44= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=EwaAWV2r; 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="EwaAWV2r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D91A7C4CEFB; Thu, 4 Dec 2025 15:33:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1764862407; bh=8jkfHNQR6LuKt/ZnqG6poyYPlzWI5xZarr51F/DZksU=; h=From:To:Cc:Subject:Date:Reply-To:From; b=EwaAWV2rvkgo3au9sgs1z2xTSoU6me9FYOEsNcSgONagKEn+aQnKBZjqvc9ISmDRs hhBrp9DjLfcl5dINfmKsNLogb2euMq8NV6MUxa4PNa3ha32NVJZI9J4kVHoip68Dow VP0FXeE8HrKgspC8OKA8XESdBzlYSI1jqobf916U= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-40230: mm: prevent poison consumption when splitting THP Date: Thu, 4 Dec 2025 16:32:05 +0100 Message-ID: <2025120400-CVE-2025-40230-7b9d@gregkh> X-Mailer: git-send-email 2.52.0 Reply-To: , Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4886; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=GkgPkndkFV1fzSY6A8J4ikbTHIfmNJGL6cLOxOE69GE=; b=owGbwMvMwCRo6H6F97bub03G02pJDJmGKwumZNtvqVm2/+iFLSdWc0nOTNunZpsT1vUrpdpL9 d7ivDd/OmJYGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAimRoMM05fmvlSJt/gkIXK mT/CnAcDZv29ybCg5aq7gPEikUMNrDHVtzQUjPlXdS0AAA== 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: prevent poison consumption when splitting THP When performing memory error injection on a THP (Transparent Huge Page) mapped to userspace on an x86 server, the kernel panics with the following trace. The expected behavior is to terminate the affected process instead of panicking the kernel, as the x86 Machine Check code can recover from an in-userspace #MC. mce: [Hardware Error]: CPU 0: Machine Check Exception: f Bank 3: bd80000000070134 mce: [Hardware Error]: RIP 10: {memchr_inv+0x4c/0xf0} mce: [Hardware Error]: TSC afff7bbff88a ADDR 1d301b000 MISC 80 PPIN 1e741e77539027db mce: [Hardware Error]: PROCESSOR 0:d06d0 TIME 1758093249 SOCKET 0 APIC 0 microcode 80000320 mce: [Hardware Error]: Run the above through 'mcelog --ascii' mce: [Hardware Error]: Machine check: Data load in unrecoverable area of kernel Kernel panic - not syncing: Fatal local machine check The root cause of this panic is that handling a memory failure triggered by an in-userspace #MC necessitates splitting the THP. The splitting process employs a mechanism, implemented in try_to_map_unused_to_zeropage(), which reads the pages in the THP to identify zero-filled pages. However, reading the pages in the THP results in a second in-kernel #MC, occurring before the initial memory_failure() completes, ultimately leading to a kernel panic. See the kernel panic call trace on the two #MCs. First Machine Check occurs // [1] memory_failure() // [2] try_to_split_thp_page() split_huge_page() split_huge_page_to_list_to_order() __folio_split() // [3] remap_page() remove_migration_ptes() remove_migration_pte() try_to_map_unused_to_zeropage() // [4] memchr_inv() // [5] Second Machine Check occurs // [6] Kernel panic [1] Triggered by accessing a hardware-poisoned THP in userspace, which is typically recoverable by terminating the affected process. [2] Call folio_set_has_hwpoisoned() before try_to_split_thp_page(). [3] Pass the RMP_USE_SHARED_ZEROPAGE remap flag to remap_page(). [4] Try to map the unused THP to zeropage. [5] Re-access pages in the hw-poisoned THP in the kernel. [6] Triggered in-kernel, leading to a panic kernel. In Step[2], memory_failure() sets the poisoned flag on the page in the THP by TestSetPageHWPoison() before calling try_to_split_thp_page(). As suggested by David Hildenbrand, fix this panic by not accessing to the poisoned page in the THP during zeropage identification, while continuing to scan unaffected pages in the THP for possible zeropage mapping. This prevents a second in-kernel #MC that would cause kernel panic in Step[4]. Thanks to Andrew Zaborowski for his initial work on fixing this issue. The Linux kernel CVE team has assigned CVE-2025-40230 to this issue. Affected and fixed versions =========================== Issue introduced in 6.12 with commit b1f202060afeb7fcb98473929d26fd3d2093b067 and fixed in 6.12.56 with commit 6fc0a7c99e973a50018c8b4be34914a1b5c7b383 Issue introduced in 6.12 with commit b1f202060afeb7fcb98473929d26fd3d2093b067 and fixed in 6.17.6 with commit 92acf4b04f255d2f0f6770bb0d0a208d8ffb2b77 Issue introduced in 6.12 with commit b1f202060afeb7fcb98473929d26fd3d2093b067 and fixed in 6.18 with commit 841a8bfcbad94bb1ba60f59ce34f75259074ae0d 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-40230 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: mm/huge_memory.c mm/migrate.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/6fc0a7c99e973a50018c8b4be34914a1b5c7b383 https://git.kernel.org/stable/c/92acf4b04f255d2f0f6770bb0d0a208d8ffb2b77 https://git.kernel.org/stable/c/841a8bfcbad94bb1ba60f59ce34f75259074ae0d