All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bilal Hashim" <AeeSec@126.com>
Cc: kvm@vger.kernel.org, virtualization@lists.linux.dev,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH] vhost/vsock: wait for RCU grace period before rehashing CID
Date: Tue, 01 Dec 2026 08:52:39 +0000	[thread overview]
Message-ID: <sashiko-outbox-242892@kernel.org> (raw)
In-Reply-To: <179602872770.13688.17108715679213800277@126.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] vhost/vsock: Fixes trailer cites initial driver commit instead
  of 834e772c8db0
--

commit 77ca38e1302ecde9680d0e62c90492c21e199dba
Author: Bilal Hashim <AeeSec@126.com>

> vhost/vsock: wait for RCU grace period before rehashing CID
>
> In vhost_vsock_set_cid(), when a vhost_vsock instance already has a CID
> assigned, hash_del_rcu(&vsock->hash) is immediately followed by
> hash_add_rcu(vhost_vsock_hash, &vsock->hash, vsock->guest_cid) without
> waiting for an RCU grace period.
>
> Reusing an hlist_node that was just removed with hash_del_rcu() overwrites
> its next pointer while concurrent RCU readers in vhost_vsock_get()
> (called from vhost_transport_send_pkt(), vhost_transport_cancel_pkt(),
> vhost_vsock_reset_orphans(), etc.) may still be traversing that bucket.
> This can cause RCU readers to:
> - jump to another hash bucket or terminate early, missing unrelated active
>   vhost_vsock instances (for example causing vhost_vsock_reset_orphans()
>   to reset healthy connections or vhost_transport_send_pkt() to return
>   -ENODEV); or
> - loop indefinitely inside an RCU read-side critical section (RCU stall /
>   soft lockup) when two instances in the same bucket are repeatedly
>   rehashed via VHOST_VSOCK_SET_GUEST_CID.
>
> Fix this by returning early when the CID is unchanged, calling
> synchronize_rcu() after hash_del_rcu() before modifying vsock->guest_cid
> and re-inserting into vhost_vsock_hash, and annotating concurrent accesses
> to vsock->guest_cid with WRITE_ONCE()/READ_ONCE().
>
> Found by manual code inspection.
>
> Fixes: 433fc58e6bf2 ("VSOCK: Introduce vhost_vsock.ko")
> Cc: stable@vger.kernel.org
> Signed-off-by: Bilal Hashim <AeeSec@126.com>

[Severity: Low]
In 433fc58e6bf2 ("VSOCK: Introduce vhost_vsock.ko"), vhost_vsock instances
were kept on a spinlock-protected list (vhost_vsock_list), and
vhost_vsock_set_cid() only updated vsock->guest_cid under vhost_vsock_lock
without unlinking or relinking any node.  The RCU hashtable
vhost_vsock_hash and the hash_del_rcu()/hash_add_rcu() rehash sequence in
vhost_vsock_set_cid() were introduced later by 834e772c8db0 ("vhost/vsock:
fix use-after-free in network stack callers").

Should the Fixes tag be updated to:

  Fixes: 834e772c8db0 ("vhost/vsock: fix use-after-free in network stack callers")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179602872770.13688.17108715679213800277@126.com?part=1

  reply	other threads:[~2026-12-01  8:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  8:52 [PATCH] vhost/vsock: wait for RCU grace period before rehashing CID Bilal Hashim
2026-12-01  8:52 ` sashiko-bot [this message]
2026-12-01 14:56 ` Stefano Garzarella
2026-12-01 16:36   ` [PATCH v2] " Bilal Hashim
2026-12-01 16:41     ` sashiko-bot
2026-12-01 16:58     ` Michael S. Tsirkin
2026-12-01 17:14       ` Stefano Garzarella

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=sashiko-outbox-242892@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=AeeSec@126.com \
    --cc=eperezma@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.