From: Stephen Hemminger <stephen@networkplumber.org>
To: Xinxin Zhao <15957197901@163.com>
Cc: dev@dpdk.org, stable@dpdk.org
Subject: Re: [PATCH] vhost: Fix the crash caused by accessing the released memory
Date: Tue, 31 Mar 2026 15:23:36 -0700 [thread overview]
Message-ID: <20260331152336.48a9d294@phoenix.local> (raw)
In-Reply-To: <20240625093149.63247-1-15957197901@163.com>
On Tue, 25 Jun 2024 17:31:49 +0800
Xinxin Zhao <15957197901@163.com> wrote:
> The rte_vhost_driver_unregister() vhost_user_read_cb()
> vhost_user_client_reconnect() can be called at the same time by 3 threads.
> when memory of vsocket is freed in rte_vhost_driver_unregister(),
> then vhost_user_read_cb() maybe add vsocket to reconn_list,
> the invalid memory of vsocket is accessed in vhost_user_client_reconnect().
> It's a bug for vhost as client.
>
> E.g., vhostuser port is created as client.
> Thread 1 calls rte_vhost_driver_unregister() to remove
> the vsocket of reconn from the reconn list.
> Then “vhost-events” thread calls vhost_user_read_cb() to
> add the vsocket of reconn back to the reconn list.
> At this time, after thread 1 releases the vsocket memory,
> the socket of vhostuser reconnects successfully,
> "vhost_reconn" thread will access the released memory.
>
> The core trace is:
> Program terminated with signal 11, Segmentation fault.
> The fix is to perform a delete operation again after releasing the memory
>
> Fixes: 451dc0f ("vhost: fix crash on port deletion")
> Cc: stable@dpdk.org
>
> Signed-off-by: Xinxin Zhao <15957197901@163.com>
> ---
This patch looks like something that should get fixed.
But the current patch has some commit message issues.
AI review had some observations
Review of [PATCH] vhost: Fix the crash caused by accessing the released memory
The use-after-free bug is real and the fix is correctly placed — the
reconnect entry is removed before vsocket is freed, and by this point
fdset_try_del has ensured vhost_user_read_cb can no longer re-add it.
Warning: Commit message says "perform a delete operation again after
releasing the memory" but the code removes the entry BEFORE freeing.
The description contradicts the (correct) code.
Warning: Fixes tag uses 7-char hash, DPDK convention is 12:
Fixes: 451dc0f2d943 ("vhost: fix crash on port deletion")
Warning: Subject should be lowercase after prefix and more concise:
vhost: fix use-after-free on client reconnect during unregister
Suggest this:
vhost: fix use-after-free on client reconnect during unregister
When vhost operates in client mode with reconnect enabled, three
threads can race: rte_vhost_driver_unregister(), vhost_user_read_cb(),
and vhost_user_client_reconnect(). If vhost_user_read_cb() adds the
vsocket back to the reconnect list after unregister has already
removed it, the reconnect thread will later dereference the freed
vsocket memory.
Fix by calling vhost_user_remove_reconnect() for client sockets
with reconnect enabled during unregister. This is safe because by
this point fdset_try_del has completed for all connection fds,
preventing vhost_user_read_cb from creating new reconnect entries.
Fixes: 451dc0f2d943 ("vhost: fix crash on port deletion")
Cc: stable@dpdk.org
Signed-off-by: Xinxin Zhao <15957197901@163.com>
next prev parent reply other threads:[~2026-03-31 22:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 9:31 [PATCH] vhost: Fix the crash caused by accessing the released memory Xinxin Zhao
2026-03-31 22:23 ` Stephen Hemminger [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-06-25 2:13 zhaoxinxin
2024-06-25 13:51 ` Patrick Robb
2024-06-19 12:27 zhaoxinxin
2024-06-24 9:20 ` Maxime Coquelin
2024-06-19 8:39 zhaoxinxin
2024-06-18 5:59 zhaoxinxin
2024-06-17 3:35 zhaoxinxin
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=20260331152336.48a9d294@phoenix.local \
--to=stephen@networkplumber.org \
--cc=15957197901@163.com \
--cc=dev@dpdk.org \
--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