net: vmxnet3: check for device_active before write
authorLi Qiang <liqiang6-s@360.cn>
Mon, 8 Aug 2016 12:38:31 +0000 (18:08 +0530)
committerJason Wang <jasowang@redhat.com>
Tue, 9 Aug 2016 07:24:56 +0000 (15:24 +0800)
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.

Reported-by: Li Qiang <liqiang6-s@360.cn>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Acked-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
hw/net/vmxnet3.c

index bbf44adbcc54fb5ba0c041a259e06978116397b1..90f69436687167907a4e927e1429702c543ec2d2 100644 (file)
@@ -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 =