netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: bsdhenrymartin@gmail.com
To: huntazhang@tencent.com, jitxie@tencent.com,
	landonsun@tencent.com, mst@redhat.com, jasowang@redhat.com
Cc: eperezma@redhat.com, kvm@vger.kernel.org,
	virtualization@lists.linux.dev, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, bsdhenrymartin@gmail.com,
	Henry Martin <bsdhenryma@tencent.com>,
	TCS Robot <tcs_robot@tencent.com>
Subject: [PATCH v1] vhost: fix missing descriptor reclaim on copy_to_iter failure
Date: Wed,  6 Aug 2025 19:46:20 +0800	[thread overview]
Message-ID: <20250806114620.2696386-1-tcs_kernel@tencent.com> (raw)

From: Henry Martin <bsdhenryma@tencent.com>

If copy_to_iter(&hdr, sizeof(hdr), &fixup) fails, the descriptor is not
reclaimed via vhost_discard_vq_desc(), leading to potential resource
leaks.

Fix it by explicitly calling vhost_discard_vq_desc() on failure.

Fixes: 4c5a84421c7d ("vhost: cleanup iterator update logic")
Reported-by: TCS Robot <tcs_robot@tencent.com>
Signed-off-by: Henry Martin <bsdhenryma@tencent.com>
---
 drivers/vhost/net.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 6edac0c1ba9b..7b4be344b8af 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -1238,6 +1238,7 @@ static void handle_rx(struct vhost_net *net)
 					 &fixup) != sizeof(hdr)) {
 				vq_err(vq, "Unable to write vnet_hdr "
 				       "at addr %p\n", vq->iov->iov_base);
+				vhost_discard_vq_desc(vq, headcount);
 				goto out;
 			}
 		} else {
-- 
2.41.3


                 reply	other threads:[~2025-08-06 11:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250806114620.2696386-1-tcs_kernel@tencent.com \
    --to=bsdhenrymartin@gmail.com \
    --cc=bsdhenryma@tencent.com \
    --cc=eperezma@redhat.com \
    --cc=huntazhang@tencent.com \
    --cc=jasowang@redhat.com \
    --cc=jitxie@tencent.com \
    --cc=kvm@vger.kernel.org \
    --cc=landonsun@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=tcs_robot@tencent.com \
    --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).