Skip to contentSkip to conversation

vhost: fix crash on NUMA

PATCH Applied Yuanhan Liu 4 participants 4 messages Jun 2, 2017 – Jun 4, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: fix crash on NUMA

The queue allocation was changed, from allocating one queue-pair at a time to one queue at a time. Most of the changes have been done, but just with one being missed: the size of coping the old queue is still based on queue-pair at numa_realloc(), which leads to overwritten issue. As a result, crash may happen.

Fix it by specifying the right copy size. Also, the net queue macros are not used any more. Remove them.

Fixes ab4d7b9f1afc ("vhost: turn queue pair to vring")
---
 lib/librte_vhost/vhost_user.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/librte_vhost/vhost_user.c +1 -3
index 5c8058b..e486b78 100644
@@ -238,8 +238,6 @@ numa_realloc(struct virtio_net *dev, int index)
 	struct vhost_virtqueue *old_vq, *vq;
 	int ret;
 
-	enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
-
 	old_dev = dev;
 	vq = old_vq = dev->virtqueue[index];
 
@@ -261,7 +259,7 @@ numa_realloc(struct virtio_net *dev, int index)
 		if (!vq)
 			return dev;
 
-		memcpy(vq, old_vq, sizeof(*vq) * VIRTIO_QNUM);
+		memcpy(vq, old_vq, sizeof(*vq));
 		rte_free(old_vq);
 	}
 
Signature · 1 line
2.8.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Yuanhan Liu

The queue allocation was changed, from allocating one queue-pair at a time to one queue at a time. Most of the changes have been done, but just with one being missed: the size of coping the old queue is still

s/coping/copying/ ?

Quoted 6 lines

based on queue-pair at numa_realloc(), which leads to overwritten issue. As a result, crash may happen.

Fix it by specifying the right copy size. Also, the net queue macros are not used any more. Remove them.

Quoted 9 lines
Fixes ab4d7b9f1afc ("vhost: turn queue pair to vring")
---
 lib/librte_vhost/vhost_user.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Tested-by on v1 1/1
#3 lore raw
In reply to Yuanhan Liu
Quoted 6 lines

The queue allocation was changed, from allocating one queue-pair at a time to one queue at a time. Most of the changes have been done, but just with one being missed: the size of coping the old queue is still based on queue-pair at numa_realloc(), which leads to overwritten issue. As a result, crash may happen.

Quoted 8 lines

Fix it by specifying the right copy size. Also, the net queue macros are not used any more. Remove them.

Fixes ab4d7b9f1afc ("vhost: turn queue pair to vring")
Quoted 28 lines
---
 lib/librte_vhost/vhost_user.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/librte_vhost/vhost_user.c +1 -4
index 5c8058b..e486b78 100644
@@ -238,8 +238,6 @@ numa_realloc(struct virtio_net *dev, int index)
 	struct vhost_virtqueue *old_vq, *vq;
 	int ret;
 
-	enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
-
 	old_dev = dev;
 	vq = old_vq = dev->virtqueue[index];
 
@@ -261,7 +259,7 @@ numa_realloc(struct virtio_net *dev, int index)
 		if (!vq)
 			return dev;
 
-		memcpy(vq, old_vq, sizeof(*vq) * VIRTIO_QNUM);
+		memcpy(vq, old_vq, sizeof(*vq));
 		rte_free(old_vq);
 	}
 
--

2.8.1

Applied
#2 lore raw
In reply to Jens Freimann
Quoted 6 lines · Jens Freimann
Quoted 3 lines · Yuanhan Liu

The queue allocation was changed, from allocating one queue-pair at a time to one queue at a time. Most of the changes have been done, but just with one being missed: the size of coping the old queue is still

s/coping/copying/ ?

right, thanks.

Quoted 17 lines
Quoted 7 lines

based on queue-pair at numa_realloc(), which leads to overwritten issue. As a result, crash may happen.

Fix it by specifying the right copy size. Also, the net queue macros are not used any more. Remove them.

Quoted 9 lines
Fixes ab4d7b9f1afc ("vhost: turn queue pair to vring")
---
 lib/librte_vhost/vhost_user.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Quoted 1 line

Applied to dpdk-next-virtio.

	--yliu