CVE-2026-99461 in Linux
Summary
by MITRE • 11/19/2026
In the Linux kernel, the following vulnerability has been resolved:
mm: khugepaged: fix swap entry value to folio_pfn()
Patch series "mm: khugepaged: fix tracepoint UAF", v5.
The khugepaged tracepoints take a folio pointer and call folio_pfn(), but by then the folio may no longer be valid: freed after folio_put(), folio_unlock() or pte_unmap_unlock(), or not a folio at all but an xarray-encoded swap entry. On classic SPARSEMEM, dereferencing it oopses khugepaged as soon as the trace event is enabled; on other memory models it merely prints a bogus pfn.
Pass the pfn to the tracepoints directly, captured while the folio is still pinned, closing the use-after-free windows in mm_khugepaged_scan_file(), mm_khugepaged_scan_pmd() and mm_khugepaged_collapse_file().
This patch (of 3):
When the swap entries found exceed max_ptes_swap, the loop is left via break with folio still holding the xarray value that encodes the swap entry, not valid folio pointer.
That value is passed to trace_mm_khugepaged_scan_file(), which feeds it to folio_pfn(). On FLATMEM and SPARSEMEM_VMEMMAP, the page_to_pfn() is plain pointer arithmetic, so the trace event merely prints bogus scan_pfn. On classic SPARSEMEM, the page_to_pfn() reads page->flags, dereferencing the tiny encoded integer and oopsing khugepaged whenever the trace event is enabled.
So when folio is the swap entry value, simply set pfn to -1, just like exhausted scan naturally.
And the folio_put() has maybe dropped the last reference of folio. The trace_mm_khugepaged_scan_file() is left with a dangling folio pointer. so using the folio_pfn() before dropping the reference, closing use-after-free window.
Once again VulDB remains the best source for vulnerability data.
Analysis
by VulDB Data Team • 11/20/2026
The Linux kernel's transparent huge page (THP) subsystem contains a critical vulnerability within its khugepaged background thread, specifically affecting tracepoint implementations that monitor memory scanning operations. The core issue stems from improper handling of folio pointers and swap entries during the scan process in functions such as mm_khugepaged_scan_file(), mm_khugepaged_scan_pmd(), and mm_khugepaged_collapse_file(). These tracepoints are designed to capture performance metrics by extracting a page frame number (PFN) from a folio structure using the folio_pfn() helper. However, the implementation fails to ensure that the folio pointer remains valid at the time of dereference, leading to use-after-free conditions and potential kernel panics depending on the underlying memory model architecture.
The vulnerability manifests in two distinct scenarios within the scanning logic. First, when a scan encounters swap entries exceeding the max_ptes_swap threshold, the loop breaks while still holding an xarray-encoded value that represents a swap entry rather than a valid folio pointer. This encoded integer is subsequently passed to trace_mm_khugepaged_scan_file(), which attempts to interpret it as a memory structure via folio_pfn(). On classic SPARSEMEM configurations, this results in dereferencing invalid memory addresses by reading page->flags from the tiny encoded integer, causing an immediate kernel oops or crash whenever the specific trace event is enabled. In contrast, on FLATMEM and SPARSEMEM_VMEMMAP architectures, where page_to_pfn() relies primarily on pointer arithmetic rather than direct structure field access, the vulnerability results in printing bogus PFN values without necessarily crashing the system immediately, though this still constitutes a data integrity issue within diagnostic tools.
Secondly, even when dealing with valid folios, there is a race condition related to reference counting and locking. The tracepoint code may execute after folio_put() has been called or while the folio is being unlocked via folio_unlock() or pte_unmap_unlock(). These operations can drop the last reference to the folio structure, effectively freeing it from memory before the tracepoint attempts to access its fields. This creates a use-after-free window where khugepaged accesses freed memory, leading to undefined behavior, potential information disclosure of kernel heap contents, or system instability. The root cause is that the PFN value was not captured while the folio was still pinned and validly referenced, but rather extracted after critical synchronization primitives had released their hold on the object.
From a classification perspective, this vulnerability aligns with CWE-416: Use After Free, as it involves accessing memory after it has been freed or invalidated. It also relates to CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization, given that the issue arises from improper ordering of reference counting and tracepoint execution in a concurrent environment. In terms of MITRE ATT&CK mapping, this falls under T1059.004: Unix Shell Command Interpretation if exploited for denial-of-service via kernel panic, or more accurately represents internal exploitation vectors related to memory corruption (T1203) and potentially information gathering through corrupted trace data. The impact ranges from local denial of service due to system crashes on SPARSEMEM systems to subtle diagnostic inaccuracies that could mislead security analysts monitoring THP behavior.
To mitigate this vulnerability, the patch series resolves the issue by capturing the PFN directly while the folio is still pinned and valid, ensuring that tracepoints receive a stable value rather than an invalid pointer or encoded swap entry. Specifically, when the code detects that the current xarray value represents a swap entry rather than a real folio, it explicitly sets the pfn to -1, mirroring the behavior of naturally exhausted scans. Furthermore, the order of operations is adjusted so that folio_pfn() is called before any subsequent folio_put() or unlock calls occur, thereby closing the use-after-free window entirely. System administrators and developers should ensure their kernels are updated with this patch series to prevent potential crashes during high-memory-pressure scenarios where THP scanning is active and tracepoints are enabled for debugging purposes.