CVE-2026-23161
Description
In the Linux kernel, the following vulnerability has been resolved:mm/shmem, swap: fix race of truncate and swap entry splitThe helper for shmem swap freeing is not handling the order of swapentries correctly. It uses xa_cmpxchg_irq to erase the swap entry, but itgets the entry order before that using xa_get_order without lockprotection, and it may get an outdated order value if the entry is splitor changed in other ways after the xa_get_order and before thexa_cmpxchg_irq.And besides, the order could grow and be larger than expected, and causetruncation to erase data beyond the end border. For example, if thetarget entry and following entries are swapped in or freed, then a largefolio was added in place and swapped out, using the same entry, thexa_cmpxchg_irq will still succeed, its very unlikely to happen though.To fix that, open code the Xarray cmpxchg and put the order retrieval andvalue checking in the same critical section. Also, ensure the order wontexceed the end border, skip it if the entry goes across the border.Skipping large swap entries crosses the end border is safe here. Shmemtruncate iterates the range twice, in the first iteration,find_lock_entries already filtered such entries, and shmem will swapin theentries that cross the end border and partially truncate the folio (splitthe folio or at least zero part of it). So in the second loop here, if wesee a swap entry that crosses the end order, it must at least have itscontent erased already.I observed random swapoff hangs and kernel panics when stress testingZSWAP with shmem. After applying this patch, all problems are gone.
Risk Information
Associated Vulnerability
No records foundPatch Details
No records foundReferences
https://nvd.nist.gov/vuln/detail/CVE-2023-1234
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-1234