CVE-2026-89805: drm/pagemap: Fix folio allocation fallback and use-after-put
In the Linux kernel, the following vulnerability has been resolved:
drm/pagemap: Fix folio allocation fallback and use-after-put
drmpagemapmigratepopulaterampfn() had two issues when populating RAM PFNs with higher-order folios:
1. The higher-order vmaallocfolio()/folioalloc() calls did not pass GFPNOWARN, so a THP allocation failure under memory pressure would spam the kernel log, and there was no fallback path despite a TODO comment stating one was needed. Add GFPNOWARN to the higher-order allocation and, on failure, fall back to order-0 allocations for the entire range originally covered by the failed higher-order allocation, leaving MIGRATEPFNCOMPOUND unset for those PFNs.
2. In the freepages error path, order was computed via folioorder(pagefolio(page)) after putpage(page) had already dropped the reference, resulting in a use-after-free/put when that was the last reference on the page. Compute order before releasing the page.
Introducing the fallback in 1. also requires the source page array handed to ->copytoram() to be built differently. Both callers only populated the entry at the head of each source folio, relying on the copy callback to derive the rest of the folio from the order recorded in the matching drmpagemapaddr. Once the destination has been demoted to order-0 folios the drmpagemapaddr entries are per-page, so a source page is needed for every one of them; leaving them NULL makes the copy callback stop after the first page and the remainder of the range is never copied.
The source folio is only split later, by migratevmapages() / migratedevicepages(), so its order cannot be used to detect the demotion - test the destination for MIGRATEPFNCOMPOUND instead. Factor the array population out into drmpagemapmigratepopulatesrcpages() and use it from both drmpagemapevicttoram() and drmpagemapmigratetoram().
Affected Software
Event History
Frequently Asked Questions
What conditions are needed to trigger the affected code paths?
The issue occurs while drm_pagemap_migrate_populate_ram_pfn() populates RAM PFNs using higher-order folios. A higher-order allocation failure under memory pressure triggers the missing fallback scenario, while the error cleanup path can compute a folio order after releasing the page reference.
What are the practical effects besides the use-after-free condition?
Failed higher-order THP allocations could generate kernel-log spam because __GFP_NOWARN was not passed. The resolved code suppresses those warnings and falls back to order-0 allocations for the range covered by the failed higher-order allocation.
How can I determine whether the fix is present?
Check whether the kernel includes either referenced stable commit: 10e92e18e3dab081789d868878f2ecce6166948a or df72e55e754c8d449321ddddad19a8bd3cb8d032. The fixed implementation determines the folio order before put_page(page) and implements order-0 fallback after higher-order allocation failures.