Received: from eggs.gnu.org ([208.118.235.92]:39903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCsMu-0005BX-5T for qemu-devel@nongnu.org; Wed, 28 Mar 2012 08:53:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCsMn-0007ma-Su for qemu-devel@nongnu.org; Wed, 28 Mar 2012 08:52:51 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 28 Mar 2012 14:52:08 +0200 Message-Id: <1332939159-16434-6-git-send-email-afaerber@suse.de> In-Reply-To: <1332939159-16434-1-git-send-email-afaerber@suse.de> References: <1332939159-16434-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH stable-0.15 05/36] e1000: bounds packet size against buffer size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , kvm@suse.de, qemu-stable@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= , Bruce Rogers From: Anthony Liguori Otherwise we can write beyond the buffer and corrupt memory. This is tra= cked as CVE-2012-0029. Signed-off-by: Anthony Liguori (cherry picked from commit 65f82df0d7a71ce1b10cd4c5ab08888d176ac840) Signed-off-by: Bruce Rogers [AF: stable-0.15 does not have pci_dma_read(). Fixes BNC#740165.] Signed-off-by: Andreas F=C3=A4rber --- hw/e1000.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index 7971457..c91790b 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -472,6 +472,8 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *= dp) bytes =3D split_size; if (tp->size + bytes > msh) bytes =3D msh - tp->size; + + bytes =3D MIN(sizeof(tp->data) - tp->size, bytes); cpu_physical_memory_read(addr, tp->data + tp->size, bytes); if ((sz =3D tp->size + bytes) >=3D hdr && tp->size < hdr) memmove(tp->header, tp->data, hdr); @@ -487,6 +489,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 =3D MIN(sizeof(tp->data) - tp->size, split_size); cpu_physical_memory_read(addr, tp->data + tp->size, split_size); tp->size +=3D split_size; } --=20 1.7.7