patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 17.11] vhost: fix corner case for enqueue operation
@ 2018-12-24  1:37 Yahui Cao
  2018-12-28  9:48 ` Yongseok Koh
  0 siblings, 1 reply; 2+ messages in thread
From: Yahui Cao @ 2018-12-24  1:37 UTC (permalink / raw)
  To: Jiayu Hu, Yuanhan Liu, Maxime Coquelin; +Cc: stable, Yongseok Koh

[ backported from upstream commit 729199397f9fc4ba265e94d492c792244e8c364b ]

When performing enqueue operations on the split and packed rings,
if the reserved buffer length from the descriptor table exceeds
65535, the returned length by fill_vec_buf_split/_packed()
overflows. This patch is to avoid this corner case.

Fixes: f689586bc060 ("vhost: shadow used ring update")
Fixes: fd68b4739d2c ("vhost: use buffer vectors in dequeue path")
Fixes: 2f3225a7d69b ("vhost: add vector filling support for packed ring")
Fixes: 37f5e79a271d ("vhost: add shadow used ring support for packed rings")
Fixes: a922401f35cc ("vhost: add Rx support for packed ring")
Fixes: ae999ce49dcb ("vhost: add Tx support for packed ring")

Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Signed-off-by: Yahui Cao <yahui.cao@intel.com>
---
 lib/librte_vhost/virtio_net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index bde360f3d..8c0c1b4bb 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -144,7 +144,7 @@ flush_shadow_used_ring(struct virtio_net *dev, struct vhost_virtqueue *vq)
 
 static __rte_always_inline void
 update_shadow_used_ring(struct vhost_virtqueue *vq,
-			 uint16_t desc_idx, uint16_t len)
+			 uint16_t desc_idx, uint32_t len)
 {
 	uint16_t i = vq->shadow_used_idx++;
 
@@ -560,7 +560,7 @@ static __rte_always_inline int
 fill_vec_buf(struct virtio_net *dev, struct vhost_virtqueue *vq,
 			 uint32_t avail_idx, uint32_t *vec_idx,
 			 struct buf_vector *buf_vec, uint16_t *desc_chain_head,
-			 uint16_t *desc_chain_len)
+			 uint32_t *desc_chain_len)
 {
 	uint16_t idx = vq->avail->ring[avail_idx & (vq->size - 1)];
 	uint32_t vec_id = *vec_idx;
@@ -635,7 +635,7 @@ reserve_avail_buf_mergeable(struct virtio_net *dev, struct vhost_virtqueue *vq,
 	uint16_t tries = 0;
 
 	uint16_t head_idx = 0;
-	uint16_t len = 0;
+	uint32_t len = 0;
 
 	*num_buffers = 0;
 	cur_idx  = vq->last_avail_idx;
-- 
2.17.1

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

* Re: [dpdk-stable] [PATCH 17.11] vhost: fix corner case for enqueue operation
  2018-12-24  1:37 [dpdk-stable] [PATCH 17.11] vhost: fix corner case for enqueue operation Yahui Cao
@ 2018-12-28  9:48 ` Yongseok Koh
  0 siblings, 0 replies; 2+ messages in thread
From: Yongseok Koh @ 2018-12-28  9:48 UTC (permalink / raw)
  To: Yahui Cao; +Cc: Jiayu Hu, Yuanhan Liu, Maxime Coquelin, stable


> On Dec 23, 2018, at 5:37 PM, Yahui Cao <yahui.cao@intel.com> wrote:
> 
> [ backported from upstream commit 729199397f9fc4ba265e94d492c792244e8c364b ]
> 
> When performing enqueue operations on the split and packed rings,
> if the reserved buffer length from the descriptor table exceeds
> 65535, the returned length by fill_vec_buf_split/_packed()
> overflows. This patch is to avoid this corner case.
> 
> Fixes: f689586bc060 ("vhost: shadow used ring update")
> Fixes: fd68b4739d2c ("vhost: use buffer vectors in dequeue path")
> Fixes: 2f3225a7d69b ("vhost: add vector filling support for packed ring")
> Fixes: 37f5e79a271d ("vhost: add shadow used ring support for packed rings")
> Fixes: a922401f35cc ("vhost: add Rx support for packed ring")
> Fixes: ae999ce49dcb ("vhost: add Tx support for packed ring")
> 
> Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> 
> Signed-off-by: Yahui Cao <yahui.cao@intel.com>
> ---

Applied to stable/17.11

Thanks,
Yongseok

> lib/librte_vhost/virtio_net.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index bde360f3d..8c0c1b4bb 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -144,7 +144,7 @@ flush_shadow_used_ring(struct virtio_net *dev, struct vhost_virtqueue *vq)
> 
> static __rte_always_inline void
> update_shadow_used_ring(struct vhost_virtqueue *vq,
> -			 uint16_t desc_idx, uint16_t len)
> +			 uint16_t desc_idx, uint32_t len)
> {
> 	uint16_t i = vq->shadow_used_idx++;
> 
> @@ -560,7 +560,7 @@ static __rte_always_inline int
> fill_vec_buf(struct virtio_net *dev, struct vhost_virtqueue *vq,
> 			 uint32_t avail_idx, uint32_t *vec_idx,
> 			 struct buf_vector *buf_vec, uint16_t *desc_chain_head,
> -			 uint16_t *desc_chain_len)
> +			 uint32_t *desc_chain_len)
> {
> 	uint16_t idx = vq->avail->ring[avail_idx & (vq->size - 1)];
> 	uint32_t vec_id = *vec_idx;
> @@ -635,7 +635,7 @@ reserve_avail_buf_mergeable(struct virtio_net *dev, struct vhost_virtqueue *vq,
> 	uint16_t tries = 0;
> 
> 	uint16_t head_idx = 0;
> -	uint16_t len = 0;
> +	uint32_t len = 0;
> 
> 	*num_buffers = 0;
> 	cur_idx  = vq->last_avail_idx;
> -- 
> 2.17.1
> 

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

end of thread, other threads:[~2018-12-28  9:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-24  1:37 [dpdk-stable] [PATCH 17.11] vhost: fix corner case for enqueue operation Yahui Cao
2018-12-28  9:48 ` Yongseok Koh

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).