From: Ouyang Changchun Date: Wed, 5 Nov 2014 07:10:35 +0000 (+0800) Subject: examples/vhost: check offset with vlan X-Git-Tag: spdx-start~10185 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=6630bc42449aebba33b0817ae830cbdf3a83a1b6;p=dpdk.git examples/vhost: check offset with vlan This patch checks the packet length offset value, and checks if the extra bytes inside buffer cross page boundary. Signed-off-by: Changchun Ouyang Acked-by: Konstantin Ananyev --- diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 29163137c4..a93f7a01d7 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -1110,7 +1110,8 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) } if (vm2vm_mode == VM2VM_HARDWARE) { - if (find_local_dest(dev, m, &offset, &vlan_tag) != 0) { + if (find_local_dest(dev, m, &offset, &vlan_tag) != 0 || + offset > rte_pktmbuf_tailroom(m)) { rte_pktmbuf_free(m); return; } @@ -1896,7 +1897,9 @@ virtio_dev_tx_zcp(struct virtio_net *dev) /* Buffer address translation. */ buff_addr = gpa_to_vva(dev, desc->addr); - phys_addr = gpa_to_hpa(vdev, desc->addr, desc->len, &addr_type); + /* Need check extra VLAN_HLEN size for inserting VLAN tag */ + phys_addr = gpa_to_hpa(vdev, desc->addr, desc->len + VLAN_HLEN, + &addr_type); if (likely(packet_success < (free_entries - 1))) /* Prefetch descriptor index. */