๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26254

Re: [PATCH v1 net] tcp: Fix MTU probe with zerocopy or devmem skb.

#26254
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 09:49
124 lines
12451 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 ยท High: 1 ยท Medium: 0 ยท 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).

- [High] The devmem MTU probe can still carry the wrong payload.
- [Low] The commit message does not mention a behaviour change.

--

tcp: Fix MTU probe with zerocopy or devmem skb.

This patch copies the ubuf_info (uarg) and skb->unreadable from the send
queue head to the MTU probe skb that tcp_mtu_probe() builds. It also
makes tcp_can_coalesce_send_queue_head() refuse to coalesce skbs whose
skb_zcopy() pointers differ.

> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index 043838d996404..be2ef1fe1ea00 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -2660,7 +2660,8 @@ static bool tcp_can_coalesce_send_queue_head(struct sock *sk, int len)
>  		if (len <= skb->len)
>  			break;
>  
> -		if (tcp_has_tx_tstamp(skb) || !tcp_skb_can_collapse(skb, next))
> +		if (tcp_has_tx_tstamp(skb) || !tcp_skb_can_collapse(skb, next) ||
> +		    skb_zcopy(skb) != skb_zcopy(next))
>  			return false;

[Severity: Low]
This isn't a bug, but could the commit message mention this change in
behaviour? The message only says:

    Let's propagate uarg and skb->unreadable to MTU probe skb.

Before this patch, tcp_skb_can_collapse() only required the same
pure-zerocopy state through skb_pure_zcopy_same(). With the new check,
tcp_mtu_probe() returns -1 whenever the send queue head mixes zerocopy
and non-zerocopy skbs, or holds zerocopy skbs with different ubuf_info.

This can happen with io_uring SEND_ZC requests smaller than probe_size,
since each one has its own notif uarg. It can also happen with
MSG_ZEROCOPY sends whose uarg could not be extended. In those workloads,
MTU probing stops raising the MSS without any notice.

The restriction makes sense because nskb can only carry one uarg, but
the changelog doesn't say so.

>  
>  		len -= skb->len;
> @@ -2828,6 +2829,8 @@ static int tcp_mtu_probe(struct sock *sk)
>  	sk_mem_charge(sk, nskb->truesize);
>  
>  	skb = tcp_send_head(sk);
> +	nskb->unreadable = skb->unreadable;
> +	skb_zcopy_set(nskb, skb_zcopy(skb), NULL);

[Severity: High]
Now that nskb is marked unreadable, the devmem probe passes
validate_xmit_unreadable_skb() and goes out on the bound device. Can its
payload still be wrong because of the way tcp_clone_payload() merges
frags?

net/ipv4/tcp_output.c:tcp_clone_payload() {
    ...
			if (lastfrag &&
			    skb_frag_page(fragfrom) == skb_frag_page(lastfrag) &&
			    skb_frag_off(fragfrom) == skb_frag_off(lastfrag) +
						      skb_frag_size(lastfrag)) {
				skb_frag_size_add(lastfrag, todo);
				continue;
			}
    ...
}

skb_frag_page() returns NULL for every net_iov frag:

include/linux/skbuff.h:skb_frag_page() {
	if (skb_frag_is_net_iov(frag))
		return NULL;
    ...
}

So any two devmem frags pass the page check. If the next frag's offset
equals the previous frag's offset plus its size, the next frag is folded
into the previous one, even though it points at a different net_iov.

Devmem TX offsets come straight from the user's iov addresses.
net_devmem_get_niov_at() returns tx_vec[virt_addr / PAGE_SIZE] with
off = virt_addr % PAGE_SIZE. zerocopy_fill_skb_from_devmem() then adds
one frag per chunk without coalescing them.

For example, an iov list of {0, 100}, {PAGE_SIZE + 100, X} gives:

    frag A = (niov0, off 0, len 100)
    frag B = (niov1, off 100, len X)

B is then merged into A as (niov0, off 0, len 100 + X). The same can
happen across skbs, for instance when 2048-byte chunks are sent as
page0/off0 followed by page1/off2048.

The NIC would compute a valid checksum over bytes from the wrong dma-buf
chunk, so the peer accepts corrupted stream data. The probe skb also
replaces the original skbs in the write queue through tcp_eat_one_skb()
and __pskb_trim_head(), so retransmissions would send the same wrong
bytes.

The merge check is older than this patch. Since this patch is what lets
the devmem probe be transmitted, should tcp_clone_payload() compare
skb_frag_netmem() instead, the way skb_can_coalesce_netmem() does?

>  	skb_copy_decrypted(nskb, skb);
>  	mptcp_skb_ext_copy(nskb, skb);

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201064908.1904467-1-kuniyu%40google.com
Technical Details
Message-ID: <179629138890.3146.6443424392256368523@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376455-linux-kernel-netdev=dewy.ru
References: <20261201064908.1904467-1-kuniyu@google.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376455-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v1 net] tcp: Fix MTU probe with zerocopy or devmem skb.
Date: Thu, 03 Dec 2026 09:49:48 +0000
Organization: Usenet Network
Message-ID: <179629138890.3146.6443424392256368523@kernel.org>
References: <20261201064908.1904467-1-kuniyu@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2452329"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Oz7lk+aaFHku8hWw/KkaOYcriBQ= sha256:l/eKR3ljK5C3l7ppMn2kshDacSaap/pzte1NUFFHizg=
	sha1:OZ/Thf1RDQfWiLJeaJ8kdNH4IdI= sha256:LgnKJNPdTfO40l66LPVXQxdL9kRNAAchWMJroMnkDRU=
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 38BED1178B2; Thu,  3 Dec 2026 12:50:06 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 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] 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 0jwK-WpAEAvk;
	Thu,  3 Dec 2026 12:50:02 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376455-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 218801178B0; Thu,  3 Dec 2026 12:49:53 +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 648DD3079A; Thu,  3 Dec 2026 09:49:51 +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=1796291391;
	b=fDNmKo3fRPMWGqv7gy0fS8b0ryCUCa0c+OiuOjdhgyc/HmYeVsscHvADROy9ea0pRIpc
	 ADPF8vTY8orm+N+/6p1i3YTo4pp7N/5pQM1IHBnsGq/Ymfy9BaY/VedOZJejzjLkoA1wf
	 EjLH6IIzWvmWlKWF3imTQ0NpN9UUMqLINFGFrcxYDBhPql32js9s3NWmxHVLjUJMe7qkA
	 gkEAN2KbtAxZChsElo+a3yeJkpBdMedUv12be356sk7oqMAcdRIZ5j/ZlT69UZ0rz7sk2
	 guXLqlMNHAkKhUKeGyAYontljrYzwfyyAxoIL6iLGM1NPd72hz6LtqJUZIt/ZJWME8g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796291391;
	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=dLrcdmBJ+Z5Fii3p0Zbu8BdkUuUft3AkrK7DyA0i++E=;
	b=j46kvzFkmXrtR9WnuqefMBbV4aRyjK7ec60D68R5GEQOJXTi/r5zTl6T7JjpuGj511zg
	 K1pDNr1I0mdJgjN8pnbC+e1ZMdOgLWhFm6XmGxKCEtbs84uwgdn+AyKE5v+uswayyZ6OO
	 EwyNj7Jfy5yRUVs7UxTjEJ8GmDPPMUn8YkfaX551n54LLiDCKor2wpY0molHzVpILwz7G
	 MqxxmswLA2wm4HuoLtFb+m8rreRfsk4+alDE2hL+WRvXIA/FXkfUeuho/KLMbnkicVixg
	 O5xotF8rvwxRhNpacMXCEMC9vYK2hdtp3Xv21Uf2xnvEmegRQvnlVnQK8CM+S21qFrQ==
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=YlBYhYi0;
	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 3D4C1606A322;
	Thu,  3 Dec 2026 09:49:51 +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=YlBYhYi0
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=1796291390;
	b=vC9E69jI9jOSJcSnFIoVSRT1EZgViqnu8Fx/pUXXoMxDQOxgz44D7s2tKO+8dhHEkg4N
	 B/UNyQ0c4AzuRb6zw1xJB/vvabnMRKq+0CXE8v22YxE++m09o9suTzPKZmR/DTogypDjP
	 ygkTdkiA0TbgVlOi3pT+HcdCYlHpY/ppK4jRkSn29qsjPXtWlPRDb0VxoSzmiIKgfI45p
	 cb7pEwWuoGpX7QKoSulsMeA7vHqOlDYzDS+tuuq/oFNihfnJVothN7Lq2s+VxRFbky3t5
	 nLVKTKzLP+mU7sGhxjwI3m+Ggl83kiblAV61DzwcT+VkPWRBQqz6fAt1L04Yy9c5Ajg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796291390;
	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=dLrcdmBJ+Z5Fii3p0Zbu8BdkUuUft3AkrK7DyA0i++E=;
	b=1xlmGdu4ENlLwuVHo8+wDAOpgkGPPxyBz5JjwHfAdb0KHPRrrsUc4p6F9AaaoWnRjkpO
	 RdPZonBOydJoC83GCajyy5agGCQSZKNWnqNRL2bugQsQSowGy8IOzHTDF7KTw/2b2QFZz
	 fXdR1U3PMPCBeXAMqRZ7w3PrwZtAxK5ApTyEA5p8fZzIiPJxFqYqESL4dYitgWN62Ho9z
	 o/I/G35SFWK7TW0XZ0u8qf8XIYrjnEKIkS9sxx2tlAKOOFsZUxUGTrN8wSTEHnYkEJwFv
	 32IFu9WhoxNidV8gFtlH/vokvFLPQCGxK/prPVe55IWBBG+2kjGCZcNlo+LYPev6z7w==
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=YlBYhYi0;
	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 5BB17606A32D
	for <netdev@vger.kernel.org>; Thu,  3 Dec 2026 09:49:50 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BA4A1F00896;
	Thu,  3 Dec 2026 09:49:49 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796291390;
	bh=dLrcdmBJ+Z5Fii3p0Zbu8BdkUuUft3AkrK7DyA0i++E=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=YlBYhYi0MO0FuYXZZsHRxx82at9/BIkoM5SC1SBzPfmX1B2h9hUBuO9fSWhyoEH/4
	 /z+/lJr7AJIVuS1cOAuE2E9HVHc+02C20EdFd04+TmvLRmIANd+MNzg/hkHE6cB2Qi
	 pS8HEDykEGVS3auCqVOxu5i6penLqP2KLL8JAYAfVDyqrJmNF1EBCWqtbEHvXmmmFw
	 YSI2tZNAW/E1blW9UENBUJcUu7Y+Op0iMKKSYGFsNnwPcpZQjmldKRk6ySf5H3Eieh
	 Av/hsYfEWJeQcX/bk7EouF6B9AwTdfyADHSyBX0XCT5Xu6EXkOFpueAq3Kru1CyuOW
	 cW/vHIDa2rHMA==
X-Cc: edumazet@kernel.org, ncardwell@google.com, davem@davemloft.net,
 kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org,
 almasrymina@google.com, kuni1840@gmail.com, netdev@vger.kernel.org
X-In-Reply-To: <20261201064908.1904467-1-kuniyu@google.com>
X-sashiko-severity: High
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