{"id":"CVE-2026-99733","summary":"mm/truncate: look again if a folio left the mapping","details":"In the Linux kernel, the following vulnerability has been resolved:\n\nmm/truncate: look again if a folio left the mapping\n\ninvalidate_inode_pages2_range() skips a folio which no longer belongs to\nthe mapping by the time it has got the folio lock, on the assumption\nthat somebody else has removed it from the page cache. But the folio may\nhave been replaced, and then there is a new folio with the same data at\nthat index.\n\nFor most cases, like folio migration, that is impossible. However,\ncollapse_file() only checks the refcount of the old folios, under the\ni_pages lock, and relies on their folio locks from there on. That works for\nusers which repeat the lookup when they find folio-\u003emapping changed.\nThe following scenario is, however, possible:\n\n  CPU0 pwrite(O_DIRECT)               CPU1 collapse_file()\n  kiocb_invalidate_pages()\n                                      read the folio (old data), lock it\n                                      refcount check\n  the write completes                 copy to new_folio\n  kiocb_invalidate_post_direct_write()\n    find_get_entries() -\u003e old folio\n                                      xas_store(new_folio)\n                                      folio-\u003emapping = NULL\n                                      folio_unlock(folio)\n    folio_lock()\n    folio-\u003emapping != mapping\n      -\u003e continue\n\nIn that scenario, the collapsed folio with the data from before the write\nstays in the page cache after the write has returned.\n\nThis used to be impossible, as khugepaged only collapsed files that nobody\nhad open for writing.\n\nRestart the lookup at that index, like shmem_undo_range() does. The same\nproblem seems to exist in truncate_inode_pages_range() as well when\ntruncate_inode_folio() fails, so handle it there as well, but slightly\ndifferently: simply check once more through find_get_entries().","modified":"2026-11-20T07:01:14.716364826Z","published":"2026-11-20T05:51:07.545Z","database_specific":{"cna_assigner":"Linux","osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/99xxx/CVE-2026-99733.json"},"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/9cf632e139737314afa889ca18122bc3fddb9120"},{"type":"WEB","url":"https://git.kernel.org/stable/c/f17044fee422605d19e07c4c9f5dc2be7abd7086"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/99xxx/CVE-2026-99733.json"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-99733"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"1b6444331bebb4e586dab30b1fa0612ef482bab4"},{"fixed":"f17044fee422605d19e07c4c9f5dc2be7abd7086"},{"fixed":"9cf632e139737314afa889ca18122bc3fddb9120"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-99733.json"}},{"package":{"name":"Kernel","ecosystem":"Linux"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"7.2.0"},{"fixed":"7.3.5"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-99733.json"}}],"schema_version":"1.9.2"}