pc: fix possible NULL pointer dereference in pc_machine_get_device_memory_region_size()
PATCH v2 1/1 pc: fix possible NULL pointer dereference in pc_machine_get_device_memory_region_size()
QEMU will crash when device-memory-region-size property is read if ms->device_memory wasn't initialized yet.
Crash can be reproduced with:
$QEMU -preconfig -qmp unix:qmp_socket,server,nowait & ./scripts/qmp/qom-get -s qmp_socket /machine.device-memory-region-size
Instead of crashing return 0 if ms->device_memory hasn't been initialized.
---
v2:
* fix missing return value assignment
(Eduardo Habkost <[email protected]>)
--- hw/i386/pc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
hw/i386/pc.c +5 -1
@@ -2458,7 +2458,11 @@ pc_machine_get_device_memory_region_size(Object *obj, Visitor *v, Error **errp) {MachineState *ms =MACHINE (obj); -int64_t value =memory_region_size (&ms->device_memory->mr); +int64_t value =0 ; + +if (ms->device_memory) { + value =memory_region_size (&ms->device_memory->mr); + }visit_type_int (v, name, &value, errp); }
Signature · 1 line
2.18.1
Quoted 10 lines · Igor Mammedov
QEMU will crash when device-memory-region-size property is read if
ms->device_memorywasn't initialized yet.Crash can be reproduced with:
$QEMU -preconfig -qmp unix:qmp_socket,server,nowait &./scripts/qmp/qom-get-sqmp_socket/machine.device-memory-region-sizeInstead of crashing return 0 if
ms->device_memoryhasn't been initialized.Signed-off-by Igor Mammedov <[email protected]>
Quoted 27 lines
---
v2:
* fix missing return value assignment
(Eduardo Habkost <[email protected]>)--- hw/i386/pc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)hw/i386/pc.c +5
-1@@ -2458,7 +2458,11 @@ pc_machine_get_device_memory_region_size(Object *obj, Visitor *v, Error **errp) {MachineState *ms =MACHINE (obj); -int64_t value =memory_region_size (&ms->device_memory->mr); +int64_t value =0 ; + +if (ms->device_memory) { + value =memory_region_size (&ms->device_memory->mr); + }visit_type_int (v, name, &value, errp); }
Michael S. Tsirkin
AppliedQuoted 10 lines · Igor Mammedov
QEMU will crash when device-memory-region-size property is read if
ms->device_memorywasn't initialized yet.Crash can be reproduced with:
$QEMU -preconfig -qmp unix:qmp_socket,server,nowait &./scripts/qmp/qom-get-sqmp_socket/machine.device-memory-region-sizeInstead of crashing return 0 if
ms->device_memoryhasn't been initialized.Signed-off-by Igor Mammedov <[email protected]>
queued, thanks!
Quoted 28 lines
---
v2:
* fix missing return value assignment
(Eduardo Habkost <[email protected]>)--- hw/i386/pc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)hw/i386/pc.c +5
-1@@ -2458,7 +2458,11 @@ pc_machine_get_device_memory_region_size(Object *obj, Visitor *v, Error **errp) {MachineState *ms =MACHINE (obj); -int64_t value =memory_region_size (&ms->device_memory->mr); +int64_t value =0 ; + +if (ms->device_memory) { + value =memory_region_size (&ms->device_memory->mr); + }visit_type_int (v, name, &value, errp); }Signature · 1 line
2.18.1
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Igor Mammedov
QEMU will crash when device-memory-region-size property is read if
ms->device_memorywasn't initialized yet.Crash can be reproduced with:
$QEMU -preconfig -qmp unix:qmp_socket,server,nowait &./scripts/qmp/qom-get-sqmp_socket/machine.device-memory-region-size
Quoted 5 lines
Quoted 3 lines
Instead of crashing return 0 if
ms->device_memoryhasn't been initialized.Signed-off-by Igor Mammedov <[email protected]>queued, thanks!
This is already commit 58164eaff530a1e804f5710936dd37518ab5a90e.
Paolo
Quoted 11 lines · Paolo Bonzini
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · Igor Mammedov
QEMU will crash when device-memory-region-size property is read if
ms->device_memorywasn't initialized yet.Crash can be reproduced with:
$QEMU -preconfig -qmp unix:qmp_socket,server,nowait &./scripts/qmp/qom-get-sqmp_socket/machine.device-memory-region-sizeInstead of crashing return 0 if
ms->device_memoryhasn't been initialized.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Igor Mammedov <[email protected]>queued, thanks!
This is already commit
58164eaff530a1e804f5710936dd37518ab5a90e.Paolo
In fact yes, git am just silently ignores a patch. Donnu why did it not get dropped from the review inbox, weird.
Thanks!
Signature · 1 line
MST