DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vhost: fix buffer length calculation
@ 2018-07-17 13:10 Tiwei Bie
  2018-07-18 10:47 ` Wang, Zhihong
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Tiwei Bie @ 2018-07-17 13:10 UTC (permalink / raw)
  To: maxime.coquelin, zhihong.wang, dev; +Cc: yinan.wang, lei.a.yao

Fixes: fd68b4739d2c ("vhost: use buffer vectors in dequeue path")

Reported-by: Yinan Wang <yinan.wang@intel.com>
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
 lib/librte_vhost/virtio_net.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 2b7ffcf92..07cc0c845 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -720,7 +720,8 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
 				uint16_t hdr_vec_idx = 0;
 
 				while (remain) {
-					len = remain;
+					len = RTE_MIN(remain,
+						buf_vec[hdr_vec_idx].buf_len);
 					dst = buf_vec[hdr_vec_idx].buf_addr;
 					rte_memcpy((void *)(uintptr_t)dst,
 							(void *)(uintptr_t)src,
@@ -747,7 +748,7 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
 			hdr_addr = 0;
 		}
 
-		cpy_len = RTE_MIN(buf_len, mbuf_avail);
+		cpy_len = RTE_MIN(buf_avail, mbuf_avail);
 
 		if (likely(cpy_len > MAX_BATCH_LEN ||
 					vq->batch_copy_nb_elems >= vq->size)) {
@@ -1112,7 +1113,8 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq,
 			 * in a contiguous virtual area.
 			 */
 			while (remain) {
-				len = remain;
+				len = RTE_MIN(remain,
+					buf_vec[hdr_vec_idx].buf_len);
 				src = buf_vec[hdr_vec_idx].buf_addr;
 				rte_memcpy((void *)(uintptr_t)dst,
 						   (void *)(uintptr_t)src, len);
-- 
2.18.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] vhost: fix buffer length calculation
  2018-07-17 13:10 [dpdk-dev] [PATCH] vhost: fix buffer length calculation Tiwei Bie
@ 2018-07-18 10:47 ` Wang, Zhihong
       [not found] ` <20180719020531.GA16332@debian>
  2018-07-19  3:37 ` Tiwei Bie
  2 siblings, 0 replies; 5+ messages in thread
From: Wang, Zhihong @ 2018-07-18 10:47 UTC (permalink / raw)
  To: Bie, Tiwei, maxime.coquelin, dev; +Cc: Wang, Yinan, Yao, Lei A



> -----Original Message-----
> From: Bie, Tiwei
> Sent: Tuesday, July 17, 2018 9:11 PM
> To: maxime.coquelin@redhat.com; Wang, Zhihong
> <zhihong.wang@intel.com>; dev@dpdk.org
> Cc: Wang, Yinan <yinan.wang@intel.com>; Yao, Lei A <lei.a.yao@intel.com>
> Subject: [PATCH] vhost: fix buffer length calculation
> 
> Fixes: fd68b4739d2c ("vhost: use buffer vectors in dequeue path")
> 
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> ---
>  lib/librte_vhost/virtio_net.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index 2b7ffcf92..07cc0c845 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -720,7 +720,8 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  				uint16_t hdr_vec_idx = 0;
> 
>  				while (remain) {
> -					len = remain;
> +					len = RTE_MIN(remain,
> +
> 	buf_vec[hdr_vec_idx].buf_len);
>  					dst = buf_vec[hdr_vec_idx].buf_addr;
>  					rte_memcpy((void *)(uintptr_t)dst,
>  							(void *)(uintptr_t)src,
> @@ -747,7 +748,7 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  			hdr_addr = 0;
>  		}
> 
> -		cpy_len = RTE_MIN(buf_len, mbuf_avail);
> +		cpy_len = RTE_MIN(buf_avail, mbuf_avail);
> 
>  		if (likely(cpy_len > MAX_BATCH_LEN ||
>  					vq->batch_copy_nb_elems >= vq-
> >size)) {
> @@ -1112,7 +1113,8 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  			 * in a contiguous virtual area.
>  			 */
>  			while (remain) {
> -				len = remain;
> +				len = RTE_MIN(remain,
> +					buf_vec[hdr_vec_idx].buf_len);
>  				src = buf_vec[hdr_vec_idx].buf_addr;
>  				rte_memcpy((void *)(uintptr_t)dst,
>  						   (void *)(uintptr_t)src, len);
> --
> 2.18.0

Acked-by: Zhihong Wang <zhihong.wang@intel.com>

Thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] vhost: fix buffer length calculation
       [not found] ` <20180719020531.GA16332@debian>
@ 2018-07-19  2:31   ` Wang, Yinan
  0 siblings, 0 replies; 5+ messages in thread
From: Wang, Yinan @ 2018-07-19  2:31 UTC (permalink / raw)
  To: Bie, Tiwei, maxime.coquelin, dev; +Cc: Yao, Lei A, Wang, Zhihong



On Tue, Jul 17, 2018 at 09:10:35PM +0800, Tiwei Bie wrote:
> Fixes: fd68b4739d2c ("vhost: use buffer vectors in dequeue path")
> 
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>

Above fix can fix below issue:
https://mails.dpdk.org/archives/dev/2018-July/108137.html

Tested-by: Yinan Wang <yinan.wang@intel.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] vhost: fix buffer length calculation
  2018-07-17 13:10 [dpdk-dev] [PATCH] vhost: fix buffer length calculation Tiwei Bie
  2018-07-18 10:47 ` Wang, Zhihong
       [not found] ` <20180719020531.GA16332@debian>
@ 2018-07-19  3:37 ` Tiwei Bie
  2018-07-19 14:15   ` Bruce Richardson
  2 siblings, 1 reply; 5+ messages in thread
From: Tiwei Bie @ 2018-07-19  3:37 UTC (permalink / raw)
  To: maxime.coquelin, zhihong.wang, dev; +Cc: yinan.wang, lei.a.yao

On Tue, Jul 17, 2018 at 09:10:35PM +0800, Tiwei Bie wrote:
> Fixes: fd68b4739d2c ("vhost: use buffer vectors in dequeue path")
> 
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>

Applied to dpdk-next-virtio/master, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] vhost: fix buffer length calculation
  2018-07-19  3:37 ` Tiwei Bie
@ 2018-07-19 14:15   ` Bruce Richardson
  0 siblings, 0 replies; 5+ messages in thread
From: Bruce Richardson @ 2018-07-19 14:15 UTC (permalink / raw)
  To: Tiwei Bie; +Cc: maxime.coquelin, zhihong.wang, dev, yinan.wang, lei.a.yao

On Thu, Jul 19, 2018 at 11:37:31AM +0800, Tiwei Bie wrote:
> On Tue, Jul 17, 2018 at 09:10:35PM +0800, Tiwei Bie wrote:
> > Fixes: fd68b4739d2c ("vhost: use buffer vectors in dequeue path")
> > 
> > Reported-by: Yinan Wang <yinan.wang@intel.com>
> > Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> 
> Applied to dpdk-next-virtio/master, thanks.

It would be great to get this patch into main tree ASAP, since meson build
with gcc 8 is currently broken on master. [Using Fedora 28].

../lib/librte_vhost/virtio_net.c: In function ‘rte_vhost_enqueue_burst’:
cc1: error: ‘__builtin_memcpy’ forming offset [13, 64] is out of the bounds [0, 12] of object ‘tmp_hdr’ with type ‘struct virtio_net_hdr_mrg_rxbuf’ [-Werror=array-bounds]
../lib/librte_vhost/virtio_net.c:636:34: note: ‘tmp_hdr’ declared here
  struct virtio_net_hdr_mrg_rxbuf tmp_hdr, *hdr = NULL;
                                  ^~~~~~~
cc1: error: ‘__builtin_memcpy’ forming offset [13, 64] is out of the bounds [0, 12] of object ‘tmp_hdr’ with type ‘struct virtio_net_hdr_mrg_rxbuf’ [-Werror=array-bounds]
../lib/librte_vhost/virtio_net.c:636:34: note: ‘tmp_hdr’ declared here
cc1: all warnings being treated as errors
ninja: build stopped: subcommand failed.

Regards,
/Bruce

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-07-19 14:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17 13:10 [dpdk-dev] [PATCH] vhost: fix buffer length calculation Tiwei Bie
2018-07-18 10:47 ` Wang, Zhihong
     [not found] ` <20180719020531.GA16332@debian>
2018-07-19  2:31   ` Wang, Yinan
2018-07-19  3:37 ` Tiwei Bie
2018-07-19 14:15   ` Bruce Richardson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).