Linux virtualization list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bartłomiej Dmitruk" <bartlomiej.dmitruk@isec.pl>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>,
	virtualization@lists.linux.dev, kvm@vger.kernel.org
Subject: Re: [RFC PATCH] vsock: keep SOCK_SEQPACKET message boundaries on interrupted send
Date: Fri, 18 Sep 2026 22:01:29 +0000	[thread overview]
Message-ID: <20260918220129.954E71F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260917220101.55744-1-bartlomiej.dmitruk@isec.pl>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] vsock: infinite wait for oversized SOCK_SEQPACKET messages
--

commit 05c4fa125400dc8e76be397870f9646f61e7a31d
Author: Bartłomiej Dmitruk <bartlomiej.dmitruk@isec.pl>

vsock: keep SOCK_SEQPACKET message boundaries on interrupted send

A credit-limited SOCK_SEQPACKET send transmits fragments as credit becomes
available, and the VIRTIO_VSOCK_SEQ_EOM flag is set only on the fragment
where msg_data_left() reaches 0. If vsock_connectible_sendmsg() exits via
out_err after a partial send, the orphaned fragments are silently merged
into the next message.

> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
> index f840498b58afb..3f7f01a7b8cbd 100644
> --- a/net/vmw_vsock/af_vsock.c
> +++ b/net/vmw_vsock/af_vsock.c
> @@ -2250,9 +2250,16 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg,
>  
>  	while (total_written < len) {
>  		ssize_t written;
> +		/* For SEQPACKET wait until the whole remaining message fits, so
> +		 * it is enqueued atomically.  A credit-limited partial send that
> +		 * then errors out (e.g. -EINTR) would otherwise leave EOM-less
> +		 * fragments that the peer merges into the next message.
> +		 */
> +		s64 min_space = (sk->sk_type == SOCK_SEQPACKET) ?
> +				(s64)(len - total_written) : 1;
>  
>  		add_wait_queue(sk_sleep(sk), &wait);
> -		while (vsock_stream_has_space(vsk) == 0 &&
> +		while (vsock_stream_has_space(vsk) < min_space &&

[Severity: High]
Does this code introduce an infinite wait for oversized SOCK_SEQPACKET
messages?

If an application attempts to send a message larger than the transport's
maximum transmit buffer size, min_space will be set to the full message
length.

Because vsock_stream_has_space() is strictly upper-bounded by the buffer
allocation, the condition vsock_stream_has_space(vsk) < min_space will
never become false for these oversized messages.

The transport's -EMSGSIZE validation (such as in
virtio_transport_seqpacket_enqueue()) will never be reached because the
thread will block beforehand. A thread could hang indefinitely in an
interruptible sleep (unless a signal or timeout interrupts it) instead of
immediately returning an -EMSGSIZE error.

Could a malicious peer or guest VM advertise a very small peer_buf_alloc
and cause a host daemon that writes standard-sized messages to hang
unrecoverably?

>  		       sk->sk_err == 0 &&
>  		       !(sk->sk_shutdown & SEND_SHUTDOWN) &&
>  		       !(vsk->peer_shutdown & RCV_SHUTDOWN)) {

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260917220101.55744-1-bartlomiej.dmitruk@isec.pl?part=1

      reply	other threads:[~2026-09-18 22:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 22:01 [RFC PATCH] vsock: keep SOCK_SEQPACKET message boundaries on interrupted send Bartłomiej Dmitruk
2026-09-18 22:01 ` sashiko-bot [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=20260918220129.954E71F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bartlomiej.dmitruk@isec.pl \
    --cc=eperezma@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=virtualization@lists.linux.dev \
    /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