Article View: linux.kernel.netdev
Article #26408Re: [PATCH] vhost/vsock: wait for RCU grace period before rehashing guest_cid
From: Krzysztof Woś
Date: Thu, 03 Dec 2026 12:13
Date: Thu, 03 Dec 2026 12:13
54 lines
13965 bytes
13965 bytes
On Thu, Dec 03, 2026 at 11:43:29AM +0100, Stefano Garzarella wrote:
> 1 commit for all of those fixes?
>
> BTW it seems your LLMs are founding the same issue in the last weeks,
> so, please, before posting a patch, can you check if there are patches
> fixing the same issue?
>
> Please test those patches already posted, and comment on them if you
> think they are not complete.
Hi Stefano,
My sincere apologies for the duplicate submission and for bundling
multiple changes into a single commit. This is one of my first kernel
submissions: I checked torvalds/linux HEAD (d06ce6f1eb5e) without
checking net-next and lore.kernel.org/netdev first, and I should also
have split distinct changes into separate commits. Going forward I will
always check net-next and lore/Patchwork before posting.
Please drop/ignore this patch in Patchwork in favor of Nguyen Dinh Phi's
merged net-next commit c68d8b4cb2e7 ("vhost/vsock: annotate lockless
accesses to guest_cid") and Bilal Hashim's v2 thread
(179614298864.2872.3567081270371906851@126.com).
Looking through Bilal's v2 and Michael's hlist_nulls follow-up there,
two small notes in case they help that discussion:
1. On Michael's question whether synchronize_rcu() runs on every VM
boot: on initial VM boot vsock->guest_cid is 0 (kzalloc'd in
vhost_vsock_dev_open()), so synchronize_rcu() is skipped and only
triggers if user space calls VHOST_VSOCK_SET_GUEST_CID again to
reassign an already-configured fd. Still, holding global
vhost_vsock_mutex across synchronize_rcu() blocks unrelated VMs'
vhost_vsock_dev_release() and SET_GUEST_CID calls during that grace
period, and leaving vsock->guest_cid non-zero across synchronize_rcu()
lets vhost_vsock_handle_tx_kick() keep accepting TX packets with the
unlinked CID until guest_cid is updated.
2. On Michael's hlist_nulls sketch: get_nulls_value(node) != bucket
catches cross-bucket moves at end-of-chain, without needing
synchronize_rcu(), if other == vsock returns early. One subtlety is
same-bucket CID reassignment (e.g. CID 3 -> 259, both hashing to the
same 8-bit bucket): if two instances in the same bucket are
repeatedly re-added at head via hlist_nulls_add_head_rcu() without a
grace period, a concurrent RCU reader positioned on them can bounce
between the two nodes without reaching the nulls marker. Also,
hlist_nulls_add_head_rcu() updates n->next via WRITE_ONCE() before
publishing head->first, so rehashing an existing live node (unlike a
freshly allocated SLAB_TYPESAFE_BY_RCU node) needs smp_wmb() between
updating guest_cid and overwriting n->next.
Thanks, and sorry again for the noise,
Krzysztof Woś
Technical Details
Message-ID:
<179630003262.439139.12879743486189024236@gmail.com>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376640-linux-kernel-netdev=dewy.ruReferences:
<179627895906.335073.17960904565008606745@gmail.com> <axFG8LeimFx1Zrk9@sgarzare-redhat>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376640-linux-kernel-netdev=dewy.ru
From: krzysztof.wos@gmail.com (Krzysztof Woś)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH] vhost/vsock: wait for RCU grace period before rehashing guest_cid
Date: Thu, 03 Dec 2026 12:13:52 +0000
Organization: Usenet Network
Message-ID: <179630003262.439139.12879743486189024236@gmail.com>
References: <179627895906.335073.17960904565008606745@gmail.com>
<axFG8LeimFx1Zrk9@sgarzare-redhat>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2505180"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:7uxhyGatrMogMWxCvB1N4GGnaxM= sha256:YuP9TXwqhWErYoyLQRW3QmAs+ATdxtjoI310O1pdZ0U=
sha1:RhgqGcjfQpO+MQ1lD/l5bHrWB8w= sha256:mt+pnZlwNAnccZBOJA7Tj19LMJFNieFNQqvpvP//+d4=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id BDA8F11796B; Thu, 3 Dec 2026 16:42:33 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.297
X-Spam-Status: No, score=-3.297 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id E6u88zjI8OxG;
Thu, 3 Dec 2026 16:42:31 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376640-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 269CA117960; Thu, 3 Dec 2026 16:42:23 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 2ED0E338C6; Thu, 3 Dec 2026 13:41:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796305291;
b=f8SR4ykth4H2EhTXsnFB6GVXSBpnypeubkUhuaZkAaHWCtsKYpcVSuVUxIVYNPOGH38w
4d1LO7widksyVUcP8GM0a+nXB6dEPTdXgB2bSU6UAo6fNgT7GDAn3OWo58EqE2gJuyjJ6
JB21mMv51Li5inu6drvi8zGnkhEbZTJ3owapqKcQfZcejDuHPHPT/5g7i30cwNWc/RyWV
XpBwmWvVn6jY7WesklpRtTHXMXPUESHuZDEOchH763C7FAI9diDP6Gfn035QNtAbYaBrx
cRkGSp9IF6FBZ6HnOaJ8pI91ErdPJ/W9bl6JlWLi/8LgzSfWJu2/UWBrQ6FIhR0hypQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796305291;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
In-Reply-To:References:Content-Type:Content-Transfer-Encoding:
X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version;
bh=hm8MWCZFYBj3BJqp6PN49dq5QWddoiG9eoCDC5px6M0=;
b=sl71YVYppEZq2d8DgAhZlQ6Ux3eQA9b3+J2BN+ajZIXwln5M0P1qirM53vB5EuHIuoDW
f/ss+7QQjaRRLkSa1vsupxLuUEsCnspYHdhJc2zsOM7dyMsZ2tda475fFBfTD3x9c39h3
VWoYUOZZtfFA7irklOTbBwRKBsWZ75uZ5VVxwoJYr3mDFgqmzWLoSmijkr+cmiirBReV0
8rdydBebn9TlfVEV1fsaCJ3IV2/ls7Xje44Qc1utjktC1/c1okJZy7KTzLRmk/vl99aK/
szKBdDAWeXWOdvPtIM7kMdGXqtG6Kt/u4vgd8VAGCdbXFp1O4+8ya6LvQ5RcDi4I0jA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=WBx8dnZ9;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id C46FB606A681;
Thu, 3 Dec 2026 13:41:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=WBx8dnZ9
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.180
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796305286;
b=HtMG4YnZCCDtaGbFxC5wXbTigFNDF7Mt8r3rP5NEdcJO+h1o1/VCqUp1opEMW4NoE4GX
Xp2HPe3DN2oWwOii+iEiLN6gFeDNZWmXZFAW91o+mAWbL3IHFS5TmHppcM8Zgd5gT00gs
hlXr5cormcTKMf4F7zFZtXpB3Xkd8mqAqejaT5jHB+m0BN5ynn6gX5YuPG22a8h0aTDCV
FqBoCKfOtdm8QGAPk48d0E1CAiJirRCLO4a5aAzcLdb6wElxujx7YTZsgbeULWjitQlUB
MNPUM257KqXuTQfS1ZrGtwvF+XNtx9JEWKwlYaI0TSo588OjYGlu7x6aUmookAvRbDA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796305286;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
Content-Type:Content-Transfer-Encoding:MIME-Version;
bh=hm8MWCZFYBj3BJqp6PN49dq5QWddoiG9eoCDC5px6M0=;
b=ktdNMz5L6W5wjlpkJAapYdde6akxzjmnJpqJqg+kUffgqo2oOTpi1LCFMQ55n8/U3/wc
JvtRZDrKxHhGlXF0r05uZvjx0NyTqPCrsyipJbzbsK0S30MajlWxj/CRyQbnGY0rrj+0F
zytXaM4YhsG2MCVk4Gv+fRMGHvYbpmBAbz7wr5aJtiJsrCi6tE2EGwM5SMSheVDHlVXyC
H2mTubw7Yly/2Ag6VnO4pCSl19SGD60krvTVVhx19A4rVjFPLUcK6I5RHTKkXQp2Fzcal
x6bb0/uXJzaTkQqlTCjsfKkCmHb9xPm+hN7I1Rkc/4qNQmykFkaUxQktMDCkgd9qbwQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=WBx8dnZ9;
arc=none smtp.remote-ip=74.125.82.180
X-Received: from mail-dy1-f180.google.com (mail-dy1-f180.google.com [74.125.82.180])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9831F606A68C
for <netdev@vger.kernel.org>; Thu, 3 Dec 2026 13:41:25 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9831F606A68C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dy1-f180.google.com with SMTP id 5a478bee46e88-38699cf08dfso19948444eec.1
for <netdev@vger.kernel.org>; Thu, 03 Dec 2026 05:41:25 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796305285; x=1796910085; darn=vger.kernel.org;
h=mime-version:content-transfer-encoding:content-type:references
:in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=hm8MWCZFYBj3BJqp6PN49dq5QWddoiG9eoCDC5px6M0=;
b=WBx8dnZ9JB4m79ArElxTIutGREwxW4UAkcxhcwd2UcZHK85BjL9tfXNWCEBH3ZRoOD
UOGn50pfZ540buhqq9CnieuAIUodce6tKjlD5OmVgk2E7XOkibPmbj/frAMYkuQ9+J46
Kwy4FwaX00tQXPz5tfhMNVaaeYw885mr6EBgL7CZtlWoq9XzAUInbkoR6zQTSHBNGDO5
fpkOkXNLtztg4YR54LTCNAbDigJ0PQpE/nKY5rxC0TmYlH2uW5mfD6GMzzMHSlilt8Lr
LZ15FzoueU9SVTC+Q02wsxKodAWQQ83e8qIp/gXdIxk3HWpB5WEGM2Ie4Vg/TRBCz1wp
BbyQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796305285; x=1796910085;
h=mime-version:content-transfer-encoding:content-type:references
:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=hm8MWCZFYBj3BJqp6PN49dq5QWddoiG9eoCDC5px6M0=;
b=oNW4BND4LSqrjR4LmtYpEAhZKMzVIRTBqXkOPPeHoJRllu5nlreOZdtSNs1iDbIPZ3
XpSnkbhySawgiQOUBozM3+tcx7+MG531I3ysaK0zrIgrDS2YRo6Zo2sAl8DBGZfSMQ5u
EhU17DmZkEt5ICdNy1qA74afCgtdomVK66oRmvfAA5YNusnzTW9BYxZuple8oXIbt1Ox
2DcbBhOz6/yFcuza+NIGpn+Pk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UldDGG4Uz6EzcgdVKg=
X-Received: by 2002:a05:7301:5f14:b0:387:403e:860b with SMTP id 5a478bee46e88-387403e8e3amr3297236eec.36.1796305284565;
Thu, 03 Dec 2026 05:41:24 -0800 (PST)
X-Received: from [127.0.1.1] (M106072044160.v4.enabler.ne.jp. [106.72.44.160])
by smtp.gmail.com with ESMTPSA id 5a478bee46e88-386aa203267sm89309842eec.0.2026.12.03.05.41.21
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 03 Dec 2026 05:41:23 -0800 (PST)
X-Cc: Stefan Hajnoczi <stefanha@redhat.com>, Michael S. Tsirkin <mst@redhat.com>,
Bobby Eshleman <bobbyeshleman@meta.com>, Jason Wang <jasowangio@gmail.com>,
Eugenio Pérez <eperezma@redhat.com>,
virtualization@lists.linux.dev, netdev@vger.kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
X-In-Reply-To: <axFG8LeimFx1Zrk9@sgarzare-redhat>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list