The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Junyoung Jang <graypanda.inzag@gmail.com>,
	 Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	 Jason Wang <jasowangio@gmail.com>,
	 Andrew Lunn <andrew+netdev@lunn.ch>,
	 "David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@kernel.org>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>
Cc: Junyoung Jang <graypanda.inzag@gmail.com>,
	 Simon Horman <horms@kernel.org>,  Shuah Khan <shuah@kernel.org>,
	 Gwanhyun Lee <gwanhyunlee@gmail.com>,
	 netdev@vger.kernel.org,  linux-kernel@vger.kernel.org,
	 linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net v3 2/4] tap: clamp zero-copy copylen to remaining payload length
Date: Thu, 19 Nov 2026 16:11:29 -0500	[thread overview]
Message-ID: <willemdebruijn.kernel.373ae703fcfde@gmail.com> (raw)
In-Reply-To: <20261119144241.360238-3-graypanda.inzag@gmail.com>

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@gmail.com>
> Signed-off-by: Gwanhyun Lee <gwanhyunlee@gmail.com>
> Signed-off-by: Junyoung Jang <graypanda.inzag@gmail.com>

Reviewed-by: Willem de Bruijn <willemb@google.com>

  reply	other threads:[~2026-11-19 21:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 14:42 [PATCH net v3 0/4] tun, tap: bound vnet header and skb copy lengths Junyoung Jang
2026-11-19 14:42 ` [PATCH net v3 1/4] net: tun_vnet: validate hdr_len after skipping header padding Junyoung Jang
2026-11-19 20:10   ` Willem de Bruijn
2026-11-19 14:42 ` [PATCH net v3 2/4] tap: clamp zero-copy copylen to remaining payload length Junyoung Jang
2026-11-19 21:11   ` Willem de Bruijn [this message]
2026-11-19 14:42 ` [PATCH net v3 3/4] tun: " Junyoung Jang
2026-11-19 21:13   ` Willem de Bruijn
2026-11-19 14:42 ` [PATCH net v3 4/4] selftests: net: check padded vnet hdr_len in tun and tap Junyoung Jang
2026-11-19 21:15   ` Willem de Bruijn

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=willemdebruijn.kernel.373ae703fcfde@gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=graypanda.inzag@gmail.com \
    --cc=gwanhyunlee@gmail.com \
    --cc=horms@kernel.org \
    --cc=jasowangio@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /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