UBUNTU-CVE-2026-97533: Use After Free
In the Linux kernel, the following vulnerability has been resolved: x86/mm/pat: Acquire initmm read lock on attribute changes to avoid UAF A previous commit protected against races between ptdump and CPA collapse, however one still exists between attribute changes and collapse as reported by Denis V. Lunev (linked). When an attribute change arises, a lockless page table walker obtains a PTE entry, which is later written to via setpteatomic(): ... -> changepageattrsetclr() -> changepageattrsetclr() -> changepageattr() -> lookupaddresscpa() -> lookupaddressinpgdattr() -> [ lockless page table walker ] -> setpteatomic() There is nothing preventing a concurrent CPA collapse which can free the PTE that was retrieved here, resulting in a use-after-free. With the mmap write lock taken on initmm over CPA collapse, resolve this race by acquiring an mmap read lock on initmm over changepageattrsetclr(). This locks across the whole operation over which the walk and the PTE entry write occurs, solving the race. It is safe to do this here, as no spinlocks are held upon entry to changepageattrsetclr(). However, the lock must not be held over an allocation, as allocation can trigger reclaim and shrinkers may call into CPA recursively, making deadlocks possible (initmm -> ... -> fsreclaim -> initmm). A page table is allocated when a huge page needs to be split: -> changepageattrsetclr() -> changepageattrsetclr() -> changepageattr() -> splitlargepage() [ pagetablealloc() ] -> splitlargepage() Avoid deadlocks by dropping the mmap lock across pagetablealloc() in splitlargepage() and track whether this is needed by adding a new 'initmmreadlocked' flag to struct cpadata. This is safe as splitlargepage() (called with locks re-established) revalidates that the page table entry is the same as it was prior to the locks being dropped and changepageattr() repeats the entire page table walk whenever a split occurs, so concurrent split and collapse are accounted for. Concurrent ptdump is also safe as the lock is only dropped over page table allocation during which time the page table has not yet been modified. The CPACOLLAPSE flag is only set by setmemoryrox(), which exclusively operates upon vmalloc ranges, and on x86 only within the module mapping space. This is important, because some callers directly invoke changepageattrsetclr(), bypassing this lock. However, none of these operate within the module mapping space. cpaprocessalias() - a recursive helper called by changepageattrsetclr(). setmemoryencpgtable() - operates on the direct mapping and (via vmbusestablishgpadl()) the vmalloc mapping space. setpages[n]p() - called by setdirectmap[invalid, default, valid]noflush(), kernelmappages() - operates on the direct map. kernel[un]mappagesinpgd() - operates on EFI ranges. This work is based upon Denis V. Lunev's excellent analysis of the bug with gratitude. [ dhansen: move to imperative voice in changelog ]
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
ubuntu/linux-hwe-7.0to a version that resolves this vulnerability.Fixed in 7.0.0-42.42~24.04.1 - Upgrade
Upgrade
ubuntu/linux-riscv-7.0to a version that resolves this vulnerability.Fixed in 7.0.0-42.42.1~24.04.1 - Upgrade
Upgrade
ubuntu/linuxto a version that resolves this vulnerability.Fixed in 7.0.0-42.42 - Upgrade
Upgrade
ubuntu/linux-awsto a version that resolves this vulnerability.Fixed in 7.0.0-1016.17 - Upgrade
Upgrade
ubuntu/linux-gcpto a version that resolves this vulnerability.Fixed in 7.0.0-1016.18 - Upgrade
Upgrade
ubuntu/linux-ibmto a version that resolves this vulnerability.Fixed in 7.0.0-1017.17 - Upgrade
Upgrade
ubuntu/linux-oem-7.0to a version that resolves this vulnerability.Fixed in 7.0.0-1017.17 - Upgrade
Upgrade
ubuntu/linux-oracleto a version that resolves this vulnerability.Fixed in 7.0.0-1015.16 - Upgrade
Upgrade
ubuntu/linux-riscvto a version that resolves this vulnerability.Fixed in 7.0.0-42.42.1 - Compensating control
Acquire an mmap read lock on init_mm across __change_page_attr_set_clr() to protect the page-table walk and PTE write; drop the mmap lock across pagetable_alloc() in split_large_page() to avoid reclaim/shrinker deadlocks, track this with the init_mm_read_locked flag in struct cpa_data, and re-establish the lock before continuing.