cd9d161
From 078c531e6b57f36359b74ea6c136c2ea1b5a9891 Mon Sep 17 00:00:00 2001
cd9d161
From: Anthony Liguori <aliguori@us.ibm.com>
cd9d161
Date: Mon, 23 Jan 2012 07:30:43 -0600
cd9d161
Subject: [PATCH] e1000: bounds packet size against buffer size
cd9d161
MIME-Version: 1.0
cd9d161
Content-Type: text/plain; charset=UTF-8
cd9d161
Content-Transfer-Encoding: 8bit
cd9d161
cd9d161
Otherwise we can write beyond the buffer and corrupt memory.  This is tracked
cd9d161
as CVE-2012-0029.
cd9d161
cd9d161
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
cd9d161
(cherry picked from commit 65f82df0d7a71ce1b10cd4c5ab08888d176ac840)
cd9d161
cd9d161
Signed-off-by: Bruce Rogers <brogers@suse.com>
cd9d161
[AF: stable-0.15 does not have pci_dma_read(). Fixes BNC#740165.]
cd9d161
Signed-off-by: Andreas Färber <afaerber@suse.de>
cd9d161
---
cd9d161
 hw/e1000.c | 3 +++
cd9d161
 1 file changed, 3 insertions(+)
cd9d161
cd9d161
diff --git a/hw/e1000.c b/hw/e1000.c
cd9d161
index 7971457..c91790b 100644
cd9d161
--- a/hw/e1000.c
cd9d161
+++ b/hw/e1000.c
cd9d161
@@ -472,6 +472,8 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
cd9d161
             bytes = split_size;
cd9d161
             if (tp->size + bytes > msh)
cd9d161
                 bytes = msh - tp->size;
cd9d161
+
cd9d161
+            bytes = MIN(sizeof(tp->data) - tp->size, bytes);
cd9d161
             cpu_physical_memory_read(addr, tp->data + tp->size, bytes);
cd9d161
             if ((sz = tp->size + bytes) >= hdr && tp->size < hdr)
cd9d161
                 memmove(tp->header, tp->data, hdr);
cd9d161
@@ -487,6 +489,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
cd9d161
         // context descriptor TSE is not set, while data descriptor TSE is set
cd9d161
         DBGOUT(TXERR, "TCP segmentaion Error\n");
cd9d161
     } else {
cd9d161
+        split_size = MIN(sizeof(tp->data) - tp->size, split_size);
cd9d161
         cpu_physical_memory_read(addr, tp->data + tp->size, split_size);
cd9d161
         tp->size += split_size;
cd9d161
     }
cd9d161
-- 
cd9d161
1.7.11.2
cd9d161