Re: [PATCH v2 0/3] mm: khugepaged: fix tracepoint UAF
Lance Yang <[email protected]>
| Newsgroups | org.kvack.linux-mm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Sat, Aug 15, 2026 at 01:19:21PM +0800, Vernon Yang wrote: >From: Vernon Yang <[email protected]> > >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(). Well spotted! Gave the series a run on x86_64 (KVM), all good (only classic SPARSEMEM untested) :) Tested-by: Lance Yang <[email protected]>