summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2015-07-15 17:36:15 +0100
committerMichael Roth <mdroth@linux.vnet.ibm.com>2015-08-04 12:33:54 -0500
commitf4c861fd68838649e81e0f9a6d75b154fda76440 (patch)
treef6cc53fe7444eff370994332ac8b83f0445961a3
parentb7a197c39e4b2099f25d2137e8d73c53c37b92c6 (diff)
downloadqemu-f4c861fd68838649e81e0f9a6d75b154fda76440.tar.gz
rtl8139: skip offload on short TCP header (CVE-2015-5165)
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: 朱东海(启路) <donghai.zdh@alibaba-inc.com> Reviewed-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> (cherry picked from commit 4240be45632db7831129f124bcf53c1223825b0f) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--hw/net/rtl8139.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index c88bf9b311..efde7b441f 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 "