From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796145277; b=DCGw32erxXb25IzhnMwt2t7FbQiKco2hJqjixpEUh954Wk1oWyTMxco/FoKjM5KCGPqg th2eYU2yvox97xD0+5f0Y8c7/qcu/J61G9TGhu7EISp0fAJVYZDKjqj+8oyVuPFxw8AnS +xNkslKao+iXAjojyAQc/DJSDRHU81fW2Otmbh5XpVuZPCeO1z6X8cLjmQv44ySf8gwQD HYTEv+ofNkvPLGTSQAaudPcT6F1zcJ4/4De4ddsgocUSeBdiKQ8TMed4ZOJInp/U6PoPW W8ROEMTs+G7voGp0vNHhl+PzDTxxLBGnkM279o2R+hguW7nmJZ+1XuTaLPJYCQdr78g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796145277; h=DMARC-Filter:DKIM-Signature:X-MC-Rep:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:In-Reply-To:X-Mimecast-Spam-Score:X-Mimecast-MFC-PROC-ID: X-Mimecast-Originator:Content-Type:Content-Disposition; bh=mfjqNq9VqxcqXovfZtwwxbzJ3ttiqS98gJfYWbASCD0=; b=CxjudNsBhjfDu2Xz+S2gCMaGjx93LYEqYduMjVqmErYW0562S3oJhCCebU+IVK9x5ioR eYCAzU4nupw5vahjNBhpHyKUGKgzYUaW4sJwWsozynoUsNEShDuh/VoL9vUlnWuRjiSBS 4cUQBGIU4nzqNfKi14GbTyca7zKKqkwgLQLMWyhylaXeJv1ibCX/qXub9a6t5em5H9zBE XtgYYw8J0jASaQxCNfPgIA8Lm3/nq23Pt2XRUrcDsr5d+jUbkxcrmzxwk8mD8q9w/h08Q ZTk5Q+ahLZWXrqsI2zANJaRSccisaHM2voZnvvUz7V1MGDWz9pbPmo7UPZbqu/3wwnw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=F7wlUyqn; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C154606A325 for ; Tue, 1 Dec 2026 17:14:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1C154606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=F7wlUyqn DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796145276; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mfjqNq9VqxcqXovfZtwwxbzJ3ttiqS98gJfYWbASCD0=; b=F7wlUyqnQqW3o08Jf/0+VnKnVoEzBUVGfhcho2C/G/QJUQ1rLAYbuwiC87VeuK7+lN/Dcv dNVNo7C4w5O8A7fkg1ockmZPCGhdQVvxTd/VG2ofPFesY+DahD7yRgVUFEGLhP2/dzGieZ ztQXSX7tlZt/TKEwFik0DTPmF7rxR3Q= X-MC-Rep: binary re single Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-199-NlMriHN3PXmI1fsA7kS8og-1; Tue, 1 Dec 2026 17:14:33 +0000 X-MC-Unique: NlMriHN3PXmI1fsA7kS8og-1 X-Mimecast-MFC-AGG-ID: NlMriHN3PXmI1fsA7kS8og_1796145272 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-4bbc86e1eb0so5588455f8f.0 for ; Tue, 01 Dec 2026 09:14:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796145272; x=1796750072; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mfjqNq9VqxcqXovfZtwwxbzJ3ttiqS98gJfYWbASCD0=; b=1JAFg5CBFcohlSqb07vo4the6n3bdLZG74kxDmiUaczrlHn5gX5AOD1xpx+8tHoSti 8ITFv+Ach1itCHjAuXjAs5Qt2AgkqOydMrkVuGVmflO4AdMJaBGNfk03k7TISV2s4NwD BLnGalh/SyYfRJZSNpGCukkNq43L+OS4ZR6FEugskaSGpeT7J7QehyV9dIqNCiz2xx4j R3CGdCibcSbgT4tx6qmzyJfbmatlHqB+ab0FwgeQord/1fr7PWOQNQby0ZRx4qTR3vvF ubrrybzb8huCflSjUp2jK87BfrKdc0SwCcUBAtmNCSKDe9JUufwBaBjgRhpCm5Q624k4 AbRA== X-Forwarded-Encrypted: i=1; AL+hErHd57z3SC2mIAk95EnplZZMyGvoZj5n7wc9bMrt31Pbwp8NaN3aMaH8s5GFDv6BfovFPKvQDlHi7W4WL+c7+w==@lists.linux.dev X-Gm-Message-State: APuU4Z90Q937bDVCsON/us8wv8tUSJ6/BQZfvysJG2YxisUdLGS6Pnsx KS97J5g7ygj0BD9OV+ANaHE0MpIEG2svkRcHYoty0SFMelWFu03mSmqGyiJV5EfgM8NjT8jvwWy S9Fs32+FKD44qHDLlUxgG1pDrqWxTIr5onhqa2lHMLK1RgA0OdcGS3cSLn8y8VDg7okDN X-Gm-Gg: AZFdTZexo4/W3UEfHQwG8ZZ+p2WV+vTXDyxQ9GXxXjw16mSubnpXpfI51iNnNANeFB6 77S8pzSfXEGyfJsgIzTx8AG3KEMeaoXwCYc5DoUVdPiJqB7MmdXUNjqyoAEe+GHk/WzT8CVUDxs UFKV9In5eQYjpKk1YxbSl3QVESCr6VtiXbwxBdwat/Ustni9fCZEKVE/x8eYR2gOLcIH+JlvH7i IShatQumSfNKOcPdwlT7ExxkjcM18C1H5W4rqEK2H1qdhAvSoc6Bz2AnprOpH4tnbQMQjL89u67 REsN8ORD0S3uq1Zc5Nup2v3TiPovR+NkNLt5+v0a0oPhUJ1o+3NqI8B9G0IyRPGJszKIOMVm4yi UFQfKPQrEhKDXMvQjtGJdRG6xYYJdytgj+UkR7rsiDZ9V+wUGlMbSalxKkn6/Rv/aFFolsZWxbB sNNRZcRNlman7zEw== X-Received: by 2002:a05:6000:4616:b0:4a8:714:7ae2 with SMTP id ffacd0b85a97d-4abb32a3f61mr73047876f8f.29.1796145272272; Tue, 01 Dec 2026 09:14:32 -0800 (PST) X-Received: by 2002:a05:6000:4616:b0:4a8:714:7ae2 with SMTP id ffacd0b85a97d-4abb32a3f61mr73047811f8f.29.1796145271739; Tue, 01 Dec 2026 09:14:31 -0800 (PST) Received: from sgarzare-redhat (ip190-139-192-82.pool-bba.aruba.it. [82.192.139.190]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4b1ed8b6a05sm46949361f8f.43.2026.12.01.09.14.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 09:14:30 -0800 (PST) Date: Tue, 1 Dec 2026 18:14:23 +0100 From: Stefano Garzarella To: "Michael S. Tsirkin" Cc: Bilal Hashim , Stefan Hajnoczi , Jason Wang , Eugenio Perez , phind.uet@gmail.com, kvm@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] vhost/vsock: wait for RCU grace period before rehashing CID Message-ID: References: <179602872770.13688.17108715679213800277@126.com> <179614298864.2872.3567081270371906851@126.com> <20261201115614-mutt-send-email-mst@kernel.org> X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 In-Reply-To: <20261201115614-mutt-send-email-mst@kernel.org> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: rCzwUw_p_pQbgNQZ8r0sF1IhOzLIndbE0PPdiE25i-A_1796145272 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline On Tue, Dec 01, 2026 at 11:58:42AM -0500, Michael S. Tsirkin wrote: >On Wed, Dec 02, 2026 at 12:36:28AM +0800, Bilal Hashim wrote: >> 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 and calling >> synchronize_rcu() after hash_del_rcu() before modifying vsock->guest_cid >> and re-inserting into vhost_vsock_hash. >> >> Found by manual code inspection. >> >> Fixes: 834e772c8db0 ("vhost/vsock: fix use-after-free in network stack callers") >> Cc: stable@vger.kernel.org >> Signed-off-by: Bilal Hashim > >Some process comments: >- pls include net/net-next [PATCH ...] to indicate the tree this is > against >- send new versions as a new thread not as reply to the old one - answer reviewer comments/questions before posting a new version Stefano