Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Sasha Levin <levinsasha928@gmail.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>
Subject: Re: [PATCH v2] KVM: Don't fail KVM_GET_SUPPORTED_CPUID if nent is just right
Date: Thu, 24 Nov 2011 13:53:42 +0200	[thread overview]
Message-ID: <1322135622.4248.17.camel@lappy> (raw)
In-Reply-To: <4ECE20EA.4060701@redhat.com>

On Thu, 2011-11-24 at 12:48 +0200, Avi Kivity wrote:
> On 11/24/2011 12:45 PM, Sasha Levin wrote:
> > If we pass just enough entries to KVM_GET_SUPPORTED_CPUID, we would still
> > fail with -E2BIG due to wrong comparisons.
> >
> > Cc: Avi Kivity <avi@redhat.com>
> > Cc: Marcelo Tosatti <mtosatti@redhat.com>
> > Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> > ---
> >  arch/x86/kvm/x86.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> > index 9eff4af..83fef71 100644
> > --- a/arch/x86/kvm/x86.c
> > +++ b/arch/x86/kvm/x86.c
> > @@ -2710,7 +2710,7 @@ static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid,
> >  		     cpuid->nent);
> >  
> >  	r = -E2BIG;
> > -	if (nent >= cpuid->nent)
> > +	if (nent > cpuid->nent)
> >  		goto out_free;
> >  
> >
> 
> This is just a landmine for the next entry to be added there; surely
> whoever adds it will forget to correct the > back to >=.
> 

Slapping a big warning before that should do the trick? Or maybe add
something similar to 'final_nent = nent - 1;'?

-- 

Sasha.


  reply	other threads:[~2011-11-24 11:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-24 10:45 [PATCH v2] KVM: Don't fail KVM_GET_SUPPORTED_CPUID if nent is just right Sasha Levin
2011-11-24 10:48 ` Avi Kivity
2011-11-24 11:53   ` Sasha Levin [this message]
2011-11-24 12:10     ` Avi Kivity

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=1322135622.4248.17.camel@lappy \
    --to=levinsasha928@gmail.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.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