kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Jim Mattson <jmattson@google.com>, kvm@vger.kernel.org
Cc: Jue Wang <juew@google.com>, Peter Shier <pshier@google.com>
Subject: Re: [PATCH] KVM: x86: Fix off-by-one error in kvm_vcpu_ioctl_x86_setup_mce
Date: Fri, 15 May 2020 19:49:20 +0200	[thread overview]
Message-ID: <e9f74b78-e689-99fe-c469-1de161895e3c@redhat.com> (raw)
In-Reply-To: <20200511225616.19557-1-jmattson@google.com>

On 12/05/20 00:56, Jim Mattson wrote:
> 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>
> ---
>  arch/x86/kvm/x86.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index d786c7d27ce5..5bf45c9aa8e5 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3751,7 +3751,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;
> 

Queued, thanks.

Paolo


      parent reply	other threads:[~2020-05-15 17:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 22:56 [PATCH] KVM: x86: Fix off-by-one error in kvm_vcpu_ioctl_x86_setup_mce Jim Mattson
2020-05-14 17:46 ` Jim Mattson
2020-05-15 12:36 ` Vitaly Kuznetsov
2020-05-15 17:49 ` Paolo Bonzini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e9f74b78-e689-99fe-c469-1de161895e3c@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jmattson@google.com \
    --cc=juew@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pshier@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).