From: Ian Campbell Date: Thu, 2 Feb 2012 13:47:06 +0000 (+0000) Subject: e1000: bounds packet size against buffer size X-Git-Tag: xen-4.2.0-rc1~20 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=ebe37b2a3f844bad02dcc30d081f39eda06118f8;p=qemu-xen-4.4-testing.git 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 (Backported from qemu upstream 65f82df0d7a71ce1b10cd4c5ab08888d176ac840 by Ian Campbell.) Signed-off-by: Ian Campbell --- diff --git a/hw/e1000.c b/hw/e1000.c index bb3689e7b..97104edaf 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -444,6 +444,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); @@ -459,6 +461,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; }