Skip to content

KVM: x86: Fix off-by-one in max_vcpu_ids bounds checks

Dmytro Maluka kvm linux-doc linux-kselftest lkml sashiko-reviews 2 versions – Applied

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

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 2 repliesApplied
  2. v13 patches 1 replySuperseded

Changes in v2 from the cover letter

Split selftest fix into two patches, to avoid interim breakage of tests.

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

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/4KVM: selftests: Fix treating KVM_CAP_MAX_VCPU_ID as inclusivetools/testing/selftests/kvm/x86/max_vcpuid_cap_test.c+7 -41 reply
2/4KVM: x86: Fix off-by-one in max_vcpu_ids bounds checksarch/x86/kvm/x86.c+3 -30 replies
3/4KVM: selftests: Improve bsp_vcpu_id and max_vcpu_ids out-of-bound teststools/testing/selftests/kvm/x86/max_vcpuid_cap_test.c tools/testing/selftests/kvm/x86/set_boot_cpu_id.c+5 -50 replies
4/4Documentation: KVM: Clarify that KVM_CAP_MAX_VCPU_ID is exclusiveDocumentation/virt/kvm/api.rst+8 -50 replies

Reviews trailers per patch

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

Read the v2 thread

Cover letter [PATCH v2 0/4] KVM: x86: Fix off-by-one in max_vcpu_ids bounds checks

max_vcpu_ids and KVM_CAP_MAX_VCPU_ID are exclusive, i.e. the maximum allowed vcpu_id value is max_vcpu_ids minus one, not max_vcpu_ids.

Fix the sanity checks for KVM_SET_BOOT_CPU_ID and KVM_CAP_MAX_VCPU_ID and the selftests for them (added in series [1]) to fail when bsp_vcpu_id is incorrectly set to max_vcpu_ids, not to a value below max_vcpu_ids.

Also clarify that in the documentation of KVM_CAP_MAX_VCPU_ID, in an attempt to make this a bit less confusing.

v1 -> v2:
Split selftest fix into two patches, to avoid interim breakage of tests.

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

Dmytro Maluka (4):
KVM: selftests: Fix treating KVM_CAP_MAX_VCPU_ID as inclusive
KVM: x86: Fix off-by-one in max_vcpu_ids bounds checks
KVM: selftests: Improve bsp_vcpu_id and max_vcpu_ids out-of-bound
tests
Documentation: KVM: Clarify that KVM_CAP_MAX_VCPU_ID is exclusive

 Documentation/virt/kvm/api.rst                  | 13 ++++++++-----
 arch/x86/kvm/x86.c                              |  6 +++---
 .../selftests/kvm/x86/max_vcpuid_cap_test.c     | 17 ++++++++++-------
 .../testing/selftests/kvm/x86/set_boot_cpu_id.c |  4 ++--
 4 files changed, 23 insertions(+), 17 deletions(-)
Signature · 1 line
2.55.0.508.g3f0d502094-goog