From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: ktraynor@redhat.com, stable@dpdk.org
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>,
David Marchand <david.marchand@redhat.com>
Subject: [PATCH v21.11.6 2/2] vhost: fix missing lock protection in power monitor API
Date: Thu, 23 Nov 2023 11:11:31 +0100 [thread overview]
Message-ID: <20231123101131.98389-2-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20231123101131.98389-1-maxime.coquelin@redhat.com>
The power monitor get API is missing both access lock
protection and access status check.
Fixes: 34fd4373ce76 ("vhost: add power monitor API")
Cc: stable@dpdk.org
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: David Marchand <david.marchand@redhat.com>
(cherry picked from commit b4c4e5675c85a9b471c252305811d15f6a6d2aa6)
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
lib/vhost/vhost.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index 19c7b92c32..a544839de3 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -2014,6 +2014,7 @@ rte_vhost_get_monitor_addr(int vid, uint16_t queue_id,
{
struct virtio_net *dev = get_device(vid);
struct vhost_virtqueue *vq;
+ int ret = 0;
if (dev == NULL)
return -1;
@@ -2024,6 +2025,13 @@ rte_vhost_get_monitor_addr(int vid, uint16_t queue_id,
if (vq == NULL)
return -1;
+ rte_spinlock_lock(&vq->access_lock);
+
+ if (unlikely(!vq->access_ok)) {
+ ret = -1;
+ goto out_unlock;
+ }
+
if (vq_is_packed(dev)) {
struct vring_packed_desc *desc;
desc = vq->desc_packed;
@@ -2043,7 +2051,10 @@ rte_vhost_get_monitor_addr(int vid, uint16_t queue_id,
pmc->match = 0;
}
- return 0;
+out_unlock:
+ rte_spinlock_unlock(&vq->access_lock);
+
+ return ret;
}
--
2.42.0
next prev parent reply other threads:[~2023-11-23 10:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-23 10:11 [PATCH v21.11.6 1/2] net/virtio: fix descriptor addresses in 32-bit build Maxime Coquelin
2023-11-23 10:11 ` Maxime Coquelin [this message]
2023-11-23 10:52 ` [PATCH v21.11.6 2/2] vhost: fix missing lock protection in power monitor API Kevin Traynor
2023-11-23 10:52 ` [PATCH v21.11.6 1/2] net/virtio: fix descriptor addresses in 32-bit build Kevin Traynor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231123101131.98389-2-maxime.coquelin@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=david.marchand@redhat.com \
--cc=ktraynor@redhat.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).