netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: mst@redhat.com, jasowang@redhat.com, eperezma@redhat.com
Cc: kvm@vger.kernel.org, virtualization@lists.linux.dev,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	jonah.palmer@oracle.com
Subject: [PATCH net-next V2 1/3] vhost: fail early when __vhost_add_used() fails
Date: Mon, 14 Jul 2025 16:47:53 +0800	[thread overview]
Message-ID: <20250714084755.11921-2-jasowang@redhat.com> (raw)
In-Reply-To: <20250714084755.11921-1-jasowang@redhat.com>

This patch fails vhost_add_used_n() early when __vhost_add_used()
fails to make sure used idx is not updated with stale used ring
information.

Reported-by: Eugenio Pérez <eperezma@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vhost/vhost.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 3a5ebb973dba..d1d3912f4804 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -2775,6 +2775,9 @@ int vhost_add_used_n(struct vhost_virtqueue *vq, struct vring_used_elem *heads,
 	}
 	r = __vhost_add_used_n(vq, heads, count);
 
+	if (r < 0)
+		return r;
+
 	/* Make sure buffer is written before we update index. */
 	smp_wmb();
 	if (vhost_put_used_idx(vq)) {
-- 
2.39.5


  reply	other threads:[~2025-07-14  8:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-14  8:47 [PATCH net-next V2 0/3] in order support for vhost-net Jason Wang
2025-07-14  8:47 ` Jason Wang [this message]
2025-07-14  8:47 ` [PATCH net-next V2 2/3] vhost: basic in order support Jason Wang
2025-07-28 14:26   ` Eugenio Perez Martin
2025-07-14  8:47 ` [PATCH net-next V2 3/3] vhost_net: basic in_order support Jason Wang
2025-07-16  1:12 ` [PATCH net-next V2 0/3] in order support for vhost-net Lei Yang
2025-07-17  0:04 ` Jakub Kicinski
2025-07-17  2:03   ` Jason Wang
2025-07-17  5:54     ` Michael S. Tsirkin
2025-07-17  6:01       ` Jason Wang
2025-07-17  6:31         ` Michael S. Tsirkin
2025-07-17 13:52         ` Paolo Abeni
2025-07-18  2:04           ` Jason Wang
2025-07-18  9:19             ` Paolo Abeni
2025-07-18  9:29               ` Michael S. Tsirkin
2025-07-18  9:44                 ` Paolo Abeni

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=20250714084755.11921-2-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=jonah.palmer@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux.dev \
    /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).