From patchwork Mon Aug 3 12:08:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 503133 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 222381402D5 for ; Mon, 3 Aug 2015 22:09:44 +1000 (AEST) Received: from localhost ([::1]:58901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMEYo-0003ZC-30 for incoming@patchwork.ozlabs.org; Mon, 03 Aug 2015 08:09:42 -0400 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 Received: from mx1.redhat.com ([209.132.183.28]:40385) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMEY1-0008Pn-9q; Mon, 03 Aug 2015 08:08:53 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 0D05C8E91B; Mon, 3 Aug 2015 12:08:53 +0000 (UTC) Received: from localhost (ovpn-112-75.ams2.redhat.com [10.36.112.75]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t73C8pAC020953; Mon, 3 Aug 2015 08:08:52 -0400 From: Stefan Hajnoczi To: 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 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Jason Wang , qemu-stable@nongnu.org, Stefan Hajnoczi Subject: [Qemu-devel] [PULL for-2.4 5/7] rtl8139: check IP Total Length field (CVE-2015-5165) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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: 朱东海(启路) 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) } ip_protocol = ip->ip_p; - ip_data_len = be16_to_cpu(ip->ip_len) - hlen; + + ip_data_len = be16_to_cpu(ip->ip_len); + if (ip_data_len < hlen || ip_data_len > eth_payload_len) { + goto skip_offload; + } + ip_data_len -= hlen; if (txdw0 & CP_TX_IPCS) {