From a307a706087debcf0cc02b7f641fc7e2fc33c0ce Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Sat, 1 Aug 2015 08:39:33 -0400 Subject: [PATCH 7/7] rtl8139: check TCP Data Offset field (CVE-2015-5165) RH-Author: Stefan Hajnoczi Message-id: <1438418373-7324-8-git-send-email-stefanha@redhat.com> Patchwork-id: 67264 O-Subject: [virt-devel] [RHEL-6.7.z qemu-kvm EMBARGOED PATCH 7/7] rtl8139: check TCP Data Offset field (CVE-2015-5165) Bugzilla: 1248761 RH-Acked-by: Dr. David Alan Gilbert RH-Acked-by: Xiao Wang RH-Acked-by: Laszlo Ersek The TCP Data Offset field contains the length of the header. Make sure it is valid and does not exceed the IP data length. Signed-off-by: Stefan Hajnoczi Signed-off-by: Jeff E. Nelson --- hw/rtl8139.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/rtl8139.c b/hw/rtl8139.c index 835b641..591047f 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -2232,6 +2232,11 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s) int tcp_hlen = TCP_HEADER_DATA_OFFSET(p_tcp_hdr); + /* Invalid TCP data offset? */ + if (tcp_hlen < sizeof(tcp_header) || tcp_hlen > ip_data_len) { + goto skip_offload; + } + /* ETH_MTU = ip header len + tcp header len + payload */ int tcp_data_len = ip_data_len - tcp_hlen; int tcp_chunk_size = ETH_MTU - hlen - tcp_hlen; -- 2.1.0