Re: [PATCH net v3 2/4] tap: clamp zero-copy copylen to remaining payload length
From: Willem de Bruijn
Date: Thu Nov 19 2026 - 16:11:43 EST
Junyoung Jang wrote:
> tap_get_user() chooses GOODCOPY_LEN when the virtio hdr_len is zero,
> without limiting it to the payload remaining after the virtio header.
> A 246-byte padded header and a 14-byte Ethernet frame give vhost-net a
> 260-byte TX descriptor, above its 256-byte zero-copy threshold. The
> 128-byte skb head then contains only 14 copied bytes; the rest can be
> transmitted as stale kernel heap contents.
>
> The original macvtap zero-copy support introduced the copylen choice.
> Commit bab632d69ee4 ("vhost: vhost TX zero-copy support") connected
> the in-tree vhost-net caller, so this case predates the v6.15 header
> validation regression.
>
> Clamp copylen to the remaining payload before allocating the skb. This
> also covers cases where the entire frame fits in the skb's linear area.
>
> An AI-assisted code review found this issue. An x86-64 QEMU/vhost-net
> reproducer observed a 128-byte frame from 14 input bytes, including a
> 114-byte uncopied tail. The patched kernel delivered 14 bytes in the
> same test and in 400 repeated short-frame sends.
If respinning:
tun/tap's vnet_hdr_sz must be at least ~129. That is far larger than any
header vhost would negotiate, so it only happens when the VMM sets
vnet_hdr_sz inconsistently with the vhost features. The guest controls the
packet contents but not vnet_hdr_sz, so a guest can't trigger this on its
own against a sane VMM.
> Fixes: 97bc3633bec7 ("macvtap: macvtapTX zero-copy support")
> Co-developed-by: Gwanhyun Lee <gwanhyunlee@xxxxxxxxx>
> Signed-off-by: Gwanhyun Lee <gwanhyunlee@xxxxxxxxx>
> Signed-off-by: Junyoung Jang <graypanda.inzag@xxxxxxxxx>
Reviewed-by: Willem de Bruijn <willemb@xxxxxxxxxx>