From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796115160; b=zwwHmhsx1juLP5L99/2DF3KdQ8jZoApALCpgrtNAFRXYyZ4jIypbDCoNyfyf668T+iZN oS2LCFYfB2Ito2S0kNSHuxZHDHo8acE7tuDYadBpmQnruQiV5cRuFNPF991k3KmLWRRyk kj43qrswwKZKv7yowilDfSClCDf7aEzi1BhAroO1ZbuXFie6/ABA8MveqwoNSTbqzBPta sDqKL8aMPht2cYTyuONPUQ5kN8cY9PGBgBQgGdkDZqxSHVX1neixESdslp/LUMTMT09QW NXqWk+MeLXQV+kZkQag/59UyV5+1cQ1MczqQ1pR/oye+zY3cChVm7tzAKyoAprFikrw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796115160; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=94vH5ph7NKAohjI8NVxUXju5SlHjVQqglRbBq4PzSMY=; b=2OtLn0z68mTwXGAoyVg+FR7WYmaES0U3TJDbQ6pQL82785xhfbL70F8KTAYz1g7sUh5i qr2deH1iPq7tsocctSHyMf9tmW3AO2fya+9dn74rwLgob0FohXgnx3gr9R6NeB3QX0gmL mImq6YBK7M5XCIM5ttl36dZABKxwCfshXSg3U064csONwuHRQs+MI5FCLmrZNKWpNRSP5 QCVQeEq2JFdrDmDvcEql1bLGdAz+PSljMullUnJdGrKauv5POGZPnhklKeOsVowHoKDoM YylvokPO2kXvVqqsR/A0FB1ntJIXxBi57NuVySjJO2z3xjB4Fa1MKtx4ZdjRGY79Feg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GOPCPJ2I; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 953AE606A329; Tue, 1 Dec 2026 08:52:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GOPCPJ2I Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4D1F1F00899; Tue, 1 Dec 2026 08:52:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796115160; bh=94vH5ph7NKAohjI8NVxUXju5SlHjVQqglRbBq4PzSMY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=GOPCPJ2IEejnH90UBNlXOcqrFwSLvI/y48K3mTroxQ142vF3dXdDLmhgnooBkdFId canxG2xzV5Rkoe5Rgvh92bN4qI7OqEUQc/3zYBs5h/j2q8qUk3nFOExQ9AhbXEjHFH J4qWtPDHvV5YKkIjfXb4LDQzuTMuBPhd0DiW05uiLnUTcmweuzC9DnOd7bVB7/hQIm 7gxtl2PtMZmscqucyVo70XyR7/Fc4vG6E4Z1UAXHq04YxxN8w6BWhQ4g7pFK5f5Teh AYg0JL6qI0vpjG+Nh4hjUD/tOZLI9Q2xW4rBeqQRjqF6Q/1Pk42pFiBRXmI/d8FZyw ng0qVfNiFKfyQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] vhost/vsock: wait for RCU grace period before rehashing CID Reply-To: sashiko-reviews@lists.linux.dev To: "Bilal Hashim" Cc: kvm@vger.kernel.org, virtualization@lists.linux.dev, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: <179602872770.13688.17108715679213800277@126.com> References: <179602872770.13688.17108715679213800277@126.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 08:52:39 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 > 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 [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 ca= llers") --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/179602872770.13688.= 17108715679213800277@126.com?part=3D1