Skip to content

Commit c4e0e4a

Browse files
jsmattsonjrbonzini
authored andcommitted
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: a9e38c3 ("KVM: x86: Catch potential overrun in MCE setup") Signed-off-by: Jue Wang <[email protected]> Signed-off-by: Jim Mattson <[email protected]> Reviewed-by: Peter Shier <[email protected]> Message-Id: <[email protected]> Reviewed-by: Vitaly Kuznetsov <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent f6bfd9c commit c4e0e4a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kvm/x86.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3759,7 +3759,7 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu,
37593759
unsigned bank_num = mcg_cap & 0xff, bank;
37603760

37613761
r = -EINVAL;
3762-
if (!bank_num || bank_num >= KVM_MAX_MCE_BANKS)
3762+
if (!bank_num || bank_num > KVM_MAX_MCE_BANKS)
37633763
goto out;
37643764
if (mcg_cap & ~(kvm_mce_cap_supported | 0xff | 0xff0000))
37653765
goto out;

0 commit comments

Comments
 (0)