From: Stefan Hajnoczi Date: Wed, 15 Jul 2015 17:17:04 +0000 (+0100) Subject: rtl8139: check TCP Data Offset field X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;p=people%2Fandrewcoop%2Fqemu-traditional.git rtl8139: check TCP Data Offset field 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 [Backport to qemu-xen-tradition] Signed-off-by: Andrew Cooper --- diff --git a/hw/rtl8139.c b/hw/rtl8139.c index 0bb45832..2ca5a9b5 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -2193,6 +2193,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;