[dpdk-stable] [PATCH 17.11] vhost: fix access for indirect descriptors
Tiwei Bie
tiwei.bie at intel.com
Fri Mar 15 10:21:32 CET 2019
[ 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>
---
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