From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 398F12E89 for ; Wed, 5 Nov 2014 08:01:27 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 04 Nov 2014 23:10:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,317,1413270000"; d="scan'208";a="617371145" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 04 Nov 2014 23:10:48 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id sA57Ak5M031934; Wed, 5 Nov 2014 15:10:46 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id sA57Ah3V024306; Wed, 5 Nov 2014 15:10:45 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id sA57AhG3024302; Wed, 5 Nov 2014 15:10:43 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Wed, 5 Nov 2014 15:10:35 +0800 Message-Id: <1415171435-24252-4-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1415171435-24252-1-git-send-email-changchun.ouyang@intel.com> References: <1415084708-8192-1-git-send-email-changchun.ouyang@intel.com> <1415171435-24252-1-git-send-email-changchun.ouyang@intel.com> Subject: [dpdk-dev] [PATCH v4 3/3] vhost: Check offset value X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Nov 2014 07:01:27 -0000 This patch checks the packet length offset value, and checks if the extra bytes inside buffer cross page boundary. Signed-off-by: Changchun Ouyang --- examples/vhost/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 2916313..a93f7a0 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. */ -- 1.8.4.2