Skip to contentSkip to conversation

vhost: fix possible out of bound access for indirect descs

PATCH In review Tiwei Bie 2 participants 3 messages Jan 21, 2019

lore
Share & tools
lore

Tiwei Bie

author
#0 lore raw

PATCH 1/1 vhost: fix possible out of bound access for indirect descs

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")
---
 lib/librte_vhost/virtio_net.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
lib/librte_vhost/virtio_net.c +2 -6
index 0893a1d04..37a4c00d2 100644
@@ -310,6 +310,7 @@ fill_vec_buf_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
 	uint32_t len    = 0;
 	uint64_t dlen;
 	uint32_t nr_descs = vq->size;
+	uint32_t cnt    = 0;
 	struct vring_desc *descs = vq->desc;
 	struct vring_desc *idesc = NULL;
 
@@ -348,12 +349,7 @@ fill_vec_buf_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
 	}
 
 	while (1) {
-		if (unlikely(idx >= vq->size)) {
-			free_ind_table(idesc);
-			return -1;
-		}
-
-		if (unlikely(nr_descs-- == 0)) {
+		if (unlikely(idx >= nr_descs || cnt++ >= nr_descs)) {
 			free_ind_table(idesc);
 			return -1;
 		}
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Tiwei Bie

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")
---
  lib/librte_vhost/virtio_net.c | 8 ++------
  1 file changed, 2 insertions(+), 6 deletions(-)

Thanks,
Maxime

#2 lore raw
In reply to Tiwei Bie
Quoted 12 lines · Tiwei Bie

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")
---
  lib/librte_vhost/virtio_net.c | 8 ++------
  1 file changed, 2 insertions(+), 6 deletions(-)

Applide to dpdk-next-virtio/master.

Thanks,
Maxime