]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
rtl8139: check IP Total Length field
authorStefan Hajnoczi <stefanha@redhat.com>
Wed, 15 Jul 2015 17:17:02 +0000 (18:17 +0100)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Mon, 3 Aug 2015 14:04:40 +0000 (14:04 +0000)
The IP Total Length field includes the IP header and data.  Make sure it
is valid and does not exceed the Ethernet payload size.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
hw/net/rtl8139.c

index ec7258db8cd3a12f64407de255db15dc1389ff4b..d59c7e4ebe28321c84dd86977d7933791d6dafca 100644 (file)
@@ -2202,7 +2202,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)
             {