* [PATCH net] Revert "vsock/virtio: fix skb overhead overflow on 32-bit builds"
@ 2026-05-27 16:48 Stefano Garzarella
2026-05-27 16:49 ` Michael S. Tsirkin
2026-05-27 16:54 ` Stefano Garzarella
0 siblings, 2 replies; 5+ messages in thread
From: Stefano Garzarella @ 2026-05-27 16:48 UTC (permalink / raw)
To: netdev; +Cc: Stefano Garzarella, David Laight, Michael S. Tsirkin
From: Stefano Garzarella <sgarzare@redhat.com>
This reverts commit 4157501b9a8f ("vsock/virtio: fix skb overhead
overflow on 32-bit builds"). The fix was semantically correct (although
it would have been better to use mul_u32_u32(), as David pointed out),
but in practice we are estimating the memory used to allocate the SKBs,
and this will never cause a 32-bit variable to overflow on a 32-bit
system, since the memory would have run out long before that. On 64-bit,
SKB_TRUESIZE() already evaluates to size_t, so the multiplication is
already in 64-bit arithmetic without the cast.
Let's revert this to avoid unnecessary 64-bit multiplies on the
per-packet receive path on 32-bit systems.
Reported-by: David Laight <david.laight.linux@gmail.com>
Closes: https://lore.kernel.org/netdev/20260523173557.5cc4f4f6@pumpkin
Suggested-by: "Michael S. Tsirkin" <mst@redhat.com>
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 b143290a311d..d4d26fba9e37 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 = ((u64)skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0);
+ u64 skb_overhead = (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] 5+ messages in thread
* Re: [PATCH net] Revert "vsock/virtio: fix skb overhead overflow on 32-bit builds"
2026-05-27 16:48 [PATCH net] Revert "vsock/virtio: fix skb overhead overflow on 32-bit builds" Stefano Garzarella
@ 2026-05-27 16:49 ` Michael S. Tsirkin
2026-05-27 16:54 ` Stefano Garzarella
1 sibling, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2026-05-27 16:49 UTC (permalink / raw)
To: Stefano Garzarella; +Cc: netdev, David Laight
On Wed, May 27, 2026 at 06:48:43PM +0200, Stefano Garzarella wrote:
> From: Stefano Garzarella <sgarzare@redhat.com>
>
> This reverts commit 4157501b9a8f ("vsock/virtio: fix skb overhead
> overflow on 32-bit builds"). The fix was semantically correct (although
> it would have been better to use mul_u32_u32(), as David pointed out),
> but in practice we are estimating the memory used to allocate the SKBs,
> and this will never cause a 32-bit variable to overflow on a 32-bit
> system, since the memory would have run out long before that. On 64-bit,
> SKB_TRUESIZE() already evaluates to size_t, so the multiplication is
> already in 64-bit arithmetic without the cast.
>
> Let's revert this to avoid unnecessary 64-bit multiplies on the
> per-packet receive path on 32-bit systems.
>
> Reported-by: David Laight <david.laight.linux@gmail.com>
> Closes: https://lore.kernel.org/netdev/20260523173557.5cc4f4f6@pumpkin
> Suggested-by: "Michael S. Tsirkin" <mst@redhat.com>
> 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 b143290a311d..d4d26fba9e37 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 = ((u64)skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0);
> + u64 skb_overhead = (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] 5+ messages in thread
* Re: [PATCH net] Revert "vsock/virtio: fix skb overhead overflow on 32-bit builds"
2026-05-27 16:48 [PATCH net] Revert "vsock/virtio: fix skb overhead overflow on 32-bit builds" Stefano Garzarella
2026-05-27 16:49 ` Michael S. Tsirkin
@ 2026-05-27 16:54 ` Stefano Garzarella
2026-05-27 16:56 ` Michael S. Tsirkin
1 sibling, 1 reply; 5+ messages in thread
From: Stefano Garzarella @ 2026-05-27 16:54 UTC (permalink / raw)
To: netdev, Jakub Kicinski, Paolo Abeni; +Cc: David Laight, Michael S. Tsirkin
On Wed, May 27, 2026 at 06:48:43PM +0200, Stefano Garzarella wrote:
>From: Stefano Garzarella <sgarzare@redhat.com>
>
>This reverts commit 4157501b9a8f ("vsock/virtio: fix skb overhead
>overflow on 32-bit builds"). The fix was semantically correct (although
>it would have been better to use mul_u32_u32(), as David pointed out),
>but in practice we are estimating the memory used to allocate the SKBs,
>and this will never cause a 32-bit variable to overflow on a 32-bit
>system, since the memory would have run out long before that. On 64-bit,
>SKB_TRUESIZE() already evaluates to size_t, so the multiplication is
>already in 64-bit arithmetic without the cast.
>
>Let's revert this to avoid unnecessary 64-bit multiplies on the
>per-packet receive path on 32-bit systems.
>
>Reported-by: David Laight <david.laight.linux@gmail.com>
>Closes: https://lore.kernel.org/netdev/20260523173557.5cc4f4f6@pumpkin
>Suggested-by: "Michael S. Tsirkin" <mst@redhat.com>
>Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
>---
> net/vmw_vsock/virtio_transport_common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
aaarg, something wrong on my new setup, CC list was missing several
people and mailing lists, including LKML. Please let me know if I should
resend this.
Sorry for the noise,
Stefano
>
>diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
>index b143290a311d..d4d26fba9e37 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 = ((u64)skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0);
>+ u64 skb_overhead = (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] 5+ messages in thread
* Re: [PATCH net] Revert "vsock/virtio: fix skb overhead overflow on 32-bit builds"
2026-05-27 16:54 ` Stefano Garzarella
@ 2026-05-27 16:56 ` Michael S. Tsirkin
2026-05-27 17:00 ` Stefano Garzarella
0 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2026-05-27 16:56 UTC (permalink / raw)
To: Stefano Garzarella; +Cc: netdev, Jakub Kicinski, Paolo Abeni, David Laight
On Wed, May 27, 2026 at 06:54:21PM +0200, Stefano Garzarella wrote:
> On Wed, May 27, 2026 at 06:48:43PM +0200, Stefano Garzarella wrote:
> > From: Stefano Garzarella <sgarzare@redhat.com>
> >
> > This reverts commit 4157501b9a8f ("vsock/virtio: fix skb overhead
> > overflow on 32-bit builds"). The fix was semantically correct (although
> > it would have been better to use mul_u32_u32(), as David pointed out),
> > but in practice we are estimating the memory used to allocate the SKBs,
> > and this will never cause a 32-bit variable to overflow on a 32-bit
> > system, since the memory would have run out long before that. On 64-bit,
> > SKB_TRUESIZE() already evaluates to size_t, so the multiplication is
> > already in 64-bit arithmetic without the cast.
> >
> > Let's revert this to avoid unnecessary 64-bit multiplies on the
> > per-packet receive path on 32-bit systems.
> >
> > Reported-by: David Laight <david.laight.linux@gmail.com>
> > Closes: https://lore.kernel.org/netdev/20260523173557.5cc4f4f6@pumpkin
> > Suggested-by: "Michael S. Tsirkin" <mst@redhat.com>
> > Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> > ---
> > net/vmw_vsock/virtio_transport_common.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
>
> aaarg, something wrong on my new setup, CC list was missing several people
> and mailing lists, including LKML. Please let me know if I should resend
> this.
>
> Sorry for the noise,
> Stefano
yea just do it. Put PATCH resend in the subj.
> >
> > diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> > index b143290a311d..d4d26fba9e37 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 = ((u64)skb_queue_len(&vvs->rx_queue) + 1) * SKB_TRUESIZE(0);
> > + u64 skb_overhead = (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] 5+ messages in thread
* Re: [PATCH net] Revert "vsock/virtio: fix skb overhead overflow on 32-bit builds"
2026-05-27 16:56 ` Michael S. Tsirkin
@ 2026-05-27 17:00 ` Stefano Garzarella
0 siblings, 0 replies; 5+ messages in thread
From: Stefano Garzarella @ 2026-05-27 17:00 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: netdev, Jakub Kicinski, Paolo Abeni, David Laight
On Wed, 27 May 2026 at 18:57, Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Wed, May 27, 2026 at 06:54:21PM +0200, Stefano Garzarella wrote:
> > On Wed, May 27, 2026 at 06:48:43PM +0200, Stefano Garzarella wrote:
> > > From: Stefano Garzarella <sgarzare@redhat.com>
> > >
> > > This reverts commit 4157501b9a8f ("vsock/virtio: fix skb overhead
> > > overflow on 32-bit builds"). The fix was semantically correct (although
> > > it would have been better to use mul_u32_u32(), as David pointed out),
> > > but in practice we are estimating the memory used to allocate the SKBs,
> > > and this will never cause a 32-bit variable to overflow on a 32-bit
> > > system, since the memory would have run out long before that. On 64-bit,
> > > SKB_TRUESIZE() already evaluates to size_t, so the multiplication is
> > > already in 64-bit arithmetic without the cast.
> > >
> > > Let's revert this to avoid unnecessary 64-bit multiplies on the
> > > per-packet receive path on 32-bit systems.
> > >
> > > Reported-by: David Laight <david.laight.linux@gmail.com>
> > > Closes: https://lore.kernel.org/netdev/20260523173557.5cc4f4f6@pumpkin
> > > Suggested-by: "Michael S. Tsirkin" <mst@redhat.com>
> > > Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> > > ---
> > > net/vmw_vsock/virtio_transport_common.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > aaarg, something wrong on my new setup, CC list was missing several people
> > and mailing lists, including LKML. Please let me know if I should resend
> > this.
> >
> > Sorry for the noise,
> > Stefano
>
>
> yea just do it. Put PATCH resend in the subj.
Should I carry your Acked-by ?
(maybe better no, otherwise should be a v2)
Thanks,
Stefano
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-05-27 17:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27 16:48 [PATCH net] Revert "vsock/virtio: fix skb overhead overflow on 32-bit builds" Stefano Garzarella
2026-05-27 16:49 ` Michael S. Tsirkin
2026-05-27 16:54 ` Stefano Garzarella
2026-05-27 16:56 ` Michael S. Tsirkin
2026-05-27 17:00 ` Stefano Garzarella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox