Re: [PATCH 0/6] KVM: Harden kvm_vcpu_map() usage against memory leaks

From: Sean Christopherson

Date: Fri Jul 31 2026 - 16:12:52 EST


On Thu, 23 Jul 2026 17:47:51 -0700, Sean Christopherson wrote:
> Harden kvm_vcpu_map() usage against memory leaks by yelling if there's already
> a valid mapping, and then unmapping the existing mapping before establishing a
> new one. To get there, add a CLASS() for local, on-stack usage, to guarantee
> the map metadata is zero-initialized (well, so long as the CLASS() is used).
>
> Prompted by 2f2312c422fd ("KVM: nVMX: Put vmcs12 pages if nested VM-Enter fails
> due to invalid guest state").
>
> [...]

Applied to kvm-x86 misc, thanks!

[1/6] KVM: nVMX: Ensure KVM_REQ_GET_NESTED_STATE_PAGES is cleared on VM-Exit
https://github.com/kvm-x86/linux/commit/11722439fb20
[2/6] KVM: nSVM: Add CLASS()es for automagically handling local kvm_vcpu_map() usage
https://github.com/kvm-x86/linux/commit/d196e4d91e78
[3/6] KVM: nSVM: Use CLASS(kvm_vcpu_map_local) for SMM VMCB mappings
https://github.com/kvm-x86/linux/commit/b717245a7b08
[4/6] KVM: nVMX: Use CLASS(kvm_vcpu_map_local_readonly) for MSR bitmap merging
https://github.com/kvm-x86/linux/commit/6bb3493175d8
[5/6] KVM: PPC: Use CLASS(kvm_vcpu_map_local_readonly) for patching dcbz
https://github.com/kvm-x86/linux/commit/e060b94a1cd4
[6/6] KVM: Harden kvm_vcpu_map() against double-mapping and thus leaking references
https://github.com/kvm-x86/linux/commit/e186d4e34ad5

--
https://github.com/kvm-x86/linux/tree/next