Skip to contentSkip to conversation

vmw_pvscsi: check message ring page count at initialisation

PATCH In review P J P 3 participants 4 messages Apr 25, 2017 – Apr 27, 2017

lore
Share & tools
lore

P J P

author
#0 lore raw

PATCH 1/1 vmw_pvscsi: check message ring page count at initialisation

Vmware Paravirtual SCSI emulation uses command descriptors to process SCSI commands. These come with their message ring buffers. A guest could set the message ring page count to an arbitrary value resulting in infinite loop. Add check to avoid it.

---
 hw/scsi/vmw_pvscsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/vmw_pvscsi.c +1 -1
index 7557546..4a106da 100644
@@ -202,7 +202,7 @@ pvscsi_ring_init_msg(PVSCSIRingInfo *m, PVSCSICmdDescSetupMsgRing *ri)
     uint32_t len_log2;
     uint32_t ring_size;
 
-    if (ri->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) {
+    if (!ri->numPages || ri->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) {
         return -1;
     }
     ring_size = ri->numPages * PVSCSI_MAX_NUM_MSG_ENTRIES_PER_PAGE;
Signature · 1 line
2.9.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · P J P

Vmware Paravirtual SCSI emulation uses command descriptors to process SCSI commands. These come with their message ring buffers. A guest could set the message ring page count to an arbitrary value resulting in infinite loop. Add check to avoid it.

Hello P J P,

Except the commit message that does not exactly correspond to what this patch does,

Thanks for the patch,
Dmitry.

Quoted 23 lines

---
hw/scsi/vmw_pvscsi.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/vmw_pvscsi.c +1 -1
index 7557546..4a106da 100644
@@ -202,7 +202,7 @@ pvscsi_ring_init_msg(PVSCSIRingInfo *m, PVSCSICmdDescSetupMsgRing *ri)
    uint32_t len_log2;
    uint32_t ring_size;
 
-    if (ri->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) {
+    if (!ri->numPages || ri->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) {
        return -1;
    }
    ring_size = ri->numPages * PVSCSI_MAX_NUM_MSG_ENTRIES_PER_PAGE;
Signature · 1 line
2.9.3
author
#3 lore raw
+-- On Thu, 27 Apr 2017, Paolo Bonzini wrote --+
| On 25/04/2017 17:52, Dmitry Fleytman wrote:
| > Except the commit message that does not exactly correspond to what this
| > patch does,
| > Reviewed-by: Dmitry Fleytman <[email protected] <mailto:[email protected]>>
| 
| Adjusted the commit message and queued.

Thank you.
--
- P J P
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F