]> www.infradead.org Git - users/dwmw2/linux.git/commit
KVM: selftests: Fix out-of-bounds reads in CPUID test's array lookups
authorSean Christopherson <seanjc@google.com>
Thu, 3 Oct 2024 23:43:27 +0000 (16:43 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Sun, 20 Oct 2024 16:10:44 +0000 (12:10 -0400)
commit773cca183440e74690dbb4f3f54bc7748f255821
tree0db77807e770addf15df11db7ccdc50f88ce5dc7
parent9a400068a1586bc4f10ee8b0443527de27d8834c
KVM: selftests: Fix out-of-bounds reads in CPUID test's array lookups

When looking for a "mangled", i.e. dynamic, CPUID entry, terminate the
walk based on the number of array _entries_, not the size in bytes of
the array.  Iterating based on the total size of the array can result in
false passes, e.g. if the random data beyond the array happens to match
a CPUID entry's function and index.

Fixes: fb18d053b7f8 ("selftest: kvm: x86: test KVM_GET_CPUID2 and guest visible CPUIDs against KVM_GET_SUPPORTED_CPUID")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-ID: <20241003234337.273364-2-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/x86_64/cpuid_test.c