From patchwork Mon Aug 3 12:08:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 503136 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 403B31402DE for ; Mon, 3 Aug 2015 22:13:42 +1000 (AEST) Received: from localhost ([::1]:58947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMEce-000066-2R for incoming@patchwork.ozlabs.org; Mon, 03 Aug 2015 08:13:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMEY7-0002ag-1E for qemu-devel@nongnu.org; Mon, 03 Aug 2015 08:09:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMEY3-0008Sk-4U for qemu-devel@nongnu.org; Mon, 03 Aug 2015 08:08:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42333) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMEY2-0008SN-W2; Mon, 03 Aug 2015 08:08:55 -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 B16B7A2C1B; Mon, 3 Aug 2015 12:08:54 +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 t73C8rmG020959; Mon, 3 Aug 2015 08:08:54 -0400 From: Stefan Hajnoczi To: Date: Mon, 3 Aug 2015 13:08:40 +0100 Message-Id: <1438603721-28320-7-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 6/7] rtl8139: skip offload on short TCP header (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 TCP Large Segment Offload accesses the TCP header in the packet. If the packet is too short we must not attempt to access header fields: tcp_header *p_tcp_hdr = (tcp_header*)(eth_payload_data + hlen); int tcp_hlen = TCP_HEADER_DATA_OFFSET(p_tcp_hdr); Reported-by: 朱东海(启路) Reviewed-by: Jason Wang Signed-off-by: Stefan Hajnoczi --- hw/net/rtl8139.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index 6859d76..fa01934 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -2210,6 +2210,11 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s) if ((txdw0 & CP_TX_LGSEN) && ip_protocol == IP_PROTO_TCP) { + /* Large enough for the TCP header? */ + if (ip_data_len < sizeof(tcp_header)) { + goto skip_offload; + } + int large_send_mss = (txdw0 >> 16) & CP_TC_LGSEN_MSS_MASK; DPRINTF("+++ C+ mode offloaded task TSO MTU=%d IP data %d "