Netdev List
 help / color / mirror / Atom feed
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
Subject: Re: [PATCH net] vsock: avoid narrowing the receive queue length to int
Date: Sat, 05 Dec 2026 16:37:34 +0000	[thread overview]
Message-ID: <179648865425.3146.7234122413294045831@kernel.org> (raw)
In-Reply-To: <CAN2NGG68dKx9L5sezmDhBNizJVAMGUPEnY0S78---NLRa-frUA@mail.gmail.com>

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

      parent reply	other threads:[~2026-12-05 16:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 16:35 [PATCH net] vsock: avoid narrowing the receive queue length to int Ryosuke Iwahashi
2026-12-04 16:37 ` netdev-bot+sinfo
2026-12-04 16:39   ` Ryosuke Iwahashi
2026-12-05 16:37 ` netdev-bot+sashiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179648865425.3146.7234122413294045831@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=arseny.krasnov@kaspersky.com \
    --cc=bobbyeshleman@meta.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ryosuke@ikotaslabs.com \
    --cc=sgarzare@redhat.com \
    --cc=virtualization@lists.linux.dev \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox