CVE-2021-47639

In the Linux kernel, the following vulnerability has been resolved: KVM: x86/mmu: Zap _all_ roots when unmapping gfn range in TDP MMU Zap both valid and invalid roots when zapping/unmapping a gfn range, as KVM must ensure it holds no references to the freed page after returning from the unmap operation. Most notably, the TDP MMU doesn't zap invalid roots in mmu_notifier callbacks. This leads to use-after-free and other issues if the mmu_notifier runs to completion while an invalid root zapper yields as KVM fails to honor the requirement that there must be _no_ references to the page after the mmu_notifier returns. The bug is most easily reproduced by hacking KVM to cause a collision between set_nx_huge_pages() and kvm_mmu_notifier_release(), but the bug exists between kvm_mmu_notifier_invalidate_range_start() and memslot updates as well. Invalidating a root ensures pages aren't accessible by the guest, and KVM won't read or write page data itself, but KVM will trigger e.g. kvm_set_pfn_dirty() when zapping SPTEs, and thus completing a zap of an invalid root _after_ the mmu_notifier returns is fatal. WARNING: CPU: 24 PID: 1496 at arch/x86/kvm/../../../virt/kvm/kvm_main.c:173 [kvm] RIP: 0010:kvm_is_zone_device_pfn+0x96/0xa0 [kvm] Call Trace: <TASK> kvm_set_pfn_dirty+0xa8/0xe0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] zap_gfn_range+0x1f3/0x310 [kvm] kvm_tdp_mmu_zap_invalidated_roots+0x50/0x90 [kvm] kvm_mmu_zap_all_fast+0x177/0x1a0 [kvm] set_nx_huge_pages+0xb4/0x190 [kvm] param_attr_store+0x70/0x100 module_attr_store+0x19/0x30 kernfs_fop_write_iter+0x119/0x1b0 new_sync_write+0x11c/0x1b0 vfs_write+0x1cc/0x270 ksys_write+0x5f/0xe0 do_syscall_64+0x38/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae </TASK>
Configurations

Configuration 1 (hide)

OR cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*

History

24 Mar 2025, 17:47

Type Values Removed Values Added
References () https://git.kernel.org/stable/c/0c8a8da182d4333d9bbb9131d765145568c847b2 - () https://git.kernel.org/stable/c/0c8a8da182d4333d9bbb9131d765145568c847b2 - Patch
References () https://git.kernel.org/stable/c/8cf6f98ab1d16d5e607635a0c21c4231eb15367e - () https://git.kernel.org/stable/c/8cf6f98ab1d16d5e607635a0c21c4231eb15367e - Patch
References () https://git.kernel.org/stable/c/af47248407c0c5ae52a752af1ab5ce5b0db91502 - () https://git.kernel.org/stable/c/af47248407c0c5ae52a752af1ab5ce5b0db91502 - Patch
References () https://git.kernel.org/stable/c/d62007edf01f5c11f75d0f4b1e538fc52a5b1982 - () https://git.kernel.org/stable/c/d62007edf01f5c11f75d0f4b1e538fc52a5b1982 - Patch
First Time Linux linux Kernel
Linux
CPE cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*

27 Feb 2025, 19:15

Type Values Removed Values Added
Summary
  • (es) En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: KVM: x86/mmu: Se eliminan _todos_ las raíces al anular la asignación del rango gfn en TDP MMU Se eliminan las raíces válidas e inválidas al hacer zapping/anular la asignación de un rango gfn, ya que KVM debe asegurarse de que no contiene referencias a la página liberada después de regresar de la operación de anulación de la asignación. En particular, TDP MMU no elimina las raíces inválidas en las devoluciones de llamadas mmu_notifier. Esto conduce a problemas de use-after-free y otros problemas si mmu_notifier se ejecuta hasta el final mientras que un zapper de raíz inválida cede, ya que KVM no cumple con el requisito de que no debe haber _ninguna_ referencia a la página después de que mmu_notifier regrese. El error se reproduce más fácilmente pirateando KVM para provocar una colisión entre set_nx_huge_pages() y kvm_mmu_notifier_release(), pero el error también existe entre kvm_mmu_notifier_invalidate_range_start() y las actualizaciones de memslot. Invalidar una raíz garantiza que el invitado no pueda acceder a las páginas, y KVM no leerá ni escribirá datos de página por sí mismo, pero KVM activará, por ejemplo, kvm_set_pfn_dirty() al hacer zapping de SPTE, y por lo tanto, completar un zapping de una raíz no válida _después_ de que mmu_notifier regrese es fatal. ADVERTENCIA: CPU: 24 PID: 1496 en arch/x86/kvm/../../../virt/kvm/kvm_main.c:173 [kvm] RIP: 0010:kvm_is_zone_device_pfn+0x96/0xa0 [kvm] Rastreo de llamadas: kvm_set_pfn_dirty+0xa8/0xe0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] zap_gfn_range+0x1f3/0x310 [kvm] kvm_tdp_mmu_zap_raíces_invalidadas+0x50/0x90 [kvm] kvm_mmu_zap_all_fast+0x177/0x1a0 [kvm] set_nx_huge_pages+0xb4/0x190 [kvm] param_attr_store+0x70/0x100 module_attr_store+0x19/0x30 kernfs_fop_write_iter+0x119/0x1b0 new_sync_write+0x11c/0x1b0 vfs_write+0x1cc/0x270 ksys_write+0x5f/0xe0 do_syscall_64+0x38/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae
CWE CWE-416
CVSS v2 : unknown
v3 : unknown
v2 : unknown
v3 : 7.8

26 Feb 2025, 06:37

Type Values Removed Values Added
New CVE

Information

Published : 2025-02-26 06:37

Updated : 2025-03-24 17:47


NVD link : CVE-2021-47639

Mitre link : CVE-2021-47639

CVE.ORG link : CVE-2021-47639


JSON object : View

Products Affected

linux

  • linux_kernel
CWE
CWE-416

Use After Free