* [PATCH net] vsock/virtio: fix skb overhead overflow on 32-bit builds
@ 2026-05-21 12:47 Stefano Garzarella
2026-05-21 13:09 ` Michael S. Tsirkin
2026-05-21 17:13 ` David Laight
0 siblings, 2 replies; 3+ messages in thread
From: Stefano Garzarella @ 2026-05-21 12:47 UTC (permalink / raw)
To: netdev
Cc: Xuan Zhuo, Stefano Garzarella, Simon Horman, virtualization,
linux-kernel, kvm, Jakub Kicinski, Eugenio Pérez,
Paolo Abeni, Michael S. Tsirkin, David S. Miller, Jason Wang,
Stefan Hajnoczi, Eric Dumazet, stable
From: Stefano Garzarella <sgarzare@redhat.com>
On 32-bit architectures, both skb_queue_len() and SKB_TRUESIZE(0) evaluate
to 32-bit values. The multiplication can overflow before being assigned to
the u64 skb_overhead variable, making the skb overhead check ineffective.
Cast skb_queue_len() to u64 so the multiplication is always performed in
64-bit arithmetic.
This issue was reported by Sashiko while reviewing another patch.
Fixes: 059b7dbd20a6 ("vsock/virtio: fix potential unbounded skb queue")
Closes: https://sashiko.dev/#/patchset/20260518090656.134588-1-sgarzare%40redhat.com
Cc: stable@vger.kernel.org
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
net/vmw_vsock/virtio_transport_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index df3b418e0392..71198bf23fc4 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -417,7 +417,7 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,
static bool virtio_transport_inc_rx_pkt(struct virtio_vsock_sock *vvs,
u32 len)
{
- u64 skb_overhead = (skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0);
+ u64 skb_overhead = ((u64)skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0);
/* Allow at most buf_alloc * 2 total budget (payload + overhead),
* similar to how SO_RCVBUF is doubled to reserve space for sk_buff
--
2.54.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] vsock/virtio: fix skb overhead overflow on 32-bit builds
2026-05-21 12:47 [PATCH net] vsock/virtio: fix skb overhead overflow on 32-bit builds Stefano Garzarella
@ 2026-05-21 13:09 ` Michael S. Tsirkin
2026-05-21 17:13 ` David Laight
1 sibling, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2026-05-21 13:09 UTC (permalink / raw)
To: Stefano Garzarella
Cc: netdev, Xuan Zhuo, Simon Horman, virtualization, linux-kernel,
kvm, Jakub Kicinski, Eugenio Pérez, Paolo Abeni,
David S. Miller, Jason Wang, Stefan Hajnoczi, Eric Dumazet,
stable
On Thu, May 21, 2026 at 02:47:32PM +0200, Stefano Garzarella wrote:
> From: Stefano Garzarella <sgarzare@redhat.com>
>
> On 32-bit architectures, both skb_queue_len() and SKB_TRUESIZE(0) evaluate
> to 32-bit values. The multiplication can overflow before being assigned to
> the u64 skb_overhead variable, making the skb overhead check ineffective.
>
> Cast skb_queue_len() to u64 so the multiplication is always performed in
> 64-bit arithmetic.
>
> This issue was reported by Sashiko while reviewing another patch.
>
> Fixes: 059b7dbd20a6 ("vsock/virtio: fix potential unbounded skb queue")
> Closes: https://sashiko.dev/#/patchset/20260518090656.134588-1-sgarzare%40redhat.com
> Cc: stable@vger.kernel.org
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> net/vmw_vsock/virtio_transport_common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> index df3b418e0392..71198bf23fc4 100644
> --- a/net/vmw_vsock/virtio_transport_common.c
> +++ b/net/vmw_vsock/virtio_transport_common.c
> @@ -417,7 +417,7 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,
> static bool virtio_transport_inc_rx_pkt(struct virtio_vsock_sock *vvs,
> u32 len)
> {
> - u64 skb_overhead = (skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0);
> + u64 skb_overhead = ((u64)skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0);
>
> /* Allow at most buf_alloc * 2 total budget (payload + overhead),
> * similar to how SO_RCVBUF is doubled to reserve space for sk_buff
> --
> 2.54.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] vsock/virtio: fix skb overhead overflow on 32-bit builds
2026-05-21 12:47 [PATCH net] vsock/virtio: fix skb overhead overflow on 32-bit builds Stefano Garzarella
2026-05-21 13:09 ` Michael S. Tsirkin
@ 2026-05-21 17:13 ` David Laight
1 sibling, 0 replies; 3+ messages in thread
From: David Laight @ 2026-05-21 17:13 UTC (permalink / raw)
To: Stefano Garzarella
Cc: netdev, Xuan Zhuo, Simon Horman, virtualization, linux-kernel,
kvm, Jakub Kicinski, Eugenio Pérez, Paolo Abeni,
Michael S. Tsirkin, David S. Miller, Jason Wang, Stefan Hajnoczi,
Eric Dumazet, stable
On Thu, 21 May 2026 14:47:32 +0200
Stefano Garzarella <sgarzare@redhat.com> wrote:
> From: Stefano Garzarella <sgarzare@redhat.com>
>
> On 32-bit architectures, both skb_queue_len() and SKB_TRUESIZE(0) evaluate
> to 32-bit values. The multiplication can overflow before being assigned to
> the u64 skb_overhead variable, making the skb overhead check ineffective.
>
> Cast skb_queue_len() to u64 so the multiplication is always performed in
> 64-bit arithmetic.
>
> This issue was reported by Sashiko while reviewing another patch.
>
> Fixes: 059b7dbd20a6 ("vsock/virtio: fix potential unbounded skb queue")
> Closes: https://sashiko.dev/#/patchset/20260518090656.134588-1-sgarzare%40redhat.com
> Cc: stable@vger.kernel.org
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
> net/vmw_vsock/virtio_transport_common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> index df3b418e0392..71198bf23fc4 100644
> --- a/net/vmw_vsock/virtio_transport_common.c
> +++ b/net/vmw_vsock/virtio_transport_common.c
> @@ -417,7 +417,7 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,
> static bool virtio_transport_inc_rx_pkt(struct virtio_vsock_sock *vvs,
> u32 len)
> {
> - u64 skb_overhead = (skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0);
> + u64 skb_overhead = ((u64)skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0);
I was thinking this should use mul_u32_u32().
But that is all moot.
'skb_overhead' is a memory size in bytes, 'unsigned long' it more than big enough.
No need for 64bit maths on 32bit.
-- David
>
> /* Allow at most buf_alloc * 2 total budget (payload + overhead),
> * similar to how SO_RCVBUF is doubled to reserve space for sk_buff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-21 17:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-21 12:47 [PATCH net] vsock/virtio: fix skb overhead overflow on 32-bit builds Stefano Garzarella
2026-05-21 13:09 ` Michael S. Tsirkin
2026-05-21 17:13 ` David Laight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox