* [PATCH v2] KVM: Don't fail KVM_GET_SUPPORTED_CPUID if nent is just right
@ 2011-11-24 10:45 Sasha Levin
2011-11-24 10:48 ` Avi Kivity
0 siblings, 1 reply; 4+ messages in thread
From: Sasha Levin @ 2011-11-24 10:45 UTC (permalink / raw)
To: kvm; +Cc: Sasha Levin, Avi Kivity, Marcelo Tosatti
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;
r = -EFAULT;
--
1.7.8.rc3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] KVM: Don't fail KVM_GET_SUPPORTED_CPUID if nent is just right
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
0 siblings, 1 reply; 4+ messages in thread
From: Avi Kivity @ 2011-11-24 10:48 UTC (permalink / raw)
To: Sasha Levin; +Cc: kvm, Marcelo Tosatti
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 >=.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] KVM: Don't fail KVM_GET_SUPPORTED_CPUID if nent is just right
2011-11-24 10:48 ` Avi Kivity
@ 2011-11-24 11:53 ` Sasha Levin
2011-11-24 12:10 ` Avi Kivity
0 siblings, 1 reply; 4+ messages in thread
From: Sasha Levin @ 2011-11-24 11:53 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm, Marcelo Tosatti
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] KVM: Don't fail KVM_GET_SUPPORTED_CPUID if nent is just right
2011-11-24 11:53 ` Sasha Levin
@ 2011-11-24 12:10 ` Avi Kivity
0 siblings, 0 replies; 4+ messages in thread
From: Avi Kivity @ 2011-11-24 12:10 UTC (permalink / raw)
To: Sasha Levin; +Cc: kvm, Marcelo Tosatti
On 11/24/2011 01:53 PM, Sasha Levin wrote:
> 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;'?
Refactor the whole thing so all the repetitive code goes away. Maybe
make it table driven.
But after my cpuid.c patch please, I'd hate to redo it.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-11-24 12:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2011-11-24 12:10 ` Avi Kivity
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).