Skip to contentSkip to conversation

net: vmxnet3: check for device_active before write

PATCH Applied P J P 3 participants 3 messages Aug 8, 2016 – Aug 9, 2016

lore
Share & tools
lore

P J P

author
#0 lore raw

PATCH 1/1 net: vmxnet3: check for device_active before write

From: Li Qiang <[email protected]>

Vmxnet3 device emulator does not check if the device is active, before using it for write. It leads to a use after free issue, if the vmxnet3_io_bar0_write routine is called after the device is deactivated. Add check to avoid it.

---
 hw/net/vmxnet3.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/net/vmxnet3.c +4 -0
index bbf44ad..90f6943 100644
@@ -1167,6 +1167,10 @@ vmxnet3_io_bar0_write(void *opaque, hwaddr addr,
 {
     VMXNET3State *s = opaque;
 
+    if (!s->device_active) {
+        return;
+    }
+
     if (VMW_IS_MULTIREG_ADDR(addr, VMXNET3_REG_TXPROD,
                         VMXNET3_DEVICE_MAX_TX_QUEUES, VMXNET3_REG_ALIGN)) {
         int tx_queue_idx =
Signature · 1 line
2.5.5
Acked-by on v1 1/1
#1 lore raw
Quoted 33 lines · P J P

From: Li Qiang <[email protected]>

Vmxnet3 device emulator does not check if the device is active, before using it for write. It leads to a use after free issue, if the vmxnet3_io_bar0_write routine is called after the device is deactivated. Add check to avoid it.

---
hw/net/vmxnet3.c | 4 ++++

1 file changed, 4 insertions(+)
hw/net/vmxnet3.c +4 -0
index bbf44ad..90f6943 100644
@@ -1167,6 +1167,10 @@ vmxnet3_io_bar0_write(void *opaque, hwaddr addr,
 {
    VMXNET3State *s = opaque;
 
+    if (!s->device_active) {
+        return;
+    }
+
    if (VMW_IS_MULTIREG_ADDR(addr, VMXNET3_REG_TXPROD,
                        VMXNET3_DEVICE_MAX_TX_QUEUES, VMXNET3_REG_ALIGN)) {
        int tx_queue_idx =
Signature · 1 line
2.5.5
Applied
#2 lore raw
Quoted 25 lines · Dmitry Fleytman
Quoted 23 lines · P J P

From: Li Qiang <[email protected]>

Vmxnet3 device emulator does not check if the device is active, before using it for write. It leads to a use after free issue, if the vmxnet3_io_bar0_write routine is called after the device is deactivated. Add check to avoid it.

---
hw/net/vmxnet3.c | 4 ++++

1 file changed, 4 insertions(+)
hw/net/vmxnet3.c +0 -0
index bbf44ad..90f6943 100644
@@ -1167,6 +1167,10 @@ vmxnet3_io_bar0_write(void *opaque, hwaddr addr,
 {
     VMXNET3State *s = opaque;
 
Quoted 10 lines
Quoted 10 lines
hw/net/vmxnet3.c +4 -0
+    if (!s->device_active) {
+        return;
+    }
+
     if (VMW_IS_MULTIREG_ADDR(addr, VMXNET3_REG_TXPROD,
                         VMXNET3_DEVICE_MAX_TX_QUEUES, VMXNET3_REG_ALIGN)) {
         int tx_queue_idx =
Signature · 1 line
2.5.5

Applied, thanks.