[dpdk-stable] [PATCH 17.11] vhost: fix access for indirect descriptors

Yongseok Koh yskoh at mellanox.com
Wed Mar 27 19:32:24 CET 2019


> On Mar 15, 2019, at 2:21 AM, Tiwei Bie <tiwei.bie at 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 at intel.com>
> Signed-off-by: Tiwei Bie <tiwei.bie at intel.com>
> Reviewed-by: Maxime Coquelin <maxime.coquelin at 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
> 



More information about the stable mailing list