aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-01-23 07:30:43 -0600
committerJustin M. Forbes <jforbes@redhat.com>2012-01-23 15:07:00 -0600
commitd0ed2d2e8e863a9a64c9fc9c08fa68bee546ad00 (patch)
tree775f3e3204a459ed0c84ef081a3357cfe483b043
parent85a4ca797dbe25f27df0a66aa4df1cab63245cd3 (diff)
e1000: bounds packet size against buffer size
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>
-rw-r--r--hw/e1000.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/e1000.c b/hw/e1000.c
index 986ed9cf7..e164d79b8 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -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;
}