CVE-2026-89987: mm/huge_memory: transfer the pmd dirty bit to the folio on zap
In the Linux kernel, the following vulnerability has been resolved:
mm/hugememory: transfer the pmd dirty bit to the folio on zap
zaphugepmdfolio() propagates the pmd young bit to the folio for the file case, but not the dirty bit. The pte path does propagate it, in zappresentfolioptes() and so does the pmd split path, in splithugepmdlocked().
For most file mappings the omission is harmless, because writing to a shared file mapping goes through pagemkwrite(), which dirties the folio. tmpfs is different: it has no pagemkwrite(), and vmawantswritenotify() is false for it, so a read fault on a MAPSHARED tmpfs mapping installs a writable pmd via doreadfault(). doreadfault() does not call faultdirtysharedpage(), so subsequent stores through that mapping set only the hardware dirty bit in the pmd and never call foliomarkdirty(). A shmem folio allocated by a fault is marked uptodate but not dirty (see the clear: block in shmemgetfoliogfp()), so PGdirty is never set at all.
Unmapping such a folio - munmap(), or exitmmap() when the process dies - then loses the only record that it was written, because zaphugepmd() drops the pmd without transferring the dirty bit. Reclaim afterwards sees a clean shmem folio: the whole swap-out block in shrinkfoliolist() is inside "if (foliotestdirty(folio))", so pageout() is skipped and the folio falls into removemapping(). There, folioisfilelru() is false for a swapbacked folio, so no shadow entry is created and filemapremovefolio(folio, NULL) simply empties the ipages slot. The data is freed without ever being written to swap, and the next fault on that index returns a freshly zeroed folio.
This is silent data loss for any process that keeps state in a MAPSHARED tmpfs segment across an unmap - for example a cache handed from one process generation to the next through /dev/shm. It requires the folio to be PMD-mapped, so it only shows up once shmem THP is enabled (which is what we did in Meta fleet and started noticing crashes); with THP off the pte path transfers the dirty bit correctly. It also only becomes visible when swap is enabled, because with no swap device shmem folios (which are on the anon LRU) are not scanned by reclaim at all, so the clean folio is never dropped.
Reproduced on x8664 with a tmpfs mounted huge=withinsize: read-fault a 2MB-backed region, write a known pattern through the resulting mapping, munmap, force reclaim of the cgroup, then re-map and read back. Without this patch the region reads back as zeros and vmstat shows zswpout 0 - the data was discarded rather than swapped. With this patch the region reads back correctly and the pages are swapped out as expected. With huge=never, or when the first touch is a write, the test passes either way.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Configuration
If the system is affected, disable shmem THP (or avoid PMD-mapped huge shmem folios) until the kernel patch is applied, since the issue is described as only showing up once shmem THP is enabled.
Linux tmpfs (MAP_SHARED huge shmem/THP behavior) transparent huge pages (shmem THP) = enabled/disabled (adjust to avoid MAP_SHARED read-fault dirty-bit/data-loss path without the patch) - Compensating control
For any tmpfs MAP_SHARED workloads on affected hosts, prevent/limit the use of MMAP_SHARED shmem THP until patched (e.g., avoid huge/shmem THP-backed MAP_SHARED regions) to reduce silent data-loss risk.
Event History
Frequently Asked Questions
Which workloads are affected by this issue?
The described affected case is a MAP_SHARED tmpfs mapping backed by a huge PMD mapping. A read fault can install a writable PMD, and later writes may be recorded only in the PMD hardware dirty bit rather than on the folio.
What must occur for data changes to be lost?
After stores through the mapping set the PMD dirty bit, the mapping must be unmapped, such as through munmap() or process teardown via exit_mmap(). If zap_huge_pmd() drops the PMD without transferring its dirty state to the folio, the only record of the writes can be lost.
Are ordinary shared file mappings affected in the same way?
For most file mappings, the omission is described as harmless because writes go through page_mkwrite(), which dirties the folio. tmpfs differs because it has no page_mkwrite() and does not require write notification in this path.