]> git.proxmox.com Git - qemu.git/commitdiff
e1000: bounds packet size against buffer size
authorAnthony Liguori <aliguori@us.ibm.com>
Mon, 23 Jan 2012 13:30:43 +0000 (07:30 -0600)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 23 Jan 2012 13:30:43 +0000 (07:30 -0600)
Otherwise we can write beyond the buffer and corrupt memory.  This is tracked
as CVE-2012-0029.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/e1000.c

index a29c944df412344f83540d4ac1a4b328d331ea3f..86c5416bd1290cdfc44fd23e1e7ed11200975b48 100644 (file)
@@ -466,6 +466,8 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
             bytes = split_size;
             if (tp->size + bytes > msh)
                 bytes = msh - tp->size;
+
+            bytes = MIN(sizeof(tp->data) - tp->size, bytes);
             pci_dma_read(&s->dev, addr, tp->data + tp->size, bytes);
             if ((sz = tp->size + bytes) >= hdr && tp->size < hdr)
                 memmove(tp->header, tp->data, hdr);
@@ -481,6 +483,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
         // context descriptor TSE is not set, while data descriptor TSE is set
         DBGOUT(TXERR, "TCP segmentaion Error\n");
     } else {
+        split_size = MIN(sizeof(tp->data) - tp->size, split_size);
         pci_dma_read(&s->dev, addr, tp->data + tp->size, split_size);
         tp->size += split_size;
     }