KVM: guest_memfd: take the invalidate lock when unbinding a dying file
NIST has received this entry but not started reviewing it.
In the Linux kernel, the following vulnerability has been resolved: KVM: guest_memfd: take the invalidate lock when unbinding a dying file kvm_gmem_unbind() takes mapping->invalidate_lock only if the get_file_active() succeeds. When the guest_memfd file is dying, its reference count is already zero so get_file_active fails and the binding is removed without holding the invalidate lock. kvm_gmem_invalidate_{start,end}() checks f->bindings independently to decide whether to begin or end KVM MMU invalidation. So, the bindings must therefore remain stable between the two calls. Otherwise, unbind can remove a binding after start increments mmu_invalidate_in_progress, but before end finds the binding and decrements it. Example, unbind race with memory failure: CPU 0: memory failure CPU 1: memslot delete ---------------------------------- --------------------------- (guest_memfd file is dying) kvm_gmem_error_folio() kvm_gmem_invalidate_start() finds binding mmu_invalidate_in_progress++ kvm_gmem_unbind() get_file_active() fails removes binding kvm_gmem_invalidate_end() no binding found counter stays elevated mmu_invalidate_retry() then returns 1 forever, so guest page faults retry without ever installing a mapping and the guest hangs. Remove the distinction between live and dying files in the unbind path. Always use slot->gmem.file and take the invalidate lock when it's non-NULL. Normal unbind callers hold slots_lock, which prevents release from clearing the pointer or freeing the file state until unbind completes. Final VM teardown can only see a NULL pointer because guest_memfd pins the KVM until release has cleared all bindings.
New to this? Read how to keep your software updated.
The products and versions NIST lists as vulnerable, 2 products in all. If what you run is not listed it is probably not affected, but ask your provider if you are unsure.
| Product | Type | Vulnerable versions | Fixed in |
|---|---|---|---|
| Linux Linux | Software | from a8ac2bd0f98e1a230f1eb3260fa552bf2ef1753b, before 4ae4316682cdc78d8f5a856ab0712a8281f211ca; from ae431059e75d36170a5ae6b44cc4d06d43613215, before 3af94f4e3526efdf52d84d7ba8d9fb8e8facb93a; from ae431059e75d36170a5ae6b44cc4d06d43613215, before 024be82ac4c4df650cc6daca6d7db79daee95470; from ae431059e75d36170a5ae6b44cc4d06d43613215, before 0ee2c883b62deb74d8c43007e8049dc006d3a2fb; 393893693a523e053f84d69320d090b93503f79f; from 6.12.59, before 6.12.118; and 1 more | 4ae4316682cdc78d8f5a856ab0712a8281f211ca; 3af94f4e3526efdf52d84d7ba8d9fb8e8facb93a; 024be82ac4c4df650cc6daca6d7db79daee95470; 0ee2c883b62deb74d8c43007e8049dc006d3a2fb |
| Linux Linux | Software | 6.18 | not recorded |
The 7.0 severity score (high) from the company that reported it, broken into what it means in practice. Red means it makes the flaw easier or worse.
| How it is reached | On the machine | The attacker needs access to the computer itself, for example a login or a file they can get you to open. |
| How hard it is | High | Hard to carry out. It depends on conditions the attacker cannot control. |
| Login needed | Low | The attacker needs an ordinary user account. |
| Someone has to act | None | Nobody has to click or open anything. It can happen on its own. |
| Reaches beyond the program | Unchanged | The damage stays inside the vulnerable program. |
| Data exposed | High | Total loss of confidentiality: the attacker can read all the data the program can reach. |
| Data changed | High | The attacker can change or delete anything the program can reach. |
| Service disrupted | High | The attacker can take the service down completely. |
| Ease of attack | 1.0 | A score for how easy it is to use the flaw. Higher is easier. |
| Damage | 5.9 | A score for how bad the harm is if it works. Higher is worse. |
NIST lists 4 sources for this flaw, none tagged as a vendor patch.