{"id":"CVE-2026-99918","summary":"mm/madvise: atomically clear the young bit on THP MADV_COLD","details":"In the Linux kernel, the following vulnerability has been resolved:\n\nmm/madvise: atomically clear the young bit on THP MADV_COLD\n\nAs-is, madvise_cold_or_pageout_pte_range() discards the hardware young bit\nby invalidating the PMD, doing pmd_mkold() and subsequently writing to the\npmd again.  However, it does so in a racy manner, looking at a\npossibly-stale snapshot.  It's entirely possible that a write elsewhere\nset the hardware D bit, which this logic now loses.\n\nFix it by using pmdp_test_and_clear_young().  This is an atomic\nmodification of the PMD entry, and thus safe against any possible racing\nwrites.  As a (nice) side-effect, this elides one non-required TLB flush\nin pmdp_invalidate().\n\nThis bug can interact with the swapping system in complicated ways,\nleading to data loss.  For instance, if a folio is marked lazyfree, but\nwas later read from, and then MADV_COLD'd while racing a write to that\nsame THP, dropping the dirty bit may lead to data loss as\nreclaim/MADV_PAGEOUT drops the \"clean\" anon folio:\n\nT0                                T1\n================================================================\nMADV_FREE(thp)\t\t\t|\n  folio marked lazyfree\t\t|\nread(thp)\t\t\t|\n  PMD marked young by hardware\t|\n\t\t\t\t| MADV_COLD(thp)\nwrite(thp)\t\t\t|   if (pmd_young(pmd)) {\n  PMD marked dirty by hardware\t|     set(pmdp, pmd_mkold(pmd));\nMADV_PAGEOUT/reclaim\t\t|\n  dirty bit may or may not be   |\n  set\t\t\t\t|\n    reclaim/pageout may drop    |\n    the folio\t\t\t|","modified":"2026-11-30T15:02:32.250497048Z","published":"2026-11-30T13:18:16.236Z","database_specific":{"osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/99xxx/CVE-2026-99918.json","cna_assigner":"Linux"},"references":[{"type":"PACKAGE","url":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"},{"type":"WEB","url":"https://git.kernel.org/stable/c/17ee2edd085250973eb00cbd98c8b2e0f1a64eda"},{"type":"WEB","url":"https://git.kernel.org/stable/c/246c8cc33438a71c28f9b86baa492d9a0a130316"},{"type":"WEB","url":"https://git.kernel.org/stable/c/5a4d557c02049f75c260dd5492c6e1961e49e77e"},{"type":"WEB","url":"https://git.kernel.org/stable/c/866940b1ccbf8061528986484eac73e44f8a1c52"},{"type":"WEB","url":"https://git.kernel.org/stable/c/9eeed293486a5389bc07232613ed57e875c5bdd8"},{"type":"WEB","url":"https://git.kernel.org/stable/c/be48a2b1253655b4f4fdde4c950ff5c87f2ec51a"},{"type":"WEB","url":"https://git.kernel.org/stable/c/be6be6707c2953dc4ee979e7e4605fe436d87429"},{"type":"WEB","url":"https://git.kernel.org/stable/c/fe34430e1f0c5788160508da2265d904c6afab83"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/99xxx/CVE-2026-99918.json"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-99918"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"9c276cc65a58faf98be8e56962745ec99ab87636"},{"fixed":"9eeed293486a5389bc07232613ed57e875c5bdd8"},{"fixed":"17ee2edd085250973eb00cbd98c8b2e0f1a64eda"},{"fixed":"fe34430e1f0c5788160508da2265d904c6afab83"},{"fixed":"be48a2b1253655b4f4fdde4c950ff5c87f2ec51a"},{"fixed":"866940b1ccbf8061528986484eac73e44f8a1c52"},{"fixed":"be6be6707c2953dc4ee979e7e4605fe436d87429"},{"fixed":"5a4d557c02049f75c260dd5492c6e1961e49e77e"},{"fixed":"246c8cc33438a71c28f9b86baa492d9a0a130316"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-99918.json"}},{"package":{"name":"Kernel","ecosystem":"Linux"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"5.4.0"},{"fixed":"5.10.275"}]},{"type":"ECOSYSTEM","events":[{"introduced":"5.11.0"},{"fixed":"5.15.226"}]},{"type":"ECOSYSTEM","events":[{"introduced":"5.16.0"},{"fixed":"6.1.193"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.2.0"},{"fixed":"6.6.163"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.7.0"},{"fixed":"6.12.117"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.13.0"},{"fixed":"6.18.63"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.19.0"},{"fixed":"7.3.4"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-99918.json"}}],"schema_version":"1.9.2"}