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 79A1C21ABAE for ; Thu, 8 May 2025 06:41: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=1746686460; cv=none; b=KbIKiF3Q2FGetFjqmft3fpCqPLKFtRT31LqedKZM4hFMv1XhLmZvTACw+jwADDDO6nTC6aE0P6KGsrnKAv3A3rQfFuyp1gRxNLreDB8JfejVwM6axdogs30FFXmjfeCtr8UVTa05XjxHZThH21MMrx4aAor+AnHjQTyEcy3hpFQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746686460; c=relaxed/simple; bh=t/l+lffFyvrxQjAoxXKrCqWWZ5tee7nsHCADXYYNVQA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tePQvcDkITiLhiFdrdvjq5xFZ7jcG9yFSBXMvJDoTnX07LqIzg/eRJQJq0Z35dIRbbZnxSiMih/a4l3XjTxH7zOGUi40cnNapLjw4+T8Mz1yBdLrxUeEZpkzbXEp36VlTNfSCF3NKlLfORZaK25tlXxmbsHm77u3kFgUVyRecQw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lwU+NDy+; 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="lwU+NDy+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A731C4CEED; Thu, 8 May 2025 06:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1746686460; bh=t/l+lffFyvrxQjAoxXKrCqWWZ5tee7nsHCADXYYNVQA=; h=From:To:Cc:Subject:Date:Reply-to:From; b=lwU+NDy+Ok65P0WPIPNTJmXfYm23zEKrghPxEqA7fFBv7mPv+FHx55kRkoTkdjTRz eUsMWy3Py/5/Z1rljcETKU4SC/QoVaIeAwwxJJvpD/+L6Ig5dE/XuV7zhx9xkVFmw/ E8sknuvxHB4Kf55Km+JoIGkmwUCreTTPoFVAzvIQ= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-37834: mm/vmscan: don't try to reclaim hwpoison folio Date: Thu, 8 May 2025 08:39:43 +0200 Message-ID: <2025050825-CVE-2025-37834-269b@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=4703; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=qc/6AF2jadI9dOKuCwinJ7qN9439LRL43qYjdAnAhEk=; b=owGbwMvMwCRo6H6F97bub03G02pJDBkygXPVxCVLlq+eYBh7valX1uaVb/isfZ/dV3fN9Tr63 VJw+ZU7HbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjAR9y0M82tYL3xPucnDnnLa mXtv67bronN8vzMs6Pd+WXr1n9ave1ccC+7M75MPqU7zAgA= 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/vmscan: don't try to reclaim hwpoison folio Syzkaller reports a bug as follows: Injecting memory failure for pfn 0x18b00e at process virtual address 0x20ffd000 Memory failure: 0x18b00e: dirty swapcache page still referenced by 2 users Memory failure: 0x18b00e: recovery action for dirty swapcache page: Failed page: refcount:2 mapcount:0 mapping:0000000000000000 index:0x20ffd pfn:0x18b00e memcg:ffff0000dd6d9000 anon flags: 0x5ffffe00482011(locked|dirty|arch_1|swapbacked|hwpoison|node=0|zone=2|lastcpupid=0xfffff) raw: 005ffffe00482011 dead000000000100 dead000000000122 ffff0000e232a7c9 raw: 0000000000020ffd 0000000000000000 00000002ffffffff ffff0000dd6d9000 page dumped because: VM_BUG_ON_FOLIO(!folio_test_uptodate(folio)) ------------[ cut here ]------------ kernel BUG at mm/swap_state.c:184! Internal error: Oops - BUG: 00000000f2000800 [#1] SMP Modules linked in: CPU: 0 PID: 60 Comm: kswapd0 Not tainted 6.6.0-gcb097e7de84e #3 Hardware name: linux,dummy-virt (DT) pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : add_to_swap+0xbc/0x158 lr : add_to_swap+0xbc/0x158 sp : ffff800087f37340 x29: ffff800087f37340 x28: fffffc00052c0380 x27: ffff800087f37780 x26: ffff800087f37490 x25: ffff800087f37c78 x24: ffff800087f377a0 x23: ffff800087f37c50 x22: 0000000000000000 x21: fffffc00052c03b4 x20: 0000000000000000 x19: fffffc00052c0380 x18: 0000000000000000 x17: 296f696c6f662865 x16: 7461646f7470755f x15: 747365745f6f696c x14: 6f6621284f494c4f x13: 0000000000000001 x12: ffff600036d8b97b x11: 1fffe00036d8b97a x10: ffff600036d8b97a x9 : dfff800000000000 x8 : 00009fffc9274686 x7 : ffff0001b6c5cbd3 x6 : 0000000000000001 x5 : ffff0000c25896c0 x4 : 0000000000000000 x3 : 0000000000000000 x2 : 0000000000000000 x1 : ffff0000c25896c0 x0 : 0000000000000000 Call trace: add_to_swap+0xbc/0x158 shrink_folio_list+0x12ac/0x2648 shrink_inactive_list+0x318/0x948 shrink_lruvec+0x450/0x720 shrink_node_memcgs+0x280/0x4a8 shrink_node+0x128/0x978 balance_pgdat+0x4f0/0xb20 kswapd+0x228/0x438 kthread+0x214/0x230 ret_from_fork+0x10/0x20 I can reproduce this issue with the following steps: 1) When a dirty swapcache page is isolated by reclaim process and the page isn't locked, inject memory failure for the page. me_swapcache_dirty() clears uptodate flag and tries to delete from lru, but fails. Reclaim process will put the hwpoisoned page back to lru. 2) The process that maps the hwpoisoned page exits, the page is deleted the page will never be freed and will be in the lru forever. 3) If we trigger a reclaim again and tries to reclaim the page, add_to_swap() will trigger VM_BUG_ON_FOLIO due to the uptodate flag is cleared. To fix it, skip the hwpoisoned page in shrink_folio_list(). Besides, the hwpoison folio may not be unmapped by hwpoison_user_mappings() yet, unmap it in shrink_folio_list(), otherwise the folio will fail to be unmaped by hwpoison_user_mappings() since the folio isn't in lru list. The Linux kernel CVE team has assigned CVE-2025-37834 to this issue. Affected and fixed versions =========================== Fixed in 6.12.26 with commit 1c9798bf8145a92abf45aa9d38a6406d9eb8bdf0 Fixed in 6.14.5 with commit 912e9f0300c3564b72a8808db406e313193a37ad Fixed in 6.15-rc1 with commit 1b0449544c6482179ac84530b61fc192a6527bfd 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-37834 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/vmscan.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/1c9798bf8145a92abf45aa9d38a6406d9eb8bdf0 https://git.kernel.org/stable/c/912e9f0300c3564b72a8808db406e313193a37ad https://git.kernel.org/stable/c/1b0449544c6482179ac84530b61fc192a6527bfd