patch 'vhost: fix wrapping on control virtqueue rings' has been queued to stable release 24.11.3
Kevin Traynor
ktraynor at redhat.com
Fri Jul 18 21:29:09 CEST 2025
Hi,
FYI, your patch has been queued to stable release 24.11.3
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 07/23/25. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable
This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/3478fefb08e696ca8b4081872f16697c3e25129e
Thanks.
Kevin
---
>From 3478fefb08e696ca8b4081872f16697c3e25129e Mon Sep 17 00:00:00 2001
From: David Marchand <david.marchand at redhat.com>
Date: Wed, 2 Apr 2025 08:53:58 +0200
Subject: [PATCH] vhost: fix wrapping on control virtqueue rings
[ upstream commit 38e640038798da92d1b7daf953f06fcd116cb952 ]
The idx field of a virtqueue available ring is increased by the driver
regardless of the ring size. It is for the device to mask this index
modulo the ring size (2.7.6 of the virtio 1.3 specification).
The same applies to the used ring.
Failing to mask triggers:
- crashes when popping message received on the cvq,
- system lockups (in the case of VDUSE) when the virtio-net driver waits
infinitely,
Fixes: 474f4d7840ad ("vhost: add control virtqueue")
Signed-off-by: David Marchand <david.marchand at redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
Tested-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
lib/vhost/virtio_net_ctrl.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/lib/vhost/virtio_net_ctrl.c b/lib/vhost/virtio_net_ctrl.c
index b8ee94018e..5d411fc248 100644
--- a/lib/vhost/virtio_net_ctrl.c
+++ b/lib/vhost/virtio_net_ctrl.c
@@ -41,5 +41,5 @@ virtio_net_ctrl_pop(struct virtio_net *dev, struct vhost_virtqueue *cvq,
}
- desc_idx = cvq->avail->ring[cvq->last_avail_idx];
+ desc_idx = cvq->avail->ring[cvq->last_avail_idx & (cvq->size - 1)];
if (desc_idx >= cvq->size) {
VHOST_CONFIG_LOG(dev->ifname, ERR, "Out of range desc index, dropping");
@@ -168,6 +168,4 @@ virtio_net_ctrl_pop(struct virtio_net *dev, struct vhost_virtqueue *cvq,
cvq->last_avail_idx++;
- if (cvq->last_avail_idx >= cvq->size)
- cvq->last_avail_idx -= cvq->size;
vhost_virtqueue_reconnect_log_split(cvq);
@@ -181,6 +179,4 @@ free_err:
err:
cvq->last_avail_idx++;
- if (cvq->last_avail_idx >= cvq->size)
- cvq->last_avail_idx -= cvq->size;
vhost_virtqueue_reconnect_log_split(cvq);
@@ -232,11 +228,9 @@ virtio_net_ctrl_push(struct virtio_net *dev, struct virtio_net_ctrl_elem *ctrl_e
struct vring_used_elem *used_elem;
- used_elem = &cvq->used->ring[cvq->last_used_idx];
+ used_elem = &cvq->used->ring[cvq->last_used_idx & (cvq->size - 1)];
used_elem->id = ctrl_elem->head_idx;
used_elem->len = ctrl_elem->n_descs;
cvq->last_used_idx++;
- if (cvq->last_used_idx >= cvq->size)
- cvq->last_used_idx -= cvq->size;
rte_atomic_store_explicit((unsigned short __rte_atomic *)&cvq->used->idx,
--
2.50.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2025-07-18 20:29:11.644603097 +0100
+++ 0015-vhost-fix-wrapping-on-control-virtqueue-rings.patch 2025-07-18 20:29:10.819906991 +0100
@@ -1 +1 @@
-From 38e640038798da92d1b7daf953f06fcd116cb952 Mon Sep 17 00:00:00 2001
+From 3478fefb08e696ca8b4081872f16697c3e25129e Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 38e640038798da92d1b7daf953f06fcd116cb952 ]
+
@@ -17 +18,0 @@
-Cc: stable at dpdk.org
@@ -27 +28 @@
-index 999e84db7c..63c0a06b4f 100644
+index b8ee94018e..5d411fc248 100644
More information about the stable
mailing list