Skip to content

KVM: x86: Out-of-bounds access in kvm_recalculate_phys_map()

Sean Christopherson kvm lkml 2 versions – Applied

Status from this message: Applied patch 2 with fixup for the typo to kvm-x86 misc. Note, patches 1 and 3

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 4 repliesApplied
  2. v23 patches 2 repliesSuperseded

Changes in v3 from the cover letter

- s/race/test for the new test file
- Use kvm_vm_free() instead of kvm_vm_release() in the test
- Fix a few typos in the test

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/3KVM: x86: Bail from kvm_recalculate_phys_map() if x2APIC ID is out-of-boundsarch/x86/kvm/lapic.c+18 -21 reply
2/3KVM: x86: Retry APIC optimized map recalc if vCPU is added/enabledarch/x86/kvm/lapic.c+25 -41 reply
3/3KVM: selftests: Add test for race in kvm_recalculate_apic_map()tools/testing/selftests/kvm/Makefile tools/testing/selftests/kvm/x86_64/recalc_apic_map_test.c+75 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/3] KVM: x86: Out-of-bounds access in kvm_recalculate_phys_map()

In Michal's words...

kvm_recalculate_apic_map() creates the APIC map iterating over the list of vCPUs twice. First to find the max APIC ID and allocate a max-sized buffer, then again, calling kvm_recalculate_phys_map() for each vCPU. This opens a race window: value of max APIC ID can increase _after_ the buffer was allocated.

v3:
- s/race/test for the new test file
- Use kvm_vm_free() instead of kvm_vm_release() in the test
- Fix a few typos in the test

v2: https://lore.kernel.org/all/[email protected]

v1: https://lore.kernel.org/all/[email protected]

Michal Luczaj (1):
KVM: selftests: Add test for race in kvm_recalculate_apic_map()

Sean Christopherson (2):
KVM: x86: Bail from kvm_recalculate_phys_map() if x2APIC ID is
out-of-bounds
KVM: x86: Retry APIC optimized map recalc if vCPU is added/enabled

 arch/x86/kvm/lapic.c                          | 49 ++++++++++--
 tools/testing/selftests/kvm/Makefile          |  1 +
 .../kvm/x86_64/recalc_apic_map_test.c         | 74 +++++++++++++++++++
 3 files changed, 118 insertions(+), 6 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/recalc_apic_map_test.c

base-commit: 39428f6ea9eace95011681628717062ff7f5eb5f

Signature · 1 line
2.41.0.rc2.161.g9c6817b8e7-goog