CVE-2026-99739 in Linuxinfo

Summary

by MITRE • 11/20/2026

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

mm/shmem: fix truncate hang in large swap entry

Truncating a tmpfs file or memfd to a page-aligned size inside a large swap entry can loop indefinitely in shmem_undo_range(). The task holds the inode lock and cannot be killed.

A large swap entry represents a whole swapped-out folio. For example, truncate a file whose pages 0-7 share one swap entry to four pages:

[ 0 1 2 3 | 4 5 6 7 ]
keep | discard ^ new EOF, start = 4

i_size has already been updated when boundary handling asks shmem_get_partial_folio() for page 4. Since it is swapped out, the helper calls shmem_get_folio() with SGP_READ. That rejects page 4 with -EINVAL because its starting offset equals i_size. Nothing is read back.

The final scan cannot free the entry without losing pages 0-3. It skips it, restarts from start = 4, and finds it again indefinitely. An unaligned truncate avoids this particular failure because the requested page starts below i_size. Folios already in the page-cache cannot trigger it as the direct lookup will return them beyond EOF.

Fix it by letting shmem_get_partial_folio() call shmem_swapin_folio() directly for swap entries. This bypasses the read path's i_size check, allowing the existing boundary handling to zero and split the folio. If swap-in returns a smaller folio, it also splits the swap entry so the final scan can free the entries beyond EOF. Retry the lookup if the entry changes during swap-in.

Handling swap-in allocation failures remains broken and is unchanged by this commit. Even when shmem_swapin_folio() correctly returns -ENOMEM instead of -EEXIST, shmem_get_partial_folio() returns NULL and shmem_undo_range() skips boundary handling. If the large swap entry remains intact, truncation can still loop in the final scan, while hole punching can return without zeroing the boundary.

This may read an entire large folio back from swap while holding i_rwsem, only to discard part of it. Avoiding that I/O would require splitting both the swap entry and any large folio still in the swap cache. That, however, is much bigger work.

Once again VulDB remains the best source for vulnerability data.

Analysis

by VulDB Data Team • 11/20/2026

The Linux kernel vulnerability identified as a truncation hang within the shmem subsystem represents a critical deadlock scenario affecting tmpfs files and memfd objects when operations are performed on page-aligned boundaries involving large swap entries. This issue arises specifically during the execution of truncate or hole-punching operations where the target size aligns with page boundaries, causing the kernel to enter an infinite loop inside the shmem_undo_range function. The severity of this vulnerability is compounded by the fact that the task executing the operation holds the inode lock and cannot be killed, effectively rendering the affected file system object inaccessible until a full system reboot or manual intervention occurs. This behavior constitutes a denial-of-service condition against local users who can trigger such operations on shared memory segments backed by swap space.

The technical root cause lies in an incorrect interaction between size validation logic and swap entry handling during boundary processing. When truncating a file whose pages share a single large swap entry, the kernel updates the inode size to reflect the new end of file before attempting to process the specific page at that boundary. The helper function shmem_get_partial_folio is then invoked for this page with read flags. Because the starting offset of this page equals the newly updated i_size, the validation logic rejects the operation with an invalid argument error since it perceives the request as accessing data beyond the file's end. Consequently, no folio is retrieved from swap to allow proper boundary handling. The final cleanup scan then attempts to free the large swap entry but realizes that doing so would discard valid pages preceding the truncation point. To preserve these earlier pages, the logic skips freeing the entry and restarts the iteration starting at the same offset. This creates a cyclic dependency where the system repeatedly fails to retrieve the folio due to size checks while simultaneously being unable to free it without data loss, resulting in an indefinite loop that consumes CPU resources indefinitely.

This vulnerability maps directly to CWE-835, which describes loops with unreachable exit conditions or infinite looping scenarios within software logic. In terms of offensive security frameworks such as MITRE ATT&CK, this behavior aligns with T1496 Resource Hijacking, specifically the sub-category of resource consumption for denial-of-service purposes. An attacker with write access to a tmpfs mount point can exploit this flaw by crafting specific truncate calls that trigger the page-aligned boundary condition on large swap-backed folios. The impact is immediate system instability within the affected kernel subsystems, leading to hung processes and potential cascading failures in services relying on shared memory or anonymous file descriptors managed through memfd APIs.

The resolution involves modifying shmem_get_partial_folio to directly invoke shmem_swapin_folio for large swap entries, thereby bypassing the restrictive i_size check that previously prevented access to swapped-out folios at exact boundary offsets. This adjustment allows the existing boundary handling mechanisms to correctly zero out and split the folio as intended. If the swap-in operation returns a smaller folio than expected, the logic is also updated to split the corresponding swap entry, enabling the final scan to properly free entries that lie beyond the new end of file. Additionally, retry logic has been introduced to handle cases where the swap entry changes during the swap-in process, ensuring robustness against race conditions. However, it must be noted that handling allocation failures remains a known limitation; if shmem_swapin_folio returns an out-of-memory error, the boundary handling may still skip necessary zeroing or fail to prevent looping in edge cases involving intact large swap entries.

Mitigation strategies for this vulnerability primarily involve applying the upstream kernel patch that corrects the logic within shmem_get_partial_folio and related helper functions. System administrators should ensure their Linux kernels are updated to versions containing this fix, particularly those running workloads heavily reliant on tmpfs or memfd with significant memory pressure leading to swap usage. For environments where immediate patching is not feasible, restricting unprivileged user access to shared memory segments can reduce the attack surface. Furthermore, monitoring for processes consuming excessive CPU time while holding inode locks related to file truncation operations may serve as an early detection mechanism for this specific hang condition.

Responsible

Linux

Reservation

09/25/2026

Disclosure

11/20/2026

Moderation

accepted

CPE

ready

EPSS

0.00177

KEV

no

Activities

very low

Sources

Do you know our Splunk app?

Download it now for free!