Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Stefano Garzarella" <sgarzare@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH net 1/2] vsock/virtio: collapse receive queue under memory pressure
Date: Sat, 27 Jun 2026 13:48:47 +0000	[thread overview]
Message-ID: <20260627134848.20A4F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626134823.206676-2-sgarzare@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] If `skb_copy_bits()` fails during receive queue collapse, the error path drops `new_skb` without updating `rx_bytes` and `buf_used`, causing a permanent socket credit leak and stream corruption.
--

commit 7c26a8d9c487a00892dd5ed3c4bb090956e769a6
Author: Stefano Garzarella <sgarzare@redhat.com>

vsock/virtio: collapse receive queue under memory pressure

This patch adds a mechanism to collapse small packets in the receive queue
into larger, compact SKBs when memory pressure prevents enqueueing new
packets. This reduces SKB overhead and avoids connection resets during large
transfers under backpressure.

Closes: https://lore.kernel.org/netdev/618701dd023e$063de350$12b9a9f0$@gmail.com/

> diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> index 09475007165b3..304ea424995d4 100644
> --- a/net/vmw_vsock/virtio_transport_common.c
> +++ b/net/vmw_vsock/virtio_transport_common.c
[ ... ]
> @@ -420,6 +420,137 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,
[ ... ]
> +/* Called under lock_sock when skb overhead exceeds the budget. */
> +static void virtio_transport_collapse_rx_queue(struct virtio_vsock_sock *vvs)
> +{
[ ... ]
> +		/* Cannot fail since src_off/src_len are within bounds, but if
> +		 * it does, discard new_skb to avoid queuing corrupted data.
> +		 */
> +		if (WARN_ON_ONCE(skb_copy_bits(skb, src_off,
> +					       skb_put(new_skb, src_len),
> +					       src_len))) {
> +			kfree_skb(new_skb);
> +			new_skb = NULL;
> +			goto out;
> +		}
> +
> +		le32_add_cpu(&virtio_vsock_hdr(new_skb)->len, src_len);
> +		virtio_vsock_hdr(new_skb)->flags |= hdr->flags;
> +
> +next:
> +		__skb_unlink(skb, &vvs->rx_queue);
> +		if (keep)
> +			__skb_queue_tail(&new_queue, skb);
> +		else
> +			consume_skb(skb);
> +	}

[Severity: Medium]
If new_skb successfully absorbed data from a previous SKB in an earlier
iteration before skb_copy_bits fails on a subsequent SKB, does
kfree_skb(new_skb) drop that accumulated data without updating vvs->rx_bytes
and vvs->buf_used?

When consume_skb(skb) runs on those earlier iterations, the original SKBs are
freed. If this error path later frees new_skb, the previously merged payloads
are permanently lost, but the socket accounting still includes them. Will
this leak receive buffer credit and eventually cause the socket to stall?

> +out:
> +	if (new_skb)
> +		__skb_queue_tail(&new_queue, new_skb);
> +
> +	skb_queue_splice(&new_queue, &vvs->rx_queue);
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260626134823.206676-1-sgarzare@redhat.com?part=1

  reply	other threads:[~2026-06-27 13:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 13:48 [PATCH net 0/2] vsock/virtio: collapse receive queue under memory pressure Stefano Garzarella
2026-06-26 13:48 ` [PATCH net 1/2] " Stefano Garzarella
2026-06-27 13:48   ` sashiko-bot [this message]
2026-06-30  9:53   ` Paolo Abeni
2026-07-01 10:13     ` Stefano Garzarella
2026-07-01 16:34   ` Bobby Eshleman
2026-06-26 13:48 ` [PATCH net 2/2] vsock/test: add test for small packets under pressure Stefano Garzarella

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=20260627134848.20A4F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sgarzare@redhat.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