]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: selftests: Fix signedness issue with vCPU mmap size check
authorJames Houghton <jthoughton@google.com>
Fri, 11 Jul 2025 00:17:42 +0000 (00:17 +0000)
committerSean Christopherson <seanjc@google.com>
Tue, 19 Aug 2025 14:43:56 +0000 (07:43 -0700)
commita585b87614511e4272305bb5acf406f19f7dcade
tree42e512a3f7102d34337e7c3127f71d090c12a924
parentc17b750b3ad9f45f2b6f7e6f7f4679844244f0b9
KVM: selftests: Fix signedness issue with vCPU mmap size check

Check that the return value of KVM_GET_VCPU_MMAP_SIZE is non-negative
before comparing with sizeof(kvm_run). If KVM_GET_VCPU_MMAP_SIZE fails,
it will return -1, and `-1 > sizeof(kvm_run)` is true, so the ASSERT
passes.

There are no other locations in tools/testing/selftests/kvm that make
the same mistake.

Signed-off-by: James Houghton <jthoughton@google.com>
Link: https://lore.kernel.org/r/20250711001742.1965347-1-jthoughton@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/lib/kvm_util.c