patch 'vhost: fix missing vring call check on virtqueue access' has been queued to stable release 20.11.10

luca.boccassi at gmail.com luca.boccassi at gmail.com
Wed Nov 8 20:25:04 CET 2023


Hi,

FYI, your patch has been queued to stable release 20.11.10

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/10/23. 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/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/db07b9fe92fb159e54b74a80be7ad12e6336c9eb

Thanks.

Luca Boccassi

---
>From db07b9fe92fb159e54b74a80be7ad12e6336c9eb Mon Sep 17 00:00:00 2001
From: Maxime Coquelin <maxime.coquelin at redhat.com>
Date: Fri, 20 Oct 2023 10:47:58 +0200
Subject: [PATCH] vhost: fix missing vring call check on virtqueue access

[ upstream commit af7f683615244675fc4f472a2aa42880896476ad ]

Acquiring the access lock is not enough to ensure
virtqueue's metadata such as vring pointers are valid.

The access status must also be checked.

Fixes: 6c299bb7322f ("vhost: introduce vring call API")
Fixes: c5736998305d ("vhost: fix missing virtqueue lock protection")
Fixes: 830f7e790732 ("vhost: add non-blocking API for posting interrupt")

Reported-by: Li Feng <fengli at smartx.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
Acked-by: David Marchand <david.marchand at redhat.com>
---
 lib/librte_vhost/vhost.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index cc5855ecfd..cb3ede8942 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -1253,6 +1253,7 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)
 {
 	struct virtio_net *dev;
 	struct vhost_virtqueue *vq;
+	int ret = 0;
 
 	dev = get_device(vid);
 	if (!dev)
@@ -1267,14 +1268,20 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)
 
 	rte_spinlock_lock(&vq->access_lock);
 
+	if (unlikely(!vq->access_ok)) {
+		ret = -1;
+		goto out_unlock;
+	}
+
 	if (vq_is_packed(dev))
 		vhost_vring_call_packed(dev, vq);
 	else
 		vhost_vring_call_split(dev, vq);
 
+out_unlock:
 	rte_spinlock_unlock(&vq->access_lock);
 
-	return 0;
+	return ret;
 }
 
 int
@@ -1282,6 +1289,7 @@ rte_vhost_vring_call_nonblock(int vid, uint16_t vring_idx)
 {
 	struct virtio_net *dev;
 	struct vhost_virtqueue *vq;
+	int ret = 0;
 
 	dev = get_device(vid);
 	if (!dev)
@@ -1297,14 +1305,20 @@ rte_vhost_vring_call_nonblock(int vid, uint16_t vring_idx)
 	if (!rte_spinlock_trylock(&vq->access_lock))
 		return -EAGAIN;
 
+	if (unlikely(!vq->access_ok)) {
+		ret = -1;
+		goto out_unlock;
+	}
+
 	if (vq_is_packed(dev))
 		vhost_vring_call_packed(dev, vq);
 	else
 		vhost_vring_call_split(dev, vq);
 
+out_unlock:
 	rte_spinlock_unlock(&vq->access_lock);
 
-	return 0;
+	return ret;
 }
 
 uint16_t
-- 
2.39.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-11-08 19:23:52.223159935 +0000
+++ 0006-vhost-fix-missing-vring-call-check-on-virtqueue-acce.patch	2023-11-08 19:23:51.733395465 +0000
@@ -1 +1 @@
-From af7f683615244675fc4f472a2aa42880896476ad Mon Sep 17 00:00:00 2001
+From db07b9fe92fb159e54b74a80be7ad12e6336c9eb Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit af7f683615244675fc4f472a2aa42880896476ad ]
+
@@ -14 +15,0 @@
-Cc: stable at dpdk.org
@@ -20 +21 @@
- lib/vhost/vhost.c | 18 ++++++++++++++++--
+ lib/librte_vhost/vhost.c | 18 ++++++++++++++++--
@@ -23,5 +24,5 @@
-diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
-index bdcf85bece..b438330063 100644
---- a/lib/vhost/vhost.c
-+++ b/lib/vhost/vhost.c
-@@ -1332,6 +1332,7 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)
+diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
+index cc5855ecfd..cb3ede8942 100644
+--- a/lib/librte_vhost/vhost.c
++++ b/lib/librte_vhost/vhost.c
+@@ -1253,6 +1253,7 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)
@@ -35 +36 @@
-@@ -1346,14 +1347,20 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)
+@@ -1267,14 +1268,20 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)
@@ -37 +38 @@
- 	rte_rwlock_read_lock(&vq->access_lock);
+ 	rte_spinlock_lock(&vq->access_lock);
@@ -50 +51 @@
- 	rte_rwlock_read_unlock(&vq->access_lock);
+ 	rte_spinlock_unlock(&vq->access_lock);
@@ -57 +58 @@
-@@ -1361,6 +1368,7 @@ rte_vhost_vring_call_nonblock(int vid, uint16_t vring_idx)
+@@ -1282,6 +1289,7 @@ rte_vhost_vring_call_nonblock(int vid, uint16_t vring_idx)
@@ -65,2 +66,2 @@
-@@ -1376,14 +1384,20 @@ rte_vhost_vring_call_nonblock(int vid, uint16_t vring_idx)
- 	if (rte_rwlock_read_trylock(&vq->access_lock))
+@@ -1297,14 +1305,20 @@ rte_vhost_vring_call_nonblock(int vid, uint16_t vring_idx)
+ 	if (!rte_spinlock_trylock(&vq->access_lock))
@@ -80 +81 @@
- 	rte_rwlock_read_unlock(&vq->access_lock);
+ 	rte_spinlock_unlock(&vq->access_lock);


More information about the stable mailing list