]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
net: vmxnet: check IP header length
authorLi Qiang <liqiang6-s@360.cn>
Tue, 9 Aug 2016 11:19:47 +0000 (16:49 +0530)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Thu, 8 Sep 2016 20:23:02 +0000 (15:23 -0500)
Vmxnet3 device emulator when parsing packet headers does not check
for IP header length. It could lead to a OOB access when reading
further packet data. Add check to avoid it.

Reported-by: Li Qiang <liqiang6-s@360.cn>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Reviewed-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/net/vmxnet_tx_pkt.c

index f4d0f5f15a91f90b5aa0f4555d3537589c0c4500..5ba2f5ea6c75f94500cb50dc62bf1406b5ac060f 100644 (file)
@@ -178,6 +178,11 @@ static bool vmxnet_tx_pkt_parse_headers(struct VmxnetTxPkt *pkt)
         }
 
         l3_hdr->iov_len = IP_HDR_GET_LEN(l3_hdr->iov_base);
+        if(l3_hdr->iov_len < sizeof(struct ip_header))
+        {
+            l3_hdr->iov_len = 0;
+            return false;
+        }
         pkt->l4proto = ((struct ip_header *) l3_hdr->iov_base)->ip_p;
 
         /* copy optional IPv4 header data */