Skip to content

KVM: Harden kvm_vcpu_map() usage against memory leaks

Sean Christopherson kvm linuxppc-dev lkml sashiko-reviews 1 version Applied

Status from this message: Applied to kvm-x86 misc, thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 3 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/6KVM: nVMX: Ensure KVM_REQ_GET_NESTED_STATE_PAGES is cleared on VM-Exitarch/x86/kvm/vmx/nested.c+3 -21 reply
2/6KVM: nSVM: Add CLASS()es for automagically handling local kvm_vcpu_map() usagearch/x86/kvm/svm/nested.c arch/x86/kvm/svm/svm.c include/linux/kvm_host.h+29 -160 replies
3/6KVM: nSVM: Use CLASS(kvm_vcpu_map_local) for SMM VMCB mappingsarch/x86/kvm/svm/svm.c+14 -240 replies
4/6KVM: nVMX: Use CLASS(kvm_vcpu_map_local_readonly) for MSR bitmap mergingarch/x86/kvm/vmx/nested.c+3 -50 replies
5/6KVM: PPC: Use CLASS(kvm_vcpu_map_local_readonly) for patching dcbzarch/powerpc/kvm/book3s_pr.c+3 -61 reply
6/6KVM: Harden kvm_vcpu_map() against double-mapping and thus leaking referencesvirt/kvm/kvm_main.c+3 -00 replies

Reviews trailers per patch

1 of 6 patches has a Reviewed-by or Acked-by.

PatchYosry Ahmed
1/6R-b
2/6
3/6
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

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

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").

Patch 1 is related in that it's needed to avoid tripping the new WARN.

The PPC change is compile-tested only.

Sean Christopherson (6):
KVM: nVMX: Ensure KVM_REQ_GET_NESTED_STATE_PAGES is cleared on VM-Exit
KVM: nSVM: Add CLASS()es for automagically handling local
kvm_vcpu_map() usage
KVM: nSVM: Use CLASS(kvm_vcpu_map_local) for SMM VMCB mappings
KVM: nVMX: Use CLASS(kvm_vcpu_map_local_readonly) for MSR bitmap
merging
KVM: PPC: Use CLASS(kvm_vcpu_map_local_readonly) for patching dcbz
KVM: Harden kvm_vcpu_map() against double-mapping and thus leaking
references

 arch/powerpc/kvm/book3s_pr.c |  9 +++----
 arch/x86/kvm/svm/nested.c    | 18 ++++++--------
 arch/x86/kvm/svm/svm.c       | 46 +++++++++++++-----------------------
 arch/x86/kvm/vmx/nested.c    | 13 +++++-----
 include/linux/kvm_host.h     | 19 +++++++++++++++
 virt/kvm/kvm_main.c          |  3 +++
 6 files changed, 55 insertions(+), 53 deletions(-)

base-commit: 6bc96b971766fbbbbdd9fb2642cedacaf02da957

Signature · 1 line
2.55.0.229.g6434b31f56-goog