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=1796488655; b=AjqtN9yYLqkGWUmVyhhbpO5WJfE+6WkFIyL9s6jrG5KaSa3LdenxDEVDXIq6ivslSia+ 2NazkvEYEiblXfvOkVY4Dk+KKCWSN+wlcTMveX89EIIZ0AsZ5zNMkxuMUEO0rj+dVbiRY lDiJdwj+By6aUJJpdGBwRgYYRxUAzTfTM7lo8QwhpcwpD8V8CxhEcViARzTioOd6EKvBh StbX/ygsPV4D1/LOURNtaKIqLNrorzubPE5Vwg7lrNjbTtFoGtwaQsqk8XC/gkY8lc3yu R1OVRb+6uOea88o1I4sISnpbDddbXnwbMP+77hueWBtIQN3PvD4PHdKGQS0ei2mLwNA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796488655; 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=dcWrSXL97IF9fu5rs716q3FXeSiaePWwIkV3HXRLTFo=; b=NONa6blgC6LEo/QX3dN0lbtYxUYxgI0NhNKSxQI2fYTx6SIc6v5K5VeAbTYw2XSEErES IFb1JXkvMPfW8Rd2N0sOIgn1iWp0thUXy0OAIhVe4/drBy1zRsiNqoqhNzZX+SeAyma33 E1gOm17LHXauMD0yeVCo/xlEyvpRnTxoDVZ7Vgx7yfL56O5CjKNztwSVUSR/42mQ2aBrG 1izlkM4b6r3NzZ66Xo7O1RAUCpeIiMxP1YXFTfXKPfhwiwVGd3+s/D0IlqhT4X98xzFGW BxnemsXfmiLitVJDtt3n3HT5Ik3B3Vo2gexCyGGsvs3I3IZ7nV5mKK/39f0AQTTrFzw== 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=MiaXPUwP; 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 D3183606A31F; Sat, 5 Dec 2026 16:37:35 +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=MiaXPUwP Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9A351F0092B; Sat, 5 Dec 2026 16:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796488655; bh=dcWrSXL97IF9fu5rs716q3FXeSiaePWwIkV3HXRLTFo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=MiaXPUwParnRn5eYLfcX7z7if6ohcjikUiWBSuWbvL+t9X/DzcrdnkeDnraX+ddVt DxuxN2JZ4+RDyMinFrTMpNnScc9fM4PNi+EUwA2Cl1PSxR396Yf7ewbDeE9tjavYA8 dapZoXPbGoJYiCAqOZi/litCX7tZTzbKg04AcDbre9nEPz0PLMtFsaxgABuLARqbkd LaovzXUM0P3Shm5X3cU/aXe5afrlYQXzZ9AbzVH/XFc0bWhmk4mzRhVRBHYtl7yao/ R0LbRD2yrRuQ0tCGdncXNfQjoPmdTyvefAcDn50WleTg6Ii4sGNtencLuBVMkRkwGg 4IKjey5QYhsaw== Subject: Re: [PATCH net] vsock: avoid narrowing the receive queue length to int From: netdev-bot+sashiko@kernel.org To: ryosuke@ikotaslabs.com Cc: sgarzare@redhat.com, bobbyeshleman@meta.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, arseny.krasnov@kaspersky.com Date: Sat, 05 Dec 2026 16:37:34 +0000 Message-ID: <179648865425.3146.7234122413294045831@kernel.org> In-Reply-To: References: X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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 patch is titled "vsock: avoid narrowing the receive queue length to int", but it fixes only vsock_connectible_wait_data(). -- vsock: avoid narrowing the receive queue length to int For virtio stream sockets, vsock_connectible_has_data() returns the queued byte count as an s64. vsock_connectible_wait_data() could narrow that count to a negative int, and its recvmsg callers would then report an error even though data was available. The patch makes vsock_connectible_wait_data() return 1 when data is available. > diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c > index 1d7d53542724f..3bfc0bf9bd1de 100644 > --- a/net/vmw_vsock/af_vsock.c > +++ b/net/vmw_vsock/af_vsock.c > @@ -2468,7 +2468,7 @@ static int vsock_connectible_wait_data(struct sock *sk, > if (data < 0) > return -ENOMEM; > > - return data; > + return data > 0; > } [Severity: Medium] The subject says "avoid narrowing the receive queue length to int", but the SIOCINQ ioctl in the same file appears to narrow the same value. Should that path be fixed as well? In vsock_do_ioctl(), arg is an int __user *: net/vmw_vsock/af_vsock.c:vsock_do_ioctl() { ... case SIOCINQ: { ssize_t n_bytes; ... n_bytes = vsock_stream_has_data(vsk); if (n_bytes < 0) { ret = n_bytes; break; } ret = put_user(n_bytes, arg); break; } ... } The n_bytes < 0 check only rejects error values. put_user() then stores the ssize_t into an int. With virtio, virtio_transport_notify_buffer_size() clamps buf_alloc only to VIRTIO_VSOCK_MAX_BUF_SIZE (0xFFFFFFFF). An unprivileged user can raise it with SO_VM_SOCKETS_BUFFER_MAX_SIZE and SO_VM_SOCKETS_BUFFER_SIZE, so rx_bytes can go past INT_MAX. That is the same condition this patch handles. When it does, can ioctl(SIOCINQ/FIONREAD) give userspace a negative or wrapped byte count? vsock_stream_inq_hint() in the same file already clamps the same value: data = vsock_stream_has_data(vsk); if (data < 0) return -1; if (data > 0) return min_t(s64, data, INT_MAX); Would a similar clamp fit the SIOCINQ case? This patch does fix the recvmsg error described in the commit body. The SIOCINQ code comes from an earlier commit, so a separate patch with its own Fixes: tag may work better. Otherwise, could the commit message say that only the vsock_connectible_wait_data() path is covered? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/CAN2NGG68dKx9L5sezmDhBNizJVAMGUPEnY0S78---NLRa-frUA%40mail.gmail.com