]> xenbits.xensource.com Git - qemu-xen-4.0-testing.git/commitdiff
e1000: bounds packet size against buffer size xen-4.0.4 xen-4.0.4-rc1 xen-4.0.4-rc2 xen-4.0.4-rc3
authorIan Campbell <Ian.Campbell@citrix.com>
Thu, 2 Feb 2012 13:47:06 +0000 (13:47 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 2 Feb 2012 13:59:07 +0000 (13:59 +0000)
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>
(Backported from qemu upstream 65f82df0d7a71ce1b10cd4c5ab08888d176ac840
 by Ian Campbell.)

Signed-off-by: Ian Campbell <Ian.Campbell@citrix.com>
(cherry picked from commit ebe37b2a3f844bad02dcc30d081f39eda06118f8)

hw/e1000.c

index 1644201d6ee6625e909a5f509a5cb40af0c3930b..e77c81e16bd5445dd906f7b63683c1528068b31a 100644 (file)
@@ -432,6 +432,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);
             cpu_physical_memory_read(addr, tp->data + tp->size, bytes);
             if ((sz = tp->size + bytes) >= hdr && tp->size < hdr)
                 memmove(tp->header, tp->data, hdr);
@@ -447,6 +449,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);
         cpu_physical_memory_read(addr, tp->data + tp->size, split_size);
         tp->size += split_size;
     }