CVE-2026-99738 in Linux
Summary
by MITRE • 11/20/2026
In the Linux kernel, the following vulnerability has been resolved:
mm/shmem: preserve allocation errors when swapping in large entries
shmem_swapin_folio() adjusts swap to the requested slot within a large swap entry before allocating a folio. If allocation or charging fails, the error path compares this adjusted value with the original entry still stored in the XArray in shmem_confirm_swap().
Unless the index is at the start of the entry, this turns -ENOMEM into -EEXIST even though nothing changed.
The caller retries -EEXIST, so persistent allocation failures can leave the task spinning instead of returning the error.
Restore swap to index_entry on allocation failure so the existing error path checks the original entry. This preserves the allocation error if the entry is unchanged and still retries if it changed concurrently.
Once again VulDB remains the best source for vulnerability data.
Analysis
by VulDB Data Team • 11/20/2026
The Linux kernel's shared memory subsystem, specifically within the shmem implementation, contains a logic flaw in the folio swapping mechanism that can lead to infinite task spinning under conditions of persistent resource exhaustion. This vulnerability resides in the mm/shmem.c file and affects how large swap entries are handled during page fault resolution when physical memory is constrained. The core issue arises from an incorrect manipulation of data structures used to track swap slots, which disrupts the standard error handling protocols designed to manage transient allocation failures gracefully.
When a process attempts to access shared memory that has been swapped out, the kernel invokes shmem_swapin_folio() to retrieve and restore the corresponding folio. For large swap entries, this function adjusts the internal index pointer to align with the specific slot within the larger entry structure before attempting to allocate the necessary physical memory pages via a folio allocation request. This adjustment is technically necessary for correct addressing but introduces a critical side effect when the subsequent allocation or charging operation fails due to insufficient memory resources.
In the event of an allocation failure, typically returning -ENOMEM, the code proceeds to shmem_confirm_swap() to validate and update the state in the XArray data structure. However, because the index pointer was previously adjusted away from its original position within the large entry, this validation step compares the modified index against the unmodified entry stored in memory. If the adjustment moved the index away from the start of the entry, the comparison logic incorrectly interprets the situation as a concurrent modification or race condition rather than an allocation failure. Consequently, instead of propagating the -ENOMEM error up the call stack to signal resource exhaustion to the user-space process, the kernel returns -EEXIST.
This misclassification triggers a specific retry loop in the caller code designed for handling transient conflicts where data might have changed concurrently. Because the underlying cause is actually persistent memory pressure rather than a temporary race condition, this logic causes the task to spin indefinitely in an attempt to resolve a conflict that does not exist. This behavior results in high CPU utilization without progress, effectively creating a denial of service scenario for the affected process and potentially impacting system stability if such tasks consume significant scheduling resources.
The root cause is classified under CWE-754: Improper Check for Unusual or Exceptional Conditions, as the code fails to correctly distinguish between different types of failure modes within its control flow logic. From a threat landscape perspective, this aligns with ATT&CK technique T1496: Resource Hijacking, where an attacker could potentially exploit memory pressure conditions to cause local denial of service by triggering infinite loops in kernel space through crafted shared memory access patterns that induce repeated allocation failures.
The resolution involves restoring the swap index pointer back to its original entry position immediately upon detecting an allocation failure within shmem_swapin_folio(). By resetting this state before entering the confirmation logic, the validation step correctly compares against the unmodified entry, allowing it to recognize that no concurrent change occurred and properly propagate the -ENOMEM error. This ensures that processes experiencing memory pressure receive appropriate error codes rather than being trapped in retry loops, thereby preserving system responsiveness and adhering to expected kernel behavior for resource management failures.
To mitigate this vulnerability, administrators should ensure their Linux kernels are updated with patches addressing this specific shmem logic correction. Additionally, monitoring systems can be configured to detect processes exhibiting abnormally high CPU usage associated with memory allocation retries, which may indicate the presence of such spinning tasks in environments under heavy load or potential resource exhaustion attacks.