CVE-2026-99733 in Linuxinfo

Summary

by MITRE • 11/20/2026

In the Linux kernel, the following vulnerability has been resolved:

mm/truncate: look again if a folio left the mapping

invalidate_inode_pages2_range() 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, collapse_file() only checks the refcount of the old folios, under the i_pages 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(O_DIRECT) CPU1 collapse_file() kiocb_invalidate_pages() read the folio (old data), lock it refcount check the write completes copy to new_folio kiocb_invalidate_post_direct_write() find_get_entries() -> old folio xas_store(new_folio) folio->mapping = NULL folio_unlock(folio) folio_lock() 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 shmem_undo_range() does. The same problem seems to exist in truncate_inode_pages_range() as well when truncate_inode_folio() fails, so handle it there as well, but slightly differently: simply check once more through find_get_entries().

Be aware that VulDB is the high quality source for vulnerability data.

Analysis

by VulDB Data Team • 11/20/2026

The Linux kernel contains a race condition within the memory management subsystem that affects how page cache folios are handled during file truncation and direct I/O operations. Specifically, the function invalidate_inode_pages2_range() is designed to skip folios that no longer belong to the current mapping when it acquires the folio lock. This behavior relies on the assumption that if a folio has been removed from the page cache by another process while waiting for the lock, then any data associated with that index has already been properly handled or discarded. However, this logic fails in scenarios where the original folio is replaced rather than simply removed, leading to stale data persisting in the page cache even after a write operation has completed successfully.

The vulnerability arises primarily during file collapse operations managed by collapse_file(). This function checks the reference count of old folios under the i_pages lock and subsequently relies on their folio locks for further processing. While this approach works correctly when users repeat the lookup upon detecting that the folio mapping has changed, it creates a window for race conditions in specific concurrent execution paths. The issue is particularly relevant because khugepaged previously prevented such scenarios by only collapsing files that were not open for writing, but changes to these constraints have exposed this logic flaw.

A concrete exploitation scenario involves two CPUs executing concurrently. On CPU0, a direct write operation via pwrite() initiates and eventually completes. Simultaneously on CPU1, collapse_file() is invoked alongside kiocb_invalidate_pages(). The sequence begins with the system reading an old folio containing stale data and locking it. During this time, the refcount check occurs, followed by the completion of the write operation which copies new data to a new_folio via xas_store(), effectively setting the original folio's mapping pointer to NULL before unlocking it. When CPU0 subsequently attempts to lock the same folio index through kiocb_invalidate_post_direct_write() and find_get_entries(), it retrieves the old, now unmapped folio. Because the mapping no longer matches the expected value, invalidate_inode_pages2_range() incorrectly assumes the folio has been removed from the cache and skips further processing. Consequently, the collapsed folito containing outdated data remains in the page cache despite the write having returned successfully to the user space application.

This flaw constitutes a CWE-367 Time-of-check Time-of-use (TOCTOU) race condition within the kernel's memory management layer. From an offensive security perspective aligned with MITRE ATT&CK, this vulnerability could potentially be leveraged for data integrity violations or information disclosure if an attacker can manipulate file states to trigger the race and access stale cached data that should have been invalidated. The persistence of old data in the page cache undermines the consistency guarantees expected from direct I/O operations, which are typically used for applications requiring strict control over caching behavior such as databases.

The resolution involves modifying the lookup logic within invalidate_inode_pages2_range() to restart the search at the current index if a folio is found that no longer belongs to the mapping but still exists in the cache structure. This approach mirrors the handling strategy employed by shmem_undo_range(). Additionally, the same vulnerability pattern was identified in truncate_inode_pages_range(), specifically when truncate_inode_folio() fails. For this function, the fix implements a slightly different mitigation: it performs an additional check through find_get_entries() to ensure that no stale folios remain associated with the truncated range. These changes ensure that any folio replaced during concurrent operations is correctly identified and handled, preventing the retention of obsolete data in the page cache.

Responsible

Linux

Reservation

09/25/2026

Disclosure

11/20/2026

Moderation

accepted

CPE

ready

EPSS

0.00000

KEV

no

Activities

very low

Sources

Are you interested in using VulDB?

Download the whitepaper to learn more about our service!