Article View: linux.kernel.netdev
Article #12597Re: [PATCH net v4 1/2] vsock/bpf: release sock lock while waiting for data in recvmsg
From: netdev-bot+sashiko
Date: Sat, 07 Nov 2026 22:00
Date: Sat, 07 Nov 2026 22:00
133 lines
12334 bytes
12334 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The commit message says that with the series applied the
reproduced cases 'behave as on a native socket, except for the reset…
--
vsock/bpf: release sock lock while waiting for data in recvmsg
This patch fixes a deadlock in vsock_bpf_recvmsg(). The function held
lock_sock() while it slept in wait_woken(), and the transport needs that
lock to deliver data. The lock is now released around wait_woken(), and
the wait loops until data arrives or one of the native exit conditions
applies (socket error, shutdown, not connected, timeout or signal).
> diff --git a/net/vmw_vsock/vsock_bpf.c b/net/vmw_vsock/vsock_bpf.c
> index 9049d26486460..6d96ff03f28c4 100644
> --- a/net/vmw_vsock/vsock_bpf.c
> +++ b/net/vmw_vsock/vsock_bpf.c
[ ... ]
> + while (1) {
> + if (vsock_has_data(sk, psock)) {
> + ret = 1;
> + break;
> + }
> +
> + /* Stop on a socket error, as vsock_connectible_wait_data()
> + * does, so that recv() returns it; the checks below would
> + * end the wait with 0 or -ENOTCONN instead.
> + */
> + if (sk->sk_err) {
> + ret = -sk->sk_err;
> + break;
> + }
[Severity: Medium]
Does this match the native path for SOCK_SEQPACKET as well as
SOCK_STREAM?
vsock_connectible_wait_data() stops on sk_err, but it returns 0 rather
than the error:
net/vmw_vsock/af_vsock.c:vsock_connectible_wait_data() {
...
if (sk->sk_err != 0 ||
(sk->sk_shutdown & RCV_SHUTDOWN) ||
(vsk->peer_shutdown & SEND_SHUTDOWN)) {
break;
}
...
}
Only __vsock_stream_recvmsg() converts that into -sk->sk_err afterwards.
__vsock_seqpacket_recvmsg() returns the 0 directly:
err = vsock_connectible_wait_data(sk, &wait, timeout, NULL, 0);
if (err <= 0)
goto out;
With this patch, vsock_bpf_recvmsg() passes the return value through
unchanged (copied = data). sock_map accepts vsock SOCK_SEQPACKET sockets.
Take a SEQPACKET socket in a sockmap with a reader blocked in recv(). If
virtio_vsock_reset_sock() runs and sets sk_err = ECONNRESET, the reader
gets -ECONNRESET here, while a native socket returns 0. The same applies
to other sk_err values, such as EPIPE from sk_psock_report_error().
The check order also differs from __vsock_connectible_recvmsg(). That
function checks the state and transport first, then returns 0 on a local
RCV_SHUTDOWN before it waits:
if (sk->sk_shutdown & RCV_SHUTDOWN) {
err = 0;
goto out;
}
This loop checks sk_err before RCV_SHUTDOWN. So a socket that is still
TCP_ESTABLISHED, has done a local SHUT_RD and has a pending sk_err would
return -sk_err from the BPF path but 0 natively.
The commit message says:
With the series applied they behave as on
a native socket, except for the reset case above
and the code comment claims parity with vsock_connectible_wait_data().
Neither holds for SEQPACKET, or for the SHUT_RD plus sk_err case.
Returning the error may be the better behaviour. If so, could the commit
message and comment say so? The alternative is to follow the native
semantics for each socket type. The later patch in the series ("vsock/bpf:
fix zero-length, MSG_OOB and MSG_ERRQUEUE reads in recvmsg") does not
change vsock_msg_wait_data(), so the difference is still there at the end
of the series.
> +
> + if ((sk->sk_shutdown & RCV_SHUTDOWN) ||
> + (vsk->peer_shutdown & SEND_SHUTDOWN)) {
> + ret = 0;
> + break;
> + }
[ ... ]
> @@ -101,9 +140,10 @@ static int vsock_bpf_recvmsg(struct sock *sk, struct msghdr *msg,
> copied = sk_msg_recvmsg(sk, psock, msg, len, flags);
> while (copied == 0) {
> long timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
> + int data = vsock_msg_wait_data(sk, psock, timeo);
>
> - if (!vsock_msg_wait_data(sk, psock, timeo)) {
> - copied = -EAGAIN;
> + if (data <= 0) {
> + copied = data;
> break;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261106-kbh3-1-022-fix-v2-v4-0-c7d36703814d%40eldare.de
Technical Details
Message-ID:
<179408883290.994134.2349835219799185998@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358535-linux-kernel-netdev=dewy.ruReferences:
<20261106-kbh3-1-022-fix-v2-v4-1-c7d36703814d@eldare.de>Show 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-358535-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v4 1/2] vsock/bpf: release sock lock while waiting for data in recvmsg Date: Sat, 07 Nov 2026 22:00:32 +0000 Organization: Usenet Network Message-ID: <179408883290.994134.2349835219799185998@kernel.org> References: <20261106-kbh3-1-022-fix-v2-v4-1-c7d36703814d@eldare.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="6708"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:dXYV8xoUIVRqv8xYebc19PyM2ps= sha256:uyQu2uDfEfTWlqJPfD89Po8SxsDfwtdloBbdHWc3FZQ= sha1:bit+gLN7Q/aFaE5R6LWLPJV73IE= sha256:ROJ6CSLixiDLOjX+taslzqOAuESLEXS8gu7OP9LFTBg= 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 588371134BE; Sun, 8 Nov 2026 01:01:16 +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 UlOgtaapSCs0; Sun, 8 Nov 2026 01:01:13 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-358535-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id AC3C11134B9; Sun, 8 Nov 2026 01:01:04 +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 17DA843FF0; Sat, 7 Nov 2026 22:00:36 +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=1794088835; b=wGqDXavk1m6YcIoXEA2mlP+Cpe1C5Xnqv17RKyIVz/ZDXJIi3BoZG2lv3MLVCue6uTdy OHGi62XZmhNVq6IGyr8QSqxTOw4v4nIZYkBe5N/NbDm/8l4eOf3O7vV9i++ks7C8bFXo8 Xzo3eiarEmdNVvjkmrwKfO7GKVFx6XMGexQOgyiyym0gmEnFlt8puJbu80O7qn3qxiIkS JZIviw6XT8y+7mHkx8fGVE5OVb/fKVqD2GKi7x0tXdr3n5zITKgiygmgxi0UFLxsoY5gj sLfDdyqu2Zcv2cHUds9Bpgf+4O4fW8YzzNfqTNjWXNq6Z+YKtguJz/CtDw75SkC+XIQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794088835; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=VNZGPeMP1H9NcfpnWuuufaSVsJdMZpOEEwuaOwBXqj4=; b=pXfidkTCTtttq7nxj80RsTd2b6oA1y+GURoyyMDJ1s5IbtLcBI/5AJA7LNdtr5Cw04nU 5J9zdb1b+UzXLVBhILNIrPKNohulT17DhIsMyLyjZRD29R8YEl1U1/zGtjA3exsnKT3dU RNEsITnrq5WJTqJbtxvLk8N425iagE+PdxphWk1h795iA3ihUhekV29tKoLw13bD3NnzS erKwQc3TgL6LT+ni9YXMhCtT2IZIe0o6yzkuFV4MQSabl7APHmmFxyzs4LFhyl2nVUnTc l2SrgbHizUid7g1Bx7+rH3oZmmbjOm/qMcJecfdXF2yBraJAlhTUo2sM/N7xsjoM8ew== 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=oGHLEmqq; 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 A7CD7606D809; Sat, 7 Nov 2026 22:00:35 +0000 (UTC) X-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=oGHLEmqq X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794088834; b=H8CtcSQYgirDW34bbmbsiP6ePUU1gK6LwyUGOV0lPedHsHggU3/7r4l1bNU6y6aeUjxZ UfX7HQGJ+DBSYNU7sVx5zI88WyKh5kkYTW7pgJ1thfBvXkDtgQwt4PUVdvjaBlLr8JRtU IzmsXjxczGK2g7uRbsr+PDgpo6d96RudG7WZfrUgnHhGzNcaNJwaCwwW8D3mE0btfQeUZ 1p3xzbD8AnuaiSXjjaEELiWsMr8teWv0a977N8NwnRYaTzCKGukm0W3a446yUuo9SGYxB 8mvuTvnbZSwB+yKOzH702Qbu2x5cvb66evyfxDDn0okwOPK+ZPAXP+Y8TOm7O6WC43w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794088834; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=VNZGPeMP1H9NcfpnWuuufaSVsJdMZpOEEwuaOwBXqj4=; b=aN/XUuySm6Wz/iCXAQxnlJbONmZb1J7fYsw2mtQCTMIIqSbswElKZmXz9H0hjQ7pUqRe RgEMOOSBm/7Mr6aU9zFEE7vnX8kLWoBE+oVPxAfBwRJNcVJ0PE6z2ipmUnhD7H3x8zzO8 NKvNos/XNGKz3O+7HsbtfVCy7W4pzBPeDtZnvGt99smz2/73bcH9N13xRff7wmu1Zd9PD o3vRNHGmbegB6ScEIKKSEca79Z89EKxTSDt2gxVMFP0IYiO8zKDEodVYQzLjV7xPGjiOm XG9nAP7rEJvhb2W1In68OGBP4VdMxNvOxIB7ikhG9Gkj0MZN9jmT1NVemnZbAtgwsTw== X-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=oGHLEmqq; arc=none 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 8610D606A32C; Sat, 7 Nov 2026 22:00:34 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F0BA1F0089F; Sat, 7 Nov 2026 22:00:33 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794088834; bh=VNZGPeMP1H9NcfpnWuuufaSVsJdMZpOEEwuaOwBXqj4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=oGHLEmqqvLjB/zQImYzHgqmIyidOSEwO86DvsCkcCp89QbT8EeaxtBOACUiP93jRX c3imQlcSm5oF0xRt1O1Omwe8e5xKJ3o2FnHB8lylBs+Sl7BJFh7oA+VklXWtsM89F7 Y3QfGjLijluCfjfP2E9TR796nYx/A18o2oNZqR55r7k8tZ2uS4dup1drDSapiBGi9R B5MRiHq31BPnaAqAEF4TAQxsrxX/3DQPyLXlCMPR9wveL+CFdZ+lc6y1eSqXazF2JY pHe9FY0TDUAgag/2MCOUjPesmSbhonY6uK1KsgnuFeaH80ZTJQ6QyYzYFyeGjwGAzc e/l9O76Ki8Ftg== X-Cc: sgarzare@redhat.com, bobbyeshleman@meta.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, mst@redhat.com, mhal@rbox.co, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, stable@vger.kernel.org X-In-Reply-To: <20261106-kbh3-1-022-fix-v2-v4-1-c7d36703814d@eldare.de> X-sashiko-severity: Medium 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