🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18000

Re: [PATCH net] tap: clamp zero-copy copylen to remaining payload length

#18000
From: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 17:03
116 lines
12181 bytes
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
Technical Details
Message-ID: <179493503300.3136.4070504744747730772@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365461-linux-kernel-netdev=dewy.ru
References: <20261113164903.785381-1-graypanda.inzag@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365461-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] tap: clamp zero-copy copylen to remaining payload length
Date: Tue, 17 Nov 2026 17:03:53 +0000
Organization: Usenet Network
Message-ID: <179493503300.3136.4070504744747730772@kernel.org>
References: <20261113164903.785381-1-graypanda.inzag@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2383270"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ytU/k96wMO0BJdeyrIh9P1/3V74= sha256:CKwwghbqzxjRh0y5JvH3/e70T6NKi2xvU8gsmgepkOY=
	sha1:kNXs92q3IIHkqKDyKDMeCVk+PkQ= sha256:tTiuY7iFqt4TUjrUl9xroUbOywZRxrSAg13D4nMdiIU=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 5C6B2115005; Tue, 17 Nov 2026 20:04:16 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Yqahs0qZGrIP;
	Tue, 17 Nov 2026 20:04:12 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-365461-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 197E2114FFC; Tue, 17 Nov 2026 20:04:03 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 3D0183589D; Tue, 17 Nov 2026 17:04:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794935040;
	b=b3mrxwxGma3Wp6uICjfke58BftrytM0Rg/ntCgfgt7i6Mkn48toAIS6vblzL9w8UqIqu
	 p6+q2LgjmclPbDi1sZZQrbXzMoxkrTm8L5BHbxp/o1PCdoKiVmT5WiNWA1eJJqHdM/ygU
	 czaRU0A1EivE4vcf7wFBjJ9rnn3oMf4oQJG7zPZDSPmne+C525HJOx4TpXl5Lb9tH5v+/
	 yLlje1ncUJfl0ZfGrkraOy4cpFeHV7QI4a64W0YwiiPCE/kvYgYbLjzHlcUBNW3HTdht5
	 M3BCNi3mS5iy9iJBXpIFtEqJpn+xvOweFzxZ8OlbJBJmpwvMw4iffWzehOh1LfLI9YA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794935040;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=6dFwgttTw42R11mfM5CS+XLJ1B724S1YmPtAmkJ59Zg=;
	b=P05vneLwbqp2fCqMbqOYN0nU0vqj2YrBOJG0vwRM9PXSBcTY5Q4i8oO/cAOCTvraqHG4
	 w+LDeEyUW/ISoayMHDDuSdEnG4fYZK4HdKrXwVkjoEmsX9OISZzqjdLEJUBIvCf9X+wxt
	 go8FJ1z7OMkewwPvracJRRRZXz/CLhQ6CVo2mnpdKMIPGctOhtywUc0vU3adzgJIHICj8
	 cmT3sYwcLGg+saG3TrxkNCbgLgL8Bzzj07ewOUv8i5GRaBbPMhjWAB3/i/pWFoqfzDSIF
	 ReNB0WkLFCjlfmz2B7gIUsRK3WqacDeDwxPR5lLE5iCI5sXU1kKpSHynensEBRmaZeQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=id5wW1Yc;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 12968606A338;
	Tue, 17 Nov 2026 17:04:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=id5wW1Yc
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794935034;
	b=NgyOTg1QDmdbDXzqar61ig2G1txtdU3w7cPu/W0rlB8LBLfurzs+LbH54UQX2T1jD0IN
	 kKkfrFhSYtGvTVLyj7+GoUeXFCp/GqqRMjskvcCklolFIJJ5pWfZKpaYWnbferjxGs8A3
	 Y3/mcGWztrt8SWSJP9iBipRMs+O5DV+XrV+uF8EDtHjULdWy/VIqmWHaQ3GcuBpqdDowj
	 tHJkLJj39g2y8+BKMv/V0sXGafDPPHaaoGmnTplL2sWJD1jFIDcheUU8RLEc3O0ax8QHU
	 eCuPHTHNsuFgjF6GWd8QZzZbFCraUK+ae64VB54gkDT1OE3T9a16x3hVodZPerU+MmA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794935034;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=6dFwgttTw42R11mfM5CS+XLJ1B724S1YmPtAmkJ59Zg=;
	b=gq8rY7CHz3qg2bkxGRw+4aAz/gtYmwwv+NiJArkzgtzsPNZYJiTuaytlRI/2ZARu9qs1
	 PYIRccCtX6lCFlN+oI2jPW8IgUjt2kk4peNtNPWNAeTDZ7qZDs+xTn0lMvJwVy07W27R9
	 amVo16C2bvppJW/AQ/NqG8k6ER4EEOlKljPxgghRLSr0Fpwsz7YV9PENPsdBehnL3ubQA
	 SMpZwcQm3Tt1AnaHpMAarMm/QPwqPWByuQY/csqFMwKXRVJDvENJeg0+nae4XUngjqfq6
	 FuODr+nIdArJ38lqAzz0bdYsHtEg1SLQ3zrez7clssHqsAa4D5+h+2VSx1Pu14ElS9A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=id5wW1Yc;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F270606A31C;
	Tue, 17 Nov 2026 17:03:54 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A3DD1F000C5;
	Tue, 17 Nov 2026 17:03:53 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794935034;
	bh=6dFwgttTw42R11mfM5CS+XLJ1B724S1YmPtAmkJ59Zg=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=id5wW1Yc8sK5qIZOs77g2mA0NjqLmOmsePJZZhyrbS77fOlAPbsi+zaw3zw5U9iTg
	 ufz7dU/V2oPT5huVg/MYUTklZnqGCgE91SNFWuRm0ccQEGzbdt/+dhdLPD8EnbH2uk
	 iFhseD4OSLMQQsFR+/Rur3Wns7rRWpPJahElxuAWB7lhHPWlA/ju6WoRuac2eA+fJz
	 2AEyYIcLmxqjR70+QyPcSQXE31rtuIDAw3W9SX3j+AIx+WfgDMFwvKGzRJgjFXQr8+
	 seS5WTDvrPHhZQ4A54q1iJw4BGhXMiuEPEEQag+/cq+bWn+VgQwkx/pV2o1x+7NG8q
	 tSuTUaYQky4iA==
X-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
X-In-Reply-To: <20261113164903.785381-1-graypanda.inzag@gmail.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list