From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMEY5-0002Wf-DA for qemu-devel@nongnu.org; Mon, 03 Aug 2015 08:09:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMEY1-0008QF-Eb for qemu-devel@nongnu.org; Mon, 03 Aug 2015 08:08:57 -0400 From: Stefan Hajnoczi Date: Mon, 3 Aug 2015 13:08:39 +0100 Message-Id: <1438603721-28320-6-git-send-email-stefanha@redhat.com> In-Reply-To: <1438603721-28320-1-git-send-email-stefanha@redhat.com> References: <1438603721-28320-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL for-2.4 5/7] rtl8139: check IP Total Length field (CVE-2015-5165) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Jason Wang , qemu-stable@nongnu.org, Stefan Hajnoczi The IP Total Length field includes the IP header and data. Make sure it is valid and does not exceed the Ethernet payload size. Reported-by: =E6=9C=B1=E4=B8=9C=E6=B5=B7(=E5=90=AF=E8=B7=AF) Reviewed-by: Jason Wang Signed-off-by: Stefan Hajnoczi --- hw/net/rtl8139.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index 4eaa352..6859d76 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -2191,7 +2191,12 @@ static int rtl8139_cplus_transmit_one(RTL8139State= *s) } =20 ip_protocol =3D ip->ip_p; - ip_data_len =3D be16_to_cpu(ip->ip_len) - hlen; + + ip_data_len =3D be16_to_cpu(ip->ip_len); + if (ip_data_len < hlen || ip_data_len > eth_payload_len) { + goto skip_offload; + } + ip_data_len -=3D hlen; =20 if (txdw0 & CP_TX_IPCS) { --=20 2.4.3