From: YuanXin <yuanxin123456@126.com>
To: dev@dpdk.org
Cc: yuanxin36 <yuanxin36@jd.com>,
Maxime Coquelin <maxime.coquelin@redhat.com>,
Chenbo Xia <chenbox@nvidia.com>
Subject: [PATCH] vhost: fix rte_vhost_vring_call coredump caused by numa_realloc free virtio_net
Date: Thu, 26 Mar 2026 17:28:35 +0800 [thread overview]
Message-ID: <20260326092835.20567-2-yuanxin123456@126.com> (raw)
In-Reply-To: <20260326092835.20567-1-yuanxin123456@126.com>
backend may start poller when the first vq kick(like spdk), and access virtio_net
in poller pthread(reactor thread). At the same time, another vq kick
coming, then call numa_realloc to realloc virtio_net in numa node of
this vq, although virtio_net is already consistent with the first vq.
numa_realloc will free old virtio_net and set its member to 0, this
causes the previous poller pthread to access NULL ptr(latest code is
vhost_vring_inject_irq).
Why dev->flags & VIRTIO_DEV_RUNNING doesn't prevent that happening?
Because there is no lock protecting dev(virtio_net), only vq is protected
by lock.
So, it's no necessary to do dev_realloc for each vq kick when call numa_realloc.
Signed-off-by: YuanXin <yuanxin123456@126.com>
Signed-off-by: yuanxin36 <yuanxin36@jd.com>
---
lib/vhost/vhost_user.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 4bfb13fb98..1312f95cbc 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -681,6 +681,9 @@ numa_realloc(struct virtio_net **pdev, struct vhost_virtqueue **pvq)
out_dev_realloc:
+ if (vq->index > 0)
+ return;
+
if (dev->flags & VIRTIO_DEV_RUNNING)
return;
--
2.43.0
next prev parent reply other threads:[~2026-03-31 7:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 9:28 [PATCH] vhost: fix rte_vhost_vring_call coredump caused by numa_realloc free virtio_net YuanXin
2026-03-26 9:28 ` YuanXin [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-03-26 10:18 YuanXin
2026-03-26 10:18 ` YuanXin
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=20260326092835.20567-2-yuanxin123456@126.com \
--to=yuanxin123456@126.com \
--cc=chenbox@nvidia.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=yuanxin36@jd.com \
/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