hw/hyperv: fix NULL dereference with pure-kvm SynIC
PATCH 1/1 hw/hyperv: fix NULL dereference with pure-kvm SynIC
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.
--- hw/hyperv/hyperv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
hw/hyperv/hyperv.c +5 -1
@@ -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 = {
Signature · 1 line
2.19.1
Quoted 12 lines · Roman Kagan
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-synicor 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.
Quoted 7 lines
Add the missing check for NULL.
Reported-by Vitaly Kuznetsov <[email protected]>Reported-by Igor Mammedov <[email protected]>Fixes 9b4cf107b09d18ac30f46fd1c4de8585ccba030cFixes 4a93722f9c279184e95b1e1ad775c01deec05065Signed-off-by Roman Kagan <[email protected]>
Quoted 22 lines
--- hw/hyperv/hyperv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)hw/hyperv/hyperv.c +5
-1@@ -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 = {
Paolo Bonzini
AppliedQuoted 31 lines · Roman Kagan
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-synicor 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 <[email protected]>Reported-by Igor Mammedov <[email protected]>Fixes 9b4cf107b09d18ac30f46fd1c4de8585ccba030cFixes 4a93722f9c279184e95b1e1ad775c01deec05065Signed-off-by Roman Kagan <[email protected]>--- hw/hyperv/hyperv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)hw/hyperv/hyperv.c +0
-0@@ -136,7 +136,11 @@ void hyperv_synic_add(CPUState *cs)void hyperv_synic_reset (CPUState *cs)
hw/hyperv/hyperv.c void hyperv_synic_add(CPUState *cs) · line 146
Quoted 10 lines
hw/hyperv/hyperv.c +5
-1{ -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
Quoted 40 lines · Paolo Bonzini
Quoted 39 lines · Roman Kagan
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-synicor 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 <[email protected]>Reported-by Igor Mammedov <[email protected]>Fixes 9b4cf107b09d18ac30f46fd1c4de8585ccba030cFixes 4a93722f9c279184e95b1e1ad775c01deec05065Signed-off-by Roman Kagan <[email protected]>--- hw/hyperv/hyperv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)hw/hyperv/hyperv.c +5
-1@@ -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)); + } }
Quoted 4 lines
hw/hyperv/hyperv.c void hyperv_synic_add(CPUState *cs) · line 146
Quoted 2 lines
hw/hyperv/hyperv.c +0
-0static const TypeInfo synic_type_info = {Queued, thanks.
Oops, I had queued it earlier today and just submitted a pull request.
Signature · 1 line
Eduardo
Quoted 41 lines · Eduardo Habkost
Quoted 40 lines · Paolo Bonzini
Quoted 39 lines · Roman Kagan
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-synicor 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 <[email protected]>Reported-by Igor Mammedov <[email protected]>Fixes 9b4cf107b09d18ac30f46fd1c4de8585ccba030cFixes 4a93722f9c279184e95b1e1ad775c01deec05065Signed-off-by Roman Kagan <[email protected]>--- hw/hyperv/hyperv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)hw/hyperv/hyperv.c +5
-1@@ -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)); + } }
Quoted 7 lines
Quoted 4 lines
hw/hyperv/hyperv.c void hyperv_synic_add(CPUState *cs) · line 146
Quoted 2 lines
hw/hyperv/hyperv.c +0
-0static 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