{"id":"CVE-2026-99463","state":"PUBLISHED","title":"mm/rmap: don't discard lazyfree THPs at PMD level","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nmm/rmap: don't discard lazyfree THPs at PMD level\n\n__discard_anon_folio_pmd_locked() clears a lazyfree THP's PMD before it\ndetermines whether the folio can be discarded, and restores it if the\nfolio is dirty or has extra references.  It is done under only the PMD\nlock and the anon_vma read lock inside try_to_unmap_one() and no mmap lock\nis held.  The temporarily none PMD causes UAF.\n\nA parallel munmap() or mremap() is supposed to serialize with it on the\nPMD lock, but zap_pmd_range() (called by munmap()) and move_page_tables()\n(called by mremap()) do not take the lock when they see the temporarily\nnone PMD and skip the PMD.  There is no more page table walk after the\nnone PMD is restored:\n\n- munmap(): free_pgtables() waits in unlink_anon_vmas() for the anon_vma\n  lock, then free_pmd_range() drops the restored PMD as bad without\n  removing the rmap, so the folio keeps a stale mapcount.\n\n- whole-VMA MREMAP_DONTUNMAP: dontunmap_complete() unlinks the source VMA\n  from its anon_vma while the restored PMD still maps the folio.\n\n- plain mremap(): the THP is not moved but unmapped, so the THP's data is\n  lost.\n\nIn the first two cases, the folio stays mapped, but no VMA that maps it is\nlinked to its anon_vma.  When the anon_vma is freed, it is still reachable\nwhen one rmap walks the folio.  Racing lazyfree reclaim against\nMREMAP_DONTUNMAP as an unprivileged user reproduces a KASAN use-after-free\nin folio_lock_anon_vma_read() as reported in the Closes link.\n\nOne solution is to use an invalidated PMD instead of a cleared one until\nthe discard is committed, but it needs arch fixes first.\n1. GUP-fast still follows an invalidated PMD on riscv, LoongArch and s390.\n2. sparc64 miscounts thp_pte_count when an invalidated PMD is set again or\n   cleared.\n\nTo keep the fix simple for backport, stop discarding lazyfree THPs at PMD\nlevel instead. try_to_unmap_one() splits the PMD and discards the folio at\nPTE level.\n\nunmap_huge_pmd_locked() and __discard_anon_folio_pmd_locked() are left in\nplace, unused, to minimize this fix for backport and the invalidated PMD\napproach is planned as a follow-up series to use them again.","publishedAt":"2026-11-19T14:42:16.661Z","updatedAt":"2026-11-22T11:08:26.233Z","severity":{"score":7.8,"label":"High","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"Linux"},"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"735ecdfaf4e802209caf34b7ac45adf448c54ccc","status":"affected","lessThan":"8cf9517996067cfbfc5abdb4cfb3d7e15a7b34a3","versionType":"git"},{"version":"735ecdfaf4e802209caf34b7ac45adf448c54ccc","status":"affected","lessThan":"3594027c292b09d9301b4be80fa8e0c815ffaf2a","versionType":"git"},{"version":"735ecdfaf4e802209caf34b7ac45adf448c54ccc","status":"affected","lessThan":"b8c683bd548268453d50e933aab2e7d50a7ac2be","versionType":"git"},{"version":"735ecdfaf4e802209caf34b7ac45adf448c54ccc","status":"affected","lessThan":"984c0700854e35779a2bcce6b02783e709b6efa2","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["mm/rmap.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.11","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.11","versionType":"semver"},{"version":"6.12.117","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.18.61","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"7.3.2","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["mm/rmap.c"]}],"references":["https://git.kernel.org/stable/c/8cf9517996067cfbfc5abdb4cfb3d7e15a7b34a3","https://git.kernel.org/stable/c/3594027c292b09d9301b4be80fa8e0c815ffaf2a","https://git.kernel.org/stable/c/b8c683bd548268453d50e933aab2e7d50a7ac2be","https://git.kernel.org/stable/c/984c0700854e35779a2bcce6b02783e709b6efa2"],"weaknesses":[],"ingestedAt":"2026-11-22T11:18:06.032Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/99xxx/CVE-2026-99463.json","commit":"247cc9beefd85903834df0592e88a44f4d599223","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-99463","state":"PUBLISHED","datePublished":"2026-11-19T14:42:16.661Z","dateUpdated":"2026-11-22T11:08:26.233Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-09-25T10:25:14.416Z"},"containers":{"cna":{"title":"mm/rmap: don't discard lazyfree THPs at PMD level","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nmm/rmap: don't discard lazyfree THPs at PMD level\n\n__discard_anon_folio_pmd_locked() clears a lazyfree THP's PMD before it\ndetermines whether the folio can be discarded, and restores it if the\nfolio is dirty or has extra references.  It is done under only the PMD\nlock and the anon_vma read lock inside try_to_unmap_one() and no mmap lock\nis held.  The temporarily none PMD causes UAF.\n\nA parallel munmap() or mremap() is supposed to serialize with it on the\nPMD lock, but zap_pmd_range() (called by munmap()) and move_page_tables()\n(called by mremap()) do not take the lock when they see the temporarily\nnone PMD and skip the PMD.  There is no more page table walk after the\nnone PMD is restored:\n\n- munmap(): free_pgtables() waits in unlink_anon_vmas() for the anon_vma\n  lock, then free_pmd_range() drops the restored PMD as bad without\n  removing the rmap, so the folio keeps a stale mapcount.\n\n- whole-VMA MREMAP_DONTUNMAP: dontunmap_complete() unlinks the source VMA\n  from its anon_vma while the restored PMD still maps the folio.\n\n- plain mremap(): the THP is not moved but unmapped, so the THP's data is\n  lost.\n\nIn the first two cases, the folio stays mapped, but no VMA that maps it is\nlinked to its anon_vma.  When the anon_vma is freed, it is still reachable\nwhen one rmap walks the folio.  Racing lazyfree reclaim against\nMREMAP_DONTUNMAP as an unprivileged user reproduces a KASAN use-after-free\nin folio_lock_anon_vma_read() as reported in the Closes link.\n\nOne solution is to use an invalidated PMD instead of a cleared one until\nthe discard is committed, but it needs arch fixes first.\n1. GUP-fast still follows an invalidated PMD on riscv, LoongArch and s390.\n2. sparc64 miscounts thp_pte_count when an invalidated PMD is set again or\n   cleared.\n\nTo keep the fix simple for backport, stop discarding lazyfree THPs at PMD\nlevel instead. try_to_unmap_one() splits the PMD and discards the folio at\nPTE level.\n\nunmap_huge_pmd_locked() and __discard_anon_folio_pmd_locked() are left in\nplace, unused, to minimize this fix for backport and the invalidated PMD\napproach is planned as a follow-up series to use them again."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"735ecdfaf4e802209caf34b7ac45adf448c54ccc","status":"affected","lessThan":"8cf9517996067cfbfc5abdb4cfb3d7e15a7b34a3","versionType":"git"},{"version":"735ecdfaf4e802209caf34b7ac45adf448c54ccc","status":"affected","lessThan":"3594027c292b09d9301b4be80fa8e0c815ffaf2a","versionType":"git"},{"version":"735ecdfaf4e802209caf34b7ac45adf448c54ccc","status":"affected","lessThan":"b8c683bd548268453d50e933aab2e7d50a7ac2be","versionType":"git"},{"version":"735ecdfaf4e802209caf34b7ac45adf448c54ccc","status":"affected","lessThan":"984c0700854e35779a2bcce6b02783e709b6efa2","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["mm/rmap.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.11","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.11","versionType":"semver"},{"version":"6.12.117","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.18.61","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"7.3.2","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["mm/rmap.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/8cf9517996067cfbfc5abdb4cfb3d7e15a7b34a3"},{"url":"https://git.kernel.org/stable/c/3594027c292b09d9301b4be80fa8e0c815ffaf2a"},{"url":"https://git.kernel.org/stable/c/b8c683bd548268453d50e933aab2e7d50a7ac2be"},{"url":"https://git.kernel.org/stable/c/984c0700854e35779a2bcce6b02783e709b6efa2"}],"metrics":[{"cvssV3_1":{"version":"3.1","vectorString":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","baseScore":7.8,"baseSeverity":"HIGH"},"scenarios":[{"lang":"en","value":"AV:L - madvise(MADV_PAGEOUT) enters madvise_pageout(), which isolates the folio and calls reclaim_pages() -> shrink_folio_list() -> try_to_unmap() -> try_to_unmap_one(), the function the fix changes. MADV_FREE has already made the THP lazyfree through madvise_free_huge_pmd() and folio_mark_lazyfree(). The colliding munmap() or mremap(MREMAP_DONTUNMAP) is the same caller's syscall.\nAC:L - The attacker faults a PMD THP, marks it lazyfree, and keeps a read-only GUP ref. __discard_anon_folio_pmd_locked() then hits ref_count != map_count + 1 and set_pmd_at() restores the PMD that pmdp_huge_clear_flush() cleared. Concurrently get_old_pmd() or zap_pmd_range() samples that none PMD without the PMD lock. The attacker runs both syscalls and can retry.\nPR:L - SYSCALL_DEFINE3(madvise) and SYSCALL_DEFINE5(mremap) accept MADV_FREE, MADV_PAGEOUT, and MREMAP_DONTUNMAP from any local uid on its own anonymous VMA. CAP_SYS_ADMIN is checked only in madvise_inject_error() for MADV_HWPOISON. do_mremap() locks only current->mm.\nUI:N - The attacker creates the anonymous mapping and issues MADV_FREE, MADV_PAGEOUT, and munmap() or mremap(MREMAP_DONTUNMAP) against it. zap_pmd_range() and dontunmap_complete() then run in that same process.\nS:U - put_anon_vma() frees an anon_vma from anon_vma_cachep in the kernel that is running the attacker, and folio_lock_anon_vma_read() then uses the stale folio->mapping. The corrupted object and the walk stay in that kernel.\nC:H - unlink_anon_vmas() in dontunmap_complete() or free_pgtables() drops the last anon_vma reference while the restored PMD still maps the folio, so folio->mapping dangles. folio_lock_anon_vma_read() then reads anon_vma->root and locks root->rwsem; a recycled anon_vma_cachep object makes that walk follow another root and its interval tree.\nI:H - down_read_trylock() writes the freed anon_vma rwsem. Once anon_vma_cachep reuses the slot, rmap_walk_anon() invokes try_to_unmap_one(), whose get_and_clear_ptes() clears PTEs of the recycled tree. free_pmd_range() also pmd_clear_bad()s the restored huge PMD without folio_remove_rmap_pmd(), leaving a stale mapcount.\nA:H - Racing lazyfree reclaim with MREMAP_DONTUNMAP is a KASAN use-after-free in folio_lock_anon_vma_read() on the freed anon_vma and oopses the kernel. move_page_tables() also skips the transient none PMD, so a plain mremap() drops the THP and loses its data."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-11-22T11:08:26.233Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.11","versionEndExcluding":"6.12.117"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.11","versionEndExcluding":"6.18.61"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.11","versionEndExcluding":"7.3.2"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.11","versionEndExcluding":"7.4-rc1"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}