All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/hyperv: fix NULL dereference with pure-kvm SynIC
@ 2018-11-26 15:28 Roman Kagan
  2018-11-26 16:04 ` Philippe Mathieu-Daudé
  2018-11-26 17:13 ` Paolo Bonzini
  0 siblings, 2 replies; 5+ messages in thread
From: Roman Kagan @ 2018-11-26 15:28 UTC (permalink / raw)
  To: qemu-devel, Igor Mammedov, Vitaly Kuznetsov, Eduardo Habkost,
	Paolo Bonzini

When started in compat configuration of SynIC, e.g.

qemu-system-x86_64 -machine pc-i440fx-2.10,accel=kvm \
 -cpu host,-vmx,hv-relaxed,hv_spinlocks=0x1fff,hv-vpindex,hv-synic

or explicitly

qemu-system-x86_64 -enable-kvm -cpu host,hv-synic,x-hv-synic-kvm-only=on

QEMU crashes in hyperv_synic_reset() trying to access the non-present
qobject for SynIC.

Add the missing check for NULL.

Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reported-by: Igor Mammedov <imammedo@redhat.com>
Fixes: 9b4cf107b09d18ac30f46fd1c4de8585ccba030c
Fixes: 4a93722f9c279184e95b1e1ad775c01deec05065
Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
---
 hw/hyperv/hyperv.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
index a28e7249d8..8758635227 100644
--- a/hw/hyperv/hyperv.c
+++ b/hw/hyperv/hyperv.c
@@ -136,7 +136,11 @@ void hyperv_synic_add(CPUState *cs)
 
 void hyperv_synic_reset(CPUState *cs)
 {
-    device_reset(DEVICE(get_synic(cs)));
+    SynICState *synic = get_synic(cs);
+
+    if (synic) {
+        device_reset(DEVICE(synic));
+    }
 }
 
 static const TypeInfo synic_type_info = {
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/hyperv: fix NULL dereference with pure-kvm SynIC
  2018-11-26 15:28 [Qemu-devel] [PATCH] hw/hyperv: fix NULL dereference with pure-kvm SynIC Roman Kagan
@ 2018-11-26 16:04 ` Philippe Mathieu-Daudé
  2018-11-26 17:13 ` Paolo Bonzini
  1 sibling, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-26 16:04 UTC (permalink / raw)
  To: Roman Kagan, qemu-devel, Igor Mammedov, Vitaly Kuznetsov,
	Eduardo Habkost, Paolo Bonzini

On 26/11/18 16:28, Roman Kagan wrote:
> When started in compat configuration of SynIC, e.g.
> 
> qemu-system-x86_64 -machine pc-i440fx-2.10,accel=kvm \
>  -cpu host,-vmx,hv-relaxed,hv_spinlocks=0x1fff,hv-vpindex,hv-synic
> 
> or explicitly
> 
> qemu-system-x86_64 -enable-kvm -cpu host,hv-synic,x-hv-synic-kvm-only=on
> 
> QEMU crashes in hyperv_synic_reset() trying to access the non-present
> qobject for SynIC.
> 
> Add the missing check for NULL.
> 
> Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> Reported-by: Igor Mammedov <imammedo@redhat.com>
> Fixes: 9b4cf107b09d18ac30f46fd1c4de8585ccba030c
> Fixes: 4a93722f9c279184e95b1e1ad775c01deec05065
> Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>  hw/hyperv/hyperv.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
> index a28e7249d8..8758635227 100644
> --- a/hw/hyperv/hyperv.c
> +++ b/hw/hyperv/hyperv.c
> @@ -136,7 +136,11 @@ void hyperv_synic_add(CPUState *cs)
>  
>  void hyperv_synic_reset(CPUState *cs)
>  {
> -    device_reset(DEVICE(get_synic(cs)));
> +    SynICState *synic = get_synic(cs);
> +
> +    if (synic) {
> +        device_reset(DEVICE(synic));
> +    }
>  }
>  
>  static const TypeInfo synic_type_info = {
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/hyperv: fix NULL dereference with pure-kvm SynIC
  2018-11-26 15:28 [Qemu-devel] [PATCH] hw/hyperv: fix NULL dereference with pure-kvm SynIC Roman Kagan
  2018-11-26 16:04 ` Philippe Mathieu-Daudé
@ 2018-11-26 17:13 ` Paolo Bonzini
  2018-11-26 21:00   ` Eduardo Habkost
  1 sibling, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2018-11-26 17:13 UTC (permalink / raw)
  To: Roman Kagan, qemu-devel, Igor Mammedov, Vitaly Kuznetsov,
	Eduardo Habkost

On 26/11/18 16:28, Roman Kagan wrote:
> When started in compat configuration of SynIC, e.g.
> 
> qemu-system-x86_64 -machine pc-i440fx-2.10,accel=kvm \
>  -cpu host,-vmx,hv-relaxed,hv_spinlocks=0x1fff,hv-vpindex,hv-synic
> 
> or explicitly
> 
> qemu-system-x86_64 -enable-kvm -cpu host,hv-synic,x-hv-synic-kvm-only=on
> 
> QEMU crashes in hyperv_synic_reset() trying to access the non-present
> qobject for SynIC.
> 
> Add the missing check for NULL.
> 
> Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> Reported-by: Igor Mammedov <imammedo@redhat.com>
> Fixes: 9b4cf107b09d18ac30f46fd1c4de8585ccba030c
> Fixes: 4a93722f9c279184e95b1e1ad775c01deec05065
> Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
> ---
>  hw/hyperv/hyperv.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
> index a28e7249d8..8758635227 100644
> --- a/hw/hyperv/hyperv.c
> +++ b/hw/hyperv/hyperv.c
> @@ -136,7 +136,11 @@ void hyperv_synic_add(CPUState *cs)
>  
>  void hyperv_synic_reset(CPUState *cs)
>  {
> -    device_reset(DEVICE(get_synic(cs)));
> +    SynICState *synic = get_synic(cs);
> +
> +    if (synic) {
> +        device_reset(DEVICE(synic));
> +    }
>  }
>  
>  static const TypeInfo synic_type_info = {
> 

Queued, thanks.

Paolo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/hyperv: fix NULL dereference with pure-kvm SynIC
  2018-11-26 17:13 ` Paolo Bonzini
@ 2018-11-26 21:00   ` Eduardo Habkost
  2018-11-27  9:02     ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Eduardo Habkost @ 2018-11-26 21:00 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Roman Kagan, qemu-devel, Igor Mammedov, Vitaly Kuznetsov

On Mon, Nov 26, 2018 at 06:13:49PM +0100, Paolo Bonzini wrote:
> On 26/11/18 16:28, Roman Kagan wrote:
> > When started in compat configuration of SynIC, e.g.
> > 
> > qemu-system-x86_64 -machine pc-i440fx-2.10,accel=kvm \
> >  -cpu host,-vmx,hv-relaxed,hv_spinlocks=0x1fff,hv-vpindex,hv-synic
> > 
> > or explicitly
> > 
> > qemu-system-x86_64 -enable-kvm -cpu host,hv-synic,x-hv-synic-kvm-only=on
> > 
> > QEMU crashes in hyperv_synic_reset() trying to access the non-present
> > qobject for SynIC.
> > 
> > Add the missing check for NULL.
> > 
> > Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> > Reported-by: Igor Mammedov <imammedo@redhat.com>
> > Fixes: 9b4cf107b09d18ac30f46fd1c4de8585ccba030c
> > Fixes: 4a93722f9c279184e95b1e1ad775c01deec05065
> > Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
> > ---
> >  hw/hyperv/hyperv.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
> > index a28e7249d8..8758635227 100644
> > --- a/hw/hyperv/hyperv.c
> > +++ b/hw/hyperv/hyperv.c
> > @@ -136,7 +136,11 @@ void hyperv_synic_add(CPUState *cs)
> >  
> >  void hyperv_synic_reset(CPUState *cs)
> >  {
> > -    device_reset(DEVICE(get_synic(cs)));
> > +    SynICState *synic = get_synic(cs);
> > +
> > +    if (synic) {
> > +        device_reset(DEVICE(synic));
> > +    }
> >  }
> >  
> >  static const TypeInfo synic_type_info = {
> > 
> 
> Queued, thanks.

Oops, I had queued it earlier today and just submitted a pull
request.

-- 
Eduardo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/hyperv: fix NULL dereference with pure-kvm SynIC
  2018-11-26 21:00   ` Eduardo Habkost
@ 2018-11-27  9:02     ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2018-11-27  9:02 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: Roman Kagan, qemu-devel, Igor Mammedov, Vitaly Kuznetsov

On 26/11/18 22:00, Eduardo Habkost wrote:
> On Mon, Nov 26, 2018 at 06:13:49PM +0100, Paolo Bonzini wrote:
>> On 26/11/18 16:28, Roman Kagan wrote:
>>> When started in compat configuration of SynIC, e.g.
>>>
>>> qemu-system-x86_64 -machine pc-i440fx-2.10,accel=kvm \
>>>  -cpu host,-vmx,hv-relaxed,hv_spinlocks=0x1fff,hv-vpindex,hv-synic
>>>
>>> or explicitly
>>>
>>> qemu-system-x86_64 -enable-kvm -cpu host,hv-synic,x-hv-synic-kvm-only=on
>>>
>>> QEMU crashes in hyperv_synic_reset() trying to access the non-present
>>> qobject for SynIC.
>>>
>>> Add the missing check for NULL.
>>>
>>> Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>>> Reported-by: Igor Mammedov <imammedo@redhat.com>
>>> Fixes: 9b4cf107b09d18ac30f46fd1c4de8585ccba030c
>>> Fixes: 4a93722f9c279184e95b1e1ad775c01deec05065
>>> Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
>>> ---
>>>  hw/hyperv/hyperv.c | 6 +++++-
>>>  1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c
>>> index a28e7249d8..8758635227 100644
>>> --- a/hw/hyperv/hyperv.c
>>> +++ b/hw/hyperv/hyperv.c
>>> @@ -136,7 +136,11 @@ void hyperv_synic_add(CPUState *cs)
>>>  
>>>  void hyperv_synic_reset(CPUState *cs)
>>>  {
>>> -    device_reset(DEVICE(get_synic(cs)));
>>> +    SynICState *synic = get_synic(cs);
>>> +
>>> +    if (synic) {
>>> +        device_reset(DEVICE(synic));
>>> +    }
>>>  }
>>>  
>>>  static const TypeInfo synic_type_info = {
>>>
>>
>> Queued, thanks.
> 
> Oops, I had queued it earlier today and just submitted a pull
> request.

No big deal, it will be included twice. :)

Paolo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-11-27  9:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-26 15:28 [Qemu-devel] [PATCH] hw/hyperv: fix NULL dereference with pure-kvm SynIC Roman Kagan
2018-11-26 16:04 ` Philippe Mathieu-Daudé
2018-11-26 17:13 ` Paolo Bonzini
2018-11-26 21:00   ` Eduardo Habkost
2018-11-27  9:02     ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.