]> xenbits.xensource.com Git - qemu-xen-traditional.git/commitdiff
rtl8139: check IP Total Length field
authorStefan Hajnoczi <stefanha@redhat.com>
Wed, 15 Jul 2015 17:17:02 +0000 (18:17 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 10 May 2016 18:15:12 +0000 (19:15 +0100)
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>
[Backport to qemu-xen-tradition]
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
hw/rtl8139.c

index b71ea62a4ade136b8be559d45b7355d48b249e8b..d49d6fa6028cb9763e0d70cd78499234bca73095 100644 (file)
@@ -2144,7 +2144,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)
             {