From: netdev-bot+sashiko@kernel.org
To: graypanda.inzag@gmail.com
Cc: willemdebruijn.kernel@gmail.com, jasowangio@gmail.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] tap: clamp zero-copy copylen to remaining payload length
Date: Tue, 17 Nov 2026 17:03:53 +0000 [thread overview]
Message-ID: <179493503300.3136.4070504744747730772@kernel.org> (raw)
In-Reply-To: <20261113164903.785381-1-graypanda.inzag@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The Fixes: trailer in the commit message is an unfilled
template: `Fixes: <12자리_커밋_해시> ("<원본_커밋_제목>")`.
- [Low] The commit message and the new comment ("A padded vnet header can
leave fewer payload bytes than GOODCOPY_LEN.") describe only the…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but tun_get_user()
in drivers/net/tun.c has the same unbounded zero-copy copylen.
--
tap: clamp zero-copy copylen to remaining payload length
This commit clamps copylen in the zero-copy TX branch of tap_get_user()
to the remaining payload length. Without the clamp, a padded vnet header
can leave fewer frame bytes than GOODCOPY_LEN, and the uninitialized
part of the skb linear head is then transmitted.
> Fixes: <12자리_커밋_해시> ("<원본_커밋_제목>")
[Severity: Medium]
This trailer looks like an unfilled template. The placeholders translate
to "<12-digit commit hash>" and "<original commit title>".
The trailer sits above the --- separator, so git am keeps it in the
applied commit, and stable tooling can't use it to select the fix for
backporting.
Could this cite the commit that introduced the zero-copy copylen sizing
in tap_get_user()? That would be either the macvtap zerocopy support or
the later copylen clamp rework.
> diff --git a/drivers/net/tap.c b/drivers/net/tap.c
> index 2f19fb07bb2d4..b1f8776a5ca57 100644
> --- a/drivers/net/tap.c
> +++ b/drivers/net/tap.c
> @@ -608,6 +608,8 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control,
> struct iov_iter i;
>
> copylen = clamp(hdr_len ?: GOODCOPY_LEN, ETH_HLEN, good_linear);
> + /* A padded vnet header can leave fewer payload bytes than GOODCOPY_LEN. */
> + copylen = min_t(unsigned long, copylen, len);
[Severity: Low]
The comment and the commit message only describe the case where
hdr_len == 0 falls back to GOODCOPY_LEN. Doesn't this min_t() also close
a second trigger?
__tun_vnet_hdr_get() checks hdr_len against the iterator count before it
skips the header padding:
drivers/net/tun_vnet.h:__tun_vnet_hdr_get() {
...
if (hdr_len > iov_iter_count(from))
return -EINVAL;
iov_iter_advance(from, sz - parsed_size);
...
}
That means a guest-supplied hdr_len is bounded by payload plus padding,
not by len. Before this patch, with a large TUNSETVNETHDRSZ,
clamp(hdr_len, ETH_HLEN, good_linear) could reach good_linear while len
is only 14. The leak would then be much larger than the 114 bytes
described.
Should the changelog and the comment mention this path, so the size of
the disclosure isn't understated?
[Severity: High]
This is a pre-existing issue and wasn't introduced by this patch, but
does tun_get_user() in drivers/net/tun.c have the same unbounded
copylen?
drivers/net/tun.c:tun_get_user() {
...
copylen = min(hdr_len ? hdr_len : GOODCOPY_LEN, good_linear);
linear = copylen;
...
}
Nothing bounds copylen to len there. When zerocopy is set,
tun_can_build_skb() returns false, and tun_alloc_skb() calls
skb_put(skb, linear) with linear == copylen. zerocopy_sg_from_iter()
then copies only min(skb_headlen(skb), iov_iter_count(from)) bytes into
the head.
Both triggers seem to apply to tun:
- the 246-byte vnet header plus 14-byte frame from the commit message
(tun_vnet_ioctl() only enforces a lower bound on the header size)
- an oversized guest hdr_len, as described above
tun_chr_open() sets SOCK_ZEROCOPY unconditionally. With
vhost_net.experimental_zcopytx=1, the more common tun backend would
therefore still put uninitialized host heap bytes on the wire.
The notes below the --- cite the analogous tun.c report. Is a matching
fix for tun_get_user() planned?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113164903.785381-1-graypanda.inzag%40gmail.com
prev parent reply other threads:[~2026-11-17 17:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 16:49 [PATCH net] tap: clamp zero-copy copylen to remaining payload length Junyoung Jang
2026-11-17 17:03 ` netdev-bot+sashiko [this message]
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=179493503300.3136.4070504744747730772@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=graypanda.inzag@gmail.com \
--cc=jasowangio@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemdebruijn.kernel@gmail.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