{
  "schema_version": "1.6.1",
  "id": "RPI-CVE-2026-99336",
  "modified": "2026-11-23T05:30:01Z",
  "upstream": [
    "CVE-2026-99336"
  ],
  "published": "2026-11-19T15:08:37Z",
  "summary": "KVM: guest_memfd: take the invalidate lock when unbinding a dying file",
  "details": "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.",
  "severity": [
    {
      "type": "CVSS_V3",
      "score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H"
    }
  ],
  "affected": [
    {
      "package": {
        "ecosystem": "Raspberry Pi OS:13",
        "name": "linux"
      },
      "versions": [
        "1:6.18.29-1+rpt1",
        "1:6.18.33-1+rpt1",
        "1:6.18.34-1+rpt1",
        "1:6.18.39-1+rpt1",
        "1:6.18.50-1+rpt1",
        "1:6.18.60-1+rpt1"
      ],
      "ecosystem_specific": {
        "binaries": [
          {
            "binary_name": "linux-image-6.18.29+rpt-rpi-2712",
            "binary_version": "1:6.18.29-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.29+rpt-rpi-v8",
            "binary_version": "1:6.18.29-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.29+rpt-rpi-v8-rt",
            "binary_version": "1:6.18.29-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.33+rpt-rpi-2712",
            "binary_version": "1:6.18.33-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.33+rpt-rpi-v8",
            "binary_version": "1:6.18.33-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.33+rpt-rpi-v8-rt",
            "binary_version": "1:6.18.33-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.34+rpt-rpi-2712",
            "binary_version": "1:6.18.34-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.34+rpt-rpi-v8",
            "binary_version": "1:6.18.34-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.34+rpt-rpi-v8-rt",
            "binary_version": "1:6.18.34-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.39+rpt-rpi-2712",
            "binary_version": "1:6.18.39-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.39+rpt-rpi-v8",
            "binary_version": "1:6.18.39-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.39+rpt-rpi-v8-rt",
            "binary_version": "1:6.18.39-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.50+rpt-rpi-2712",
            "binary_version": "1:6.18.50-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.50+rpt-rpi-v8",
            "binary_version": "1:6.18.50-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.50+rpt-rpi-v8-rt",
            "binary_version": "1:6.18.50-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.60+rpt-rpi-2712",
            "binary_version": "1:6.18.60-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.60+rpt-rpi-v8",
            "binary_version": "1:6.18.60-1+rpt1"
          },
          {
            "binary_name": "linux-image-6.18.60+rpt-rpi-v8-rt",
            "binary_version": "1:6.18.60-1+rpt1"
          }
        ]
      },
      "database_specific": {
        "per_version": {
          "1:6.18.29-1+rpt1": {
            "linux_commit": "66318c5b5cd8145a662303af12ed39ac07eb27cc",
            "upstream_version": "6.18.29",
            "assessment": "commit ancestry (strak rule)",
            "upstream_fixed": "6.18.64"
          },
          "1:6.18.33-1+rpt1": {
            "linux_commit": "95b85bebbedcaedfa7ca79116ed38b7376fba412",
            "upstream_version": "6.18.33",
            "assessment": "commit ancestry (strak rule)",
            "upstream_fixed": "6.18.64"
          },
          "1:6.18.34-1+rpt1": {
            "linux_commit": "c8c7494100e99ee05b11aaa4f0588a223a63d1af",
            "upstream_version": "6.18.34",
            "assessment": "commit ancestry (strak rule)",
            "upstream_fixed": "6.18.64"
          },
          "1:6.18.39-1+rpt1": {
            "linux_commit": "60ea684a8ace97bb0db1a16e20753bdd6ab371ff",
            "upstream_version": "6.18.39",
            "assessment": "commit ancestry (strak rule)",
            "upstream_fixed": "6.18.64"
          },
          "1:6.18.50-1+rpt1": {
            "linux_commit": "cff533aec2fa601846766b32ff57204e0a61bed7",
            "upstream_version": "6.18.50",
            "assessment": "commit ancestry (strak rule)",
            "upstream_fixed": "6.18.64"
          },
          "1:6.18.60-1+rpt1": {
            "linux_commit": "0b41724521c9adf5399409d02aece6c1df0a4432",
            "upstream_version": "6.18.60",
            "assessment": "commit ancestry (strak rule)",
            "upstream_fixed": "6.18.64"
          }
        }
      }
    }
  ],
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://www.cve.org/CVERecord?id=CVE-2026-99336"
    },
    {
      "type": "FIX",
      "url": "https://git.kernel.org/stable/c/4ae4316682cdc78d8f5a856ab0712a8281f211ca"
    },
    {
      "type": "FIX",
      "url": "https://git.kernel.org/stable/c/3af94f4e3526efdf52d84d7ba8d9fb8e8facb93a"
    },
    {
      "type": "FIX",
      "url": "https://git.kernel.org/stable/c/024be82ac4c4df650cc6daca6d7db79daee95470"
    },
    {
      "type": "FIX",
      "url": "https://git.kernel.org/stable/c/0ee2c883b62deb74d8c43007e8049dc006d3a2fb"
    }
  ],
  "database_specific": {
    "source": "https://git.kernel.org/pub/scm/linux/security/vulns.git",
    "upstream_modified": "2026-11-22T11:18:26Z",
    "severity": {
      "source": "kernel CNA",
      "cvss_v3_score": 7.0,
      "cvss_v3_severity": "High",
      "scenario": "AV:L - kvm_gmem_unbind() runs only from kvm_free_memslot() when KVM_SET_USER_MEMORY_REGION deletes a slot (kvm_vm_ioctl -> kvm_vm_ioctl_set_memory_region -> kvm_set_memslot -> kvm_commit_memory_region). The racer, kvm_gmem_error_folio(), is entered from memory_failure(), not from a remote protocol message.\nAC:H - The invalidate lock is skipped only after get_file_active() fails on a dying guest_memfd, and the bad window is kvm_gmem_invalidate_start() through kvm_gmem_invalidate_end() in kvm_gmem_error_folio(). That callback runs only from memory_failure() on an ECC/MCE the attacker cannot schedule.\nPR:L - kvm_vm_ioctl() accepts KVM_CREATE_GUEST_MEMFD and KVM_SET_USER_MEMORY_REGION after checking only that kvm->mm equals current->mm. A user who can open /dev/kvm can create the guest_memfd, close it, and delete the slot; CAP_SYS_ADMIN is not checked.\nUI:N - The process that owns the VM fd closes the guest_memfd and issues the memslot deletion itself. No other user has to mount, open, or approve anything.\nS:U - The stuck kvm->mmu_invalidate_in_progress counter and the freed kvm_memory_slot belong to the host KVM instance the caller already controls via the VM fd. The guest cannot invoke kvm_gmem_unbind(), so this does not cross a guest/host boundary.\nC:H - kvm_free_memslot() kfree()s the slot as soon as the unlocked kvm_gmem_unbind() returns, while kvm_gmem_invalidate_start() can still be in kvm_unmap_gfn_range() reading slot->as_id and, once shadow roots exist, gfn_to_rmap() on slot->arch.rmap[]. Reclaiming that object exposes those reads.\nI:H - With shadow rmaps allocated, gfn_to_rmap() indexes slot->arch.rmap[] and kvm_zap_rmap() writes through that pointer while kvm_unmap_gfn_range() still holds the slot kvm_free_memslot() has kfree'd. Reclaiming the slab is a kernel write primitive.\nA:H - If kvm_gmem_invalidate_end() no longer finds the binding, mmu_invalidate_in_progress stays non-zero and mmu_invalidate_retry() returns 1 forever, so faults in gmem_abort() re-enter the guest with no mapping and the vCPU livelocks. The slot use-after-free can also oops the host."
    }
  }
}
