patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 17.11] vhost: fix access for indirect descriptors
@ 2019-03-15  9:21 Tiwei Bie
  2019-03-27 18:32 ` Yongseok Koh
  0 siblings, 1 reply; 2+ messages in thread
From: Tiwei Bie @ 2019-03-15  9:21 UTC (permalink / raw)
  To: yskoh, stable; +Cc: maxime.coquelin, zhihong.wang

[ backported from upstream commit 48006390003b81f6d5c7b78e3f02ed49d1049945 ]

Fix a possible out of bound access which may happen when handling
indirect descs in split ring.

Fixes: 1be4ebb1c464 ("vhost: support indirect descriptor in mergeable Rx")

Reported-by: Haiyue Wang <haiyue.wang@intel.com>
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/librte_vhost/virtio_net.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 3e2935992..07d4609ee 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -565,6 +565,7 @@ fill_vec_buf(struct virtio_net *dev, struct vhost_virtqueue *vq,
 	uint16_t idx = vq->avail->ring[avail_idx & (vq->size - 1)];
 	uint32_t vec_id = *vec_idx;
 	uint32_t len    = 0;
+	uint32_t nr_descs = vq->size;
 	uint64_t dlen;
 	struct vring_desc *descs = vq->desc;
 	struct vring_desc *idesc = NULL;
@@ -576,6 +577,7 @@ fill_vec_buf(struct virtio_net *dev, struct vhost_virtqueue *vq,
 
 	if (vq->desc[idx].flags & VRING_DESC_F_INDIRECT) {
 		dlen = vq->desc[idx].len;
+		nr_descs = dlen / sizeof(struct vring_desc);
 		descs = (struct vring_desc *)(uintptr_t)
 			vhost_iova_to_vva(dev, vq, vq->desc[idx].addr,
 						&dlen,
@@ -599,7 +601,7 @@ fill_vec_buf(struct virtio_net *dev, struct vhost_virtqueue *vq,
 	}
 
 	while (1) {
-		if (unlikely(vec_id >= BUF_VECTOR_MAX || idx >= vq->size)) {
+		if (unlikely(vec_id >= BUF_VECTOR_MAX || idx >= nr_descs)) {
 			free_ind_table(idesc);
 			return -1;
 		}
-- 
2.17.1


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

* Re: [dpdk-stable] [PATCH 17.11] vhost: fix access for indirect descriptors
  2019-03-15  9:21 [dpdk-stable] [PATCH 17.11] vhost: fix access for indirect descriptors Tiwei Bie
@ 2019-03-27 18:32 ` Yongseok Koh
  0 siblings, 0 replies; 2+ messages in thread
From: Yongseok Koh @ 2019-03-27 18:32 UTC (permalink / raw)
  To: Tiwei Bie; +Cc: stable, maxime.coquelin, zhihong.wang


> On Mar 15, 2019, at 2:21 AM, Tiwei Bie <tiwei.bie@intel.com> wrote:
> 
> [ backported from upstream commit 48006390003b81f6d5c7b78e3f02ed49d1049945 ]
> 
> Fix a possible out of bound access which may happen when handling
> indirect descs in split ring.
> 
> Fixes: 1be4ebb1c464 ("vhost: support indirect descriptor in mergeable Rx")
> 
> Reported-by: Haiyue Wang <haiyue.wang@intel.com>
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---

applied to stable/17.11

Thanks,
Yongseok

> lib/librte_vhost/virtio_net.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index 3e2935992..07d4609ee 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -565,6 +565,7 @@ fill_vec_buf(struct virtio_net *dev, struct vhost_virtqueue *vq,
> 	uint16_t idx = vq->avail->ring[avail_idx & (vq->size - 1)];
> 	uint32_t vec_id = *vec_idx;
> 	uint32_t len    = 0;
> +	uint32_t nr_descs = vq->size;
> 	uint64_t dlen;
> 	struct vring_desc *descs = vq->desc;
> 	struct vring_desc *idesc = NULL;
> @@ -576,6 +577,7 @@ fill_vec_buf(struct virtio_net *dev, struct vhost_virtqueue *vq,
> 
> 	if (vq->desc[idx].flags & VRING_DESC_F_INDIRECT) {
> 		dlen = vq->desc[idx].len;
> +		nr_descs = dlen / sizeof(struct vring_desc);
> 		descs = (struct vring_desc *)(uintptr_t)
> 			vhost_iova_to_vva(dev, vq, vq->desc[idx].addr,
> 						&dlen,
> @@ -599,7 +601,7 @@ fill_vec_buf(struct virtio_net *dev, struct vhost_virtqueue *vq,
> 	}
> 
> 	while (1) {
> -		if (unlikely(vec_id >= BUF_VECTOR_MAX || idx >= vq->size)) {
> +		if (unlikely(vec_id >= BUF_VECTOR_MAX || idx >= nr_descs)) {
> 			free_ind_table(idesc);
> 			return -1;
> 		}
> -- 
> 2.17.1
> 


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

end of thread, other threads:[~2019-03-27 18:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-15  9:21 [dpdk-stable] [PATCH 17.11] vhost: fix access for indirect descriptors Tiwei Bie
2019-03-27 18:32 ` 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).