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=1796143310; b=mUYq7U9NYn+nEp0JGW5DYRNIYx2HqCv37dlprVrHFUfJ+bJgrHd3K7N64+idAfmoBfhY FxEyefTVQ6zh0yLdKfzl9yq8vjBnVDc+cEFs6XOJhBEBsY1m9usfsZSzN/RW/aUzvZUL2 ADHW3sQf8kryUI15X5KJBqrgydGrN/EyvMVQ7F3NgBHGmE5mrVfMhHJ85190UG9RcnIo0 rK9+P7sepWXmEROVwynLdVVYllSu0GfF3xpDrnxj0xfi1U7lxiPycMUr+nOAbZbckaZoG NcIGTdBsD+eiB+Pze8a2uMxirbkM7K58cYT0QrQYr7IMeTolTUPJP7LqO4XcbdcviSw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796143310; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=0paeWHVLHubP/D+SAFb9bUejknqReZePZ1sMCEki4ac=; b=f6/Aqfmc3qsfnDla3OZ/6axjy3M3mlkzKl7kMA4VWd6NWWtflqFFjyR7N37TcjfkyBrT lOc52QGqmAHVUCMrZOKcyjjk8NL1f4Za73vsvTUIxzJt0ngriqKGkcRfrSsMw2NjeF3qL QTGNmaN2aWJmA4pSzNII90GnMiKM500E3G6uDi5a4fq2yD0uQj7MKvivOXmH1h+x87UV5 +9MrlKdWQD7/K3QfHP8LZtcFM2NSxC/b+cMK1jKMdxDQlOloJoSJTBqxmc/yl7WqqFMy7 Q55MGwZ8Cf+TacL88y8DRwSJwaVQmbyGuUOh9dtBjRfMvWJOnPtRwPFNAFwq7W1ZEsQ== 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=DJgWo11Z; 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 B7D32606A31A for ; Tue, 1 Dec 2026 16:41:50 +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=DJgWo11Z Received: by smtp.kernel.org (Postfix) with ESMTPSA id 757531F00897; Tue, 1 Dec 2026 16:41:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796143310; bh=0paeWHVLHubP/D+SAFb9bUejknqReZePZ1sMCEki4ac=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=DJgWo11ZkbjfaotY8S9DrI3Rdh47iyvdXHnWPORH6NOQpsl/RDAPTf0SO5OYKsCEa cKH8HJpvZqYWxg8ahweA8WDL3/Du4VUZ6K2fZJnOIStdMJn5vWsEXmGBgBERq+uXRf L42kcY11wNNOdf3LxDyGrxnKvi0nPLVALGuV/GNoOULgBxfZwC42NVWF8Pzb4I1kb5 8NArFBYDpDB5BIGKWmm0sXVLh8E4VYWKmNbSWjOIvHAicbRSi0CQacoZpSn+VwTFgC n+4z9rCGrl5NNsD2D5lw8DXaoWp3KEyESchi+QvcGQVR6ECtH19stM5zqoaEJoPsSu QodzU02IruHUg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] vhost/vsock: wait for RCU grace period before rehashing CID Reply-To: sashiko-reviews@lists.linux.dev To: "Bilal Hashim" Cc: virtualization@lists.linux.dev, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: <179614298864.2872.3567081270371906851@126.com> References: <179602872770.13688.17108715679213800277@126.com> <179614298864.2872.3567081270371906851@126.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 16:41:50 +0000 X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > 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. >=20 > 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. >=20 > Fix this by returning early when the CID is unchanged and calling > synchronize_rcu() after hash_del_rcu() before modifying vsock->guest_cid > and re-inserting into vhost_vsock_hash. >=20 > Found by manual code inspection. >=20 > Fixes: 834e772c8db0 ("vhost/vsock: fix use-after-free in network stack ca= llers") > Cc: stable@vger.kernel.org > Signed-off-by: Bilal Hashim Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/179614298864.2872.3= 567081270371906851@126.com?part=3D1