aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Mattson <jmattson@google.com>2020-05-11 15:56:16 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2020-05-15 13:48:56 -0400
commitc4e0e4ab4cf3ec2b3f0b628ead108d677644ebd9 (patch)
tree01d05bcdd585fd47de9fe8b29e8e8d8d1276c9fd
parentf6bfd9c8ffc2d2844042c1c78d8bdca668eea6d5 (diff)
downloadlinux-c4e0e4ab4cf3ec2b3f0b628ead108d677644ebd9.tar.gz
KVM: x86: Fix off-by-one error in kvm_vcpu_ioctl_x86_setup_mce
Bank_num is a one-based count of banks, not a zero-based index. It overflows the allocated space only when strictly greater than KVM_MAX_MCE_BANKS. Fixes: a9e38c3e01ad ("KVM: x86: Catch potential overrun in MCE setup") Signed-off-by: Jue Wang <juew@google.com> Signed-off-by: Jim Mattson <jmattson@google.com> Reviewed-by: Peter Shier <pshier@google.com> Message-Id: <20200511225616.19557-1-jmattson@google.com> Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/x86/kvm/x86.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index d11eba8b85c6..c17e6eb9ad43 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3759,7 +3759,7 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu,
unsigned bank_num = mcg_cap & 0xff, bank;
r = -EINVAL;
- if (!bank_num || bank_num >= KVM_MAX_MCE_BANKS)
+ if (!bank_num || bank_num > KVM_MAX_MCE_BANKS)
goto out;
if (mcg_cap & ~(kvm_mce_cap_supported | 0xff | 0xff0000))
goto out;