File kvm-qemu-preXX-e1000-check-for-overflow-whenever-issuing-PCI-dma-reads.patch of Package kvm.853

From 7fff7710abc9893d8dce5dbad1e7093caf521132 Mon Sep 17 00:00:00 2001
From: Anthony Liguori <aliguori@us.ibm.com>
Date: Wed, 4 Jan 2012 14:50:45 -0600
Subject: e1000: check for overflow whenever issuing PCI dma reads

Reported-by: Nicolae Mogoreanu <mogo@google.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 hw/e1000.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

Index: qemu-kvm-0.12.5/hw/e1000.c
===================================================================
--- qemu-kvm-0.12.5.orig/hw/e1000.c
+++ qemu-kvm-0.12.5/hw/e1000.c
@@ -456,6 +456,7 @@ process_tx_desc(E1000State *s, struct e1
             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);
@@ -471,6 +472,7 @@ process_tx_desc(E1000State *s, struct e1
         // 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;
     }