Article View: linux.kernel.netdev
Article #8330[PATCH net v3 0/2] vsock/bpf: fix waiting and flag handling in recvmsg
From: Jerome Mohm via B4 Relay
Date: Wed, 28 Oct 2026 17:55
Date: Wed, 28 Oct 2026 17:55
63 lines
13649 bytes
13649 bytes
vsock_bpf_recvmsg() holds lock_sock() while it sleeps for data, so the
transport's delivery worker, which needs that lock to queue the data,
deadlocks with the reader. Patch 1 releases the lock around the wait and
makes the wait loop with the exit conditions of the native path,
including a state check that ends the wait on a reset connection after
getsockopt(SO_ERROR) has cleared sk_err. Patch 2 handles the reads that
should never reach the sockmap wait: len == 0, MSG_ERRQUEUE and MSG_OOB.
v2 was one patch; as Michal noted, it mixed the deadlock fix with
fixes for pre-existing issues, so v3 splits it. Patch 1 alone fixes the
deadlock, the dataless wakeup, the peer shutdown and the reset cases;
the zero-length, MSG_ERRQUEUE and MSG_OOB reads keep their current
behaviour until patch 2.
Not addressed here: the netdev Sashiko review of v2 also noted a
pre-existing case where data that sits only in psock->ingress_skb makes
recvmsg() fall back to the native path, which never looks at the psock
queues. It is independent of this series and I will send a separate
patch for it. Annotating the lockless accesses with
READ_ONCE()/WRITE_ONCE() is likewise left for a separate patch that also
covers the native vsock_connectible_wait_data().
The deadlock and the MSG_ERRQUEUE case were found with the help of
Anthropic's Claude; the other cases come from the netdev Sashiko review.
The reproducers are available on request.
Changes in v3:
- Split into two patches (Michal): 1/2 releases the lock and loops in
the wait, 2/2 handles len == 0, MSG_ERRQUEUE and MSG_OOB.
- 1/2: also end the wait once the socket is no longer TCP_ESTABLISHED
(0 with SOCK_DONE, else -ENOTCONN, as __vsock_connectible_recvmsg()
does), so a reset connection whose error was read with SO_ERROR no
longer waits out the timeout (Sashiko review of v2).
- 2/2: reject MSG_OOB with -EOPNOTSUPP before the len == 0 check, as
unix_bpf does; this also stops MSG_OOB from consuming ordinary bytes
(Sashiko review of v2).
- Stefano's Acked-by on v1 is not carried: neither patch matches v1.
- Drop the Assisted-by trailer (removed upstream); tool use is disclosed
above instead.
- Rebase onto current net.
- Link to v2: https://lore.kernel.org/netdev/20261001-kbh3-1-022-fix-v2-v1-1-cfae958a1976@eldare.de/
Changes in v2:
- Make vsock_msg_wait_data() loop, check sk_err and the peer
SEND_SHUTDOWN, and add the len == 0 guard (Sashiko review of v1);
route MSG_ERRQUEUE to the native path ahead of the guard.
- Link to v1: https://lore.kernel.org/netdev/20260929-kbh3-1-022-fix-v1-1-cc97cc95d269@eldare.de/
---
Jerome Mohm (2):
vsock/bpf: release sock lock while waiting for data in recvmsg
vsock/bpf: fix zero-length, MSG_OOB and MSG_ERRQUEUE reads in recvmsg
net/vmw_vsock/vsock_bpf.c | 71 +++++++++++++++++++++++++++++++++++++----------
1 file changed, 57 insertions(+), 14 deletions(-)
---
base-commit: 363c8c79220d0db4d65dcd570529ddda15067cb5
change-id: 20261001-kbh3-1-022-fix-v2-e3f14290641a
Best regards,
--
Jerome Mohm <jrmmhm.kernel@eldare.de>
Technical Details
Message-ID:
<20261028-kbh3-1-022-fix-v2-v3-0-bc0752b2d3db@eldare.de>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352978-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352978-linux-kernel-netdev=dewy.ru From: devnull+jrmmhm.kernel.eldare.de@kernel.org (Jerome Mohm via B4 Relay) Newsgroups: linux.kernel.netdev Subject: [PATCH net v3 0/2] vsock/bpf: fix waiting and flag handling in recvmsg Date: Wed, 28 Oct 2026 18:55:39 +0100 Organization: Usenet Network Message-ID: <20261028-kbh3-1-022-fix-v2-v3-0-bc0752b2d3db@eldare.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="1829802"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:hQ5Mu9lYjA1W79D51LnHNteeJzU= sha256:rB/vAts4U8kND4MOBSjmmV8+6vfSq8RXEuYcr7NC79k= sha1:2REsQ/pcFE4JQPeFdliHwq5FSGQ= sha256:7xTJpE7WS5PYdEwAPAccS5yIrnfQONW79aO2FAmCL7o= 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 E22A7125C43; Wed, 28 Oct 2026 21:00:48 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=kernel.org 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 35GR3PzhOS-T; Wed, 28 Oct 2026 21:00:45 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-352978-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 8B12A125C40; Wed, 28 Oct 2026 21:00:37 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 78EE86069D2; Wed, 28 Oct 2026 17:56:41 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793210171; b=QzEyaTqLMvExnrZJ7DhzCeGgsYQXqNVZKYDe+VmhvOFluxpA2SmosccCiMHxVuhEtnlj prI82Hgb3tTxUVEFfc8bZ9RkWpoKdNquR5/kR/kZpAvxEhLkNeUKd8BWmbTJquVGozMLz kZLhFQ7tUswaS5kAcjVS9DEWu+zmqcC41wCluUza1RkVCj35cWQo8twqT73y6GhpaUWI2 6dMxV41LMEN/bDEp8mVvpIJH8mYn+CtDYRHR4AYkvlx8PCgiqV71oiAleCShqGCmfW//v xg/2FtPaukj2UxR58UA8G83XSjZ7lN7efse5UhBVFQOhefaCO4FPeCgia3Qb8mTMc9Q== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793210171; h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Subject: Date:Message-Id:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Type:Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To: Cc:X-Mailer:X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To; bh=a/xQi7IAk9m+nuRxq8RigTOPlEQpxTs7m/an1+AlzF4=; b=TWA2bxxoysp4l6sBzX/y5zvUWSIKqKgnpG5yKD3Rj7VcWlw8YfUHJZT5m2PowIbMwGeg 6XSg6nvGRE1tTKprM/J3MSiBH0ODPhgyeS2MGuUVoSDG1PVYHnjccnR1KXuFy5eylfut0 mZF3UcFHNKEu14J07GVtiFWuvlTQEP663//xvTzePFBV+1v+lDAac4F3uSvTr6Xi/HQF8 icboV5ElA+GT74zcUgXyJvsBOVMrpKiM+SH10GPH6uBy1TGvP16LAdKNFPBGqN60iZ1Fs JU9uehBPewnO2ps9i7q1WMHSRR2Ij4BJPD2y5wQmwNBHm6FB89UjfbjcHGx7GLQXQkg== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VAow92Pp; 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 75D5160A382B; Wed, 28 Oct 2026 17:56:11 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VAow92Pp X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793210160; b=OjxsWlkKkJYV47fsbk2rVB9OZ1rf/OGbFIfveSNOFYt63AKIp2QEX9yFZf1u1cuasl6U Yq3NVmt7jtK9WXe3M6jbXgFwiG1J+aAS3T1fT6tTlEOwlKnpzY2sMhjC1AcRS7HsLSRYd VksZwi3dFFb4Fa4xn5j0JiNNDIjYW922QMaEaYEB6d7bI85KgC/ZJp0rEq9KHWIvEaDcX HVNXj3czNrcTDCCmEND/lPo5MqbJkNZhTEoWo9YwyR7I/5MYoy/DYreRQ9INnqsMxJZyv NNcI2fVyNdnBmk54SoA8Me1N12X6fn3MHi7CJPo8tAoVE9Qa0ZYCxXbp6eDz419NHWw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793210160; h=Received:DKIM-Signature:Received:From:Subject:Date:Message-Id: MIME-Version:Content-Type:Content-Transfer-Encoding:X-B4-Tracking: X-Change-ID:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key: X-Endpoint-Received:X-Original-From:Reply-To; bh=a/xQi7IAk9m+nuRxq8RigTOPlEQpxTs7m/an1+AlzF4=; b=DXEGmHCdNr+ZCPA3mZuWXEr443PEJZCCOiOa8aaYCMv3zV7qhdc3g1ymRA0wVNiKFlBx QVugdVolAORJAyQFWxEsfdCPHY9IrUVcxEk7GELNE1Z5HFeWW0140fwV/+6wfjwz9slX0 oHsXQXQpOt11Qnp5YWT2ct7GLTXTZe96qO3QRowWmWn27X51nAqmraiahpYwEtXwkr7OH 5afd0G7tZfS/F1EQDAyFAjVCNW6NwGzdXzN5U8C1cxaL3mowZbNX3iRnhlDX6TUZ9QNPJ xlPAsjO118rM79uTj2ahOCLMJLcBJEQc4ov/4FjpAN37DhebxOA40PDcx8/U65Gwi7Q== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VAow92Pp; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 X-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 5226660A2602; Wed, 28 Oct 2026 17:56:00 +0000 (UTC) X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1793210160; b=VGlx3/t19nSNWObNtmDwOUniEPey5tBk8M2I3cOGHI8FCYwZdoptASDsDJ9P/MSIsTn5 oP5LA2g6LDWQQ4Id6WDtgmMArnASbF3T3tCrT612pUj1eyfkUVO0hWq9Dabi/xxP1/OkC frGMCz78ORXlM1mvecAlzot05hU240NAQ5Oh1b8g7s4M0iRTrhkvlAzCDZfcNpDoSr37l sO/AtkS+qw3w5kMfGpVTWeOHQ3SsD8AYEb+0AUxtEfsj5XFWMOzinDkmyZ1bPX/CcfPqL 5ryzOjKeLGpsvc9cLNiLMIz7QGBSGxNm91V+ed9R10IyM22NgiyXo0N/ITDgrTJduKg== X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1793210160; h=DKIM-Signature:Received:From:Subject:Date:Message-Id:MIME-Version: Content-Type:Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To: Cc:X-Mailer:X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To; bh=a/xQi7IAk9m+nuRxq8RigTOPlEQpxTs7m/an1+AlzF4=; b=XzKwugfY2vLmALm+xtjanS312GEVb1zc5jU8v5nwgawLLm3AYGk2+pMXyspCtf+9OS6e PG2/Taw6FIi2eIcxquEB9aWuAybiQXYg/vJcb9fS4SJJXwuBpxIq8dGpQNIuZjvTaWtnn W85FUF4No98EBQco5b1dWkxFrrfs1r3TpKgW+lAKv8JO4nhNBsB7JSiwxqnMR+D4beHbl v0jdgVKE774IIlhlQxMqCHwo+M71ZU2cDrave7ANGX8n9sZD10RVRFoZZT9+Oi0RJC4cU fVnHAwmvvcKUBK1AjDdsZLqDsHIyRwLyVd4dcxFSCzA81LXnfm3d6U4wfcjLl17yHHg== X-ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (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.kernel.org (Postfix) with ESMTPS id 66F6D1F031E0; Wed, 28 Oct 2026 17:55:59 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793210160; bh=a/xQi7IAk9m+nuRxq8RigTOPlEQpxTs7m/an1+AlzF4=; h=From:Subject:Date:To:Cc:Reply-To; b=VAow92Ppr+IMuw7VvilX8pwKxsVOpLDpRA32Zl55JmPzBZ7wGG8Efs0PlNRLQJDYB gkfZWeE/gh4yJsQqzKUoFC3toQeLIf1biGfxtxqiU+RnbtY93xALrpcxZX2WdOTUoe d2WAyip5eFxmRcnR8F+U3sz9l2Tz3qpKxr920nOku6oCyCIiHM9AttWG7faLXMJzaA pUAgevDbCblfMaB64LfUZwk8y8c2JkLMpv7MoXRTRhlfJJ4q8qGeU6Xgnq8rNysJuS 3GC7rkvQ+Ar4SqZDmkfPsZlfww/ugIwmAdg7RmShRSfnijHEBc7RC6YFxddQCJSy0o /REGrIVBxSwRQ== X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id EB99B45523; Wed, 28 Oct 2026 17:55:58 +0000 (UTC) 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 X-B4-Tracking: v=1; b=H4sIAAAAAAAC/32NSw6CMBCGr0Jm7ZhOQRRW3sOwKGWQqimmrY2Gc HdL3bv8/ucCnp1hD22xgONovJltgnJXgJ6UvTKaITFIIWsSgvDeTyUSCilxNG+MErkcqZKNqCt SkHpPx8nJmxewHKD7if7V31iHbW2LTcaH2X3yc6Qc/nMSKbEeFTeHk6LmWJ/5MSjH+4GhW9f1C 8dh32bJAAAA X-Change-ID: 20261001-kbh3-1-022-fix-v2-e3f14290641a X-Cc: Michal Luczaj <mhal@rbox.co>, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, stable@vger.kernel.org, Jerome Mohm <jrmmhm.kernel@eldare.de> X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793210158; l=3124; i=jrmmhm.kernel@eldare.de; s=20260928; h=from:subject:message-id; bh=5BjgUPTK+Q5h2bvpD5C1SETglAWcW6+J75MQCpy5pss=; b=hIkUf7xsHfJhu8is5rphbJIa8ojwE74njpamLIww2+KFea5blbCiVJ7YFgrtSD8m2+PX1ycYc Nb2geFyhP/SDVckrvVsn8DykNasVOYCwvTL8t3zP8dQ5S391WhRH2JC X-Developer-Key: i=jrmmhm.kernel@eldare.de; a=ed25519; pk=xRCxNXbnNottaHpmvPDAOC9NuMJxqKo24abkehKRVlo= X-Endpoint-Received: by B4 Relay for jrmmhm.kernel@eldare.de/20260928 with auth_id=1075 X-Original-From: Jerome Mohm <jrmmhm.kernel@eldare.de> X-Reply-To: jrmmhm.kernel@eldare.de