{"id":"CVE-2026-99336","aliases":["CVE-2026-99336"],"related":[],"kind":"vulnerability","state":"published","title":"KVM: guest_memfd: take the invalidate lock when unbinding a dying file","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nKVM: guest_memfd: take the invalidate lock when unbinding a dying file\n\nkvm_gmem_unbind() takes mapping->invalidate_lock only if the\nget_file_active() succeeds. When the guest_memfd file is dying, its\nreference count is already zero so get_file_active fails and the binding\nis removed without holding the invalidate lock.\n\nkvm_gmem_invalidate_{start,end}() checks f->bindings independently to\ndecide whether to begin or end KVM MMU invalidation. So, the bindings\nmust therefore remain stable between the two calls. Otherwise, unbind\ncan remove a binding after start increments mmu_invalidate_in_progress,\nbut before end finds the binding and decrements it.\nExample, unbind race with memory failure:\n\n  CPU 0: memory failure               CPU 1: memslot delete\n  ----------------------------------  ---------------------------\n                                      (guest_memfd file is dying)\n  kvm_gmem_error_folio()\n    kvm_gmem_invalidate_start()\n      finds binding\n      mmu_invalidate_in_progress++\n                                      kvm_gmem_unbind()\n                                        get_file_active() fails\n                                        removes binding\n    kvm_gmem_invalidate_end()\n      no binding found\n      counter stays elevated\n\nmmu_invalidate_retry() then returns 1 forever, so guest page faults\nretry without ever installing a mapping and the guest hangs.\n\nRemove the distinction between live and dying files in the unbind path.\nAlways use slot->gmem.file and take the invalidate lock when it's non-NULL.\nNormal unbind callers hold slots_lock, which prevents release from clearing\nthe pointer or freeing the file state until unbind completes. Final VM\nteardown can only see a NULL pointer because guest_memfd pins the KVM until\nrelease has cleared all bindings.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nKVM: guest_memfd: take the invalidate lock when unbinding a dying file\n\nkvm_gmem_unbind() takes mapping->invalidate_lock only if the\nget_file_active() succeeds. When the guest_memfd file is dying, its\nreference count is already zero so get_file_active fails and the binding\nis removed without holding the invalidate lock.\n\nkvm_gmem_invalidate_{start,end}() checks f->bindings independently to\ndecide whether to begin or end KVM MMU invalidation. So, the bindings\nmust therefore remain stable between the two calls. Otherwise, unbind\ncan remove a binding after start increments mmu_invalidate_in_progress,\nbut before end finds the binding and decrements it.\nExample, unbind race with memory failure:\n\n  CPU 0: memory failure               CPU 1: memslot delete\n  ----------------------------------  ---------------------------\n                                      (guest_memfd file is dying)\n  kvm_gmem_error_folio()\n    kvm_gmem_invalidate_start()\n      finds binding\n      mmu_invalidate_in_progress++\n                                      kvm_gmem_unbind()\n                                        get_file_active() fails\n                                        removes binding\n    kvm_gmem_invalidate_end()\n      no binding found\n      counter stays elevated\n\nmmu_invalidate_retry() then returns 1 forever, so guest page faults\nretry without ever installing a mapping and the guest hangs.\n\nRemove the distinction between live and dying files in the unbind path.\nAlways use slot->gmem.file and take the invalidate lock when it's non-NULL.\nNormal unbind callers hold slots_lock, which prevents release from clearing\nthe pointer or freeing the file state until unbind completes. Final VM\nteardown can only see a NULL pointer because guest_memfd pins the KVM until\nrelease has cleared all bindings.","source":"cvelist"}],"published":"2026-11-19T14:21:42.304Z","modified":"2026-11-22T11:16:47.793Z","severity":{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7,"rating":"HIGH"},"severities":[{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7,"rating":"HIGH"}],"cwes":[],"affected":[{"ranges":[{"type":"git","introduced":"a8ac2bd0f98e1a230f1eb3260fa552bf2ef1753b","fixed":"4ae4316682cdc78d8f5a856ab0712a8281f211ca","status":"affected"},{"type":"git","introduced":"ae431059e75d36170a5ae6b44cc4d06d43613215","fixed":"3af94f4e3526efdf52d84d7ba8d9fb8e8facb93a","status":"affected"},{"type":"git","introduced":"ae431059e75d36170a5ae6b44cc4d06d43613215","fixed":"024be82ac4c4df650cc6daca6d7db79daee95470","status":"affected"},{"type":"git","introduced":"ae431059e75d36170a5ae6b44cc4d06d43613215","fixed":"0ee2c883b62deb74d8c43007e8049dc006d3a2fb","status":"affected"},{"type":"git","version":"393893693a523e053f84d69320d090b93503f79f","status":"affected"},{"type":"semver","introduced":"6.12.59","fixed":"6.12.118","status":"affected"},{"type":"semver","introduced":"6.17.9","fixed":"6.18","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"6.18","status":"affected"},{"type":"semver","introduced":"0","fixed":"6.18","status":"unaffected"},{"type":"semver","introduced":"6.12.118","lastAffected":"6.12.*","status":"unaffected"},{"type":"semver","introduced":"6.18.64","lastAffected":"6.18.*","status":"unaffected"},{"type":"semver","introduced":"7.3.2","lastAffected":"7.3.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"7.4-rc1","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"}],"references":[{"url":"https://git.kernel.org/stable/c/4ae4316682cdc78d8f5a856ab0712a8281f211ca","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/3af94f4e3526efdf52d84d7ba8d9fb8e8facb93a","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/024be82ac4c4df650cc6daca6d7db79daee95470","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/0ee2c883b62deb74d8c43007e8049dc006d3a2fb","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-99336","url":"https://www.cve.org/CVERecord?id=CVE-2026-99336","licence":"CVE Terms of Use","modified":"2026-11-22T11:07:43.269Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-99336","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-99336","licence":"Public domain","modified":"2026-11-22T11:16:47.793Z"}],"updatedAt":"2026-11-25T22:59:52.031Z","epss":{"score":0.00165,"percentile":0.0596,"date":"2026-12-01T12:00:22.000Z"}}