CVE-2026-99733: mm/truncate: look again if a folio left the mapping
In the Linux kernel, the following vulnerability has been resolved:
mm/truncate: look again if a folio left the mapping
invalidateinodepages2range() skips a folio which no longer belongs to the mapping by the time it has got the folio lock, on the assumption that somebody else has removed it from the page cache. But the folio may have been replaced, and then there is a new folio with the same data at that index.
For most cases, like folio migration, that is impossible. However, collapsefile() only checks the refcount of the old folios, under the ipages lock, and relies on their folio locks from there on. That works for users which repeat the lookup when they find folio->mapping changed. The following scenario is, however, possible:
CPU0 pwrite(ODIRECT) CPU1 collapsefile() kiocbinvalidatepages() read the folio (old data), lock it refcount check the write completes copy to newfolio kiocbinvalidatepostdirectwrite() findgetentries() -> old folio xasstore(newfolio) folio->mapping = NULL foliounlock(folio) foliolock() folio->mapping != mapping -> continue
In that scenario, the collapsed folio with the data from before the write stays in the page cache after the write has returned.
This used to be impossible, as khugepaged only collapsed files that nobody had open for writing.
Restart the lookup at that index, like shmemundorange() does. The same problem seems to exist in truncateinodepagesrange() as well when truncateinodefolio() fails, so handle it there as well, but slightly differently: simply check once more through findgetentries().
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.5 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.1.176-1Fixed in 6.1.192-2Fixed in 6.12.107-1Fixed in 6.12.117-1Fixed in 7.3.5-1
Event History
Frequently Asked Questions
What conditions are required to trigger the stale page-cache data condition?
The described race requires a direct write using pwrite(O_DIRECT) while collapse_file() is concurrently replacing folios in the same mapping. The invalidation path can lock an old folio after it has been replaced, observe that it no longer belongs to the mapping, and skip a second lookup of the replacement folio.
What is the practical impact of the race?
A collapsed folio containing data from before the direct write can remain in the page cache after the write completes. This can leave cached data inconsistent with the completed direct-write data.
Is there a workaround when the kernel fix cannot be applied immediately?
The provided information identifies the triggering combination as concurrent O_DIRECT pwrite activity and collapse_file() processing. It does not provide a documented configuration workaround or mitigation.