From: sashiko-bot@kernel.org
To: "Bartłomiej Dmitruk" <bartlomiej.dmitruk@isec.pl>
Cc: virtualization@lists.linux.dev, kvm@vger.kernel.org,
"Eugenio Perez" <eperezma@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH v2] vsock: keep SOCK_SEQPACKET message boundaries on interrupted send
Date: Sun, 20 Sep 2026 12:31:20 +0000 [thread overview]
Message-ID: <20260920123120.F29901F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260919122916.28226-1-bartlomiej.dmitruk@isec.pl>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] vsock: vhost_transport missing seqpacket_max_size causes indefinite hang
- [Medium] vsock: seqpacket wait loop hangs if peer dynamically shrinks buffer
--
commit faa45a951be47102c344158967938f9970eb6270
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 already-transmitted fragments carry no EOM.
The receiver only advances msg_count / sets msg_ready on an EOM skb, so the
orphaned fragments are silently merged into the next message, violating
SOCK_SEQPACKET atomicity.
> diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h
> index 5549298c1ec6b..d94c613ef604b 100644
> --- a/include/net/af_vsock.h
> +++ b/include/net/af_vsock.h
> @@ -143,6 +143,7 @@ struct vsock_transport {
> size_t len);
> bool (*seqpacket_allow)(struct vsock_sock *vsk, u32 remote_cid);
> u32 (*seqpacket_has_data)(struct vsock_sock *vsk);
> + u32 (*seqpacket_max_size)(struct vsock_sock *vsk);
>
[Severity: High]
Does vhost_transport in drivers/vhost/vsock.c also need to implement this
callback?
It implements SOCK_SEQPACKET, but appears to omit the newly required
seqpacket_max_size() callback. If the callback is NULL, the max size check in
vsock_connectible_sendmsg() is skipped. If a user application sends a
SOCK_SEQPACKET message larger than the transport's buffer size, this will
cause an indefinite wait loop because the space can never reach min_space.
> /* Notification. */
> int (*notify_poll_in)(struct vsock_sock *, size_t, bool *);
[ ... ]
> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
> index 9b71479a2b295..01fc9ac6fa2b5 100644
> --- a/net/vmw_vsock/af_vsock.c
> +++ b/net/vmw_vsock/af_vsock.c
> @@ -2250,9 +2250,32 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg,
>
> while (total_written < len) {
> ssize_t written;
> + s64 min_space;
> +
> + if (sk->sk_type == SOCK_SEQPACKET) {
[ ... ]
> + if (transport->seqpacket_max_size &&
> + len > transport->seqpacket_max_size(vsk)) {
> + err = -EMSGSIZE;
> + goto out_err;
> + }
> + min_space = len - total_written;
> + } else {
> + min_space = 1;
> + }
>
> add_wait_queue(sk_sleep(sk), &wait);
> - while (vsock_stream_has_space(vsk) == 0 &&
> + while (vsock_stream_has_space(vsk) < min_space &&
[Severity: Medium]
What happens if the remote peer dynamically shrinks its receive buffer to a
size smaller than min_space while the sender is waiting in this loop?
Since the seqpacket_max_size() check is outside the sleep loop, if the space
ceiling shrinks below min_space during the wait, the sender could be
permanently trapped without re-evaluating the max size.
> sk->sk_err == 0 &&
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260919122916.28226-1-bartlomiej.dmitruk@isec.pl?part=1
next prev parent reply other threads:[~2026-09-20 12:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 12:29 [PATCH v2] vsock: keep SOCK_SEQPACKET message boundaries on interrupted send Bartłomiej Dmitruk
2026-09-20 9:08 ` David Laight
2026-09-20 12:31 ` sashiko-bot [this message]
2026-09-23 12:46 ` netdev-bot+sashiko
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=20260920123120.F29901F000FF@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.