Article View: linux.kernel.netdev
Article #12921Re: [PATCH net-next v3 4/9] net: devmem: add a per-device netmem TX frag size limit
From: netdev-bot+sashiko
Date: Mon, 09 Nov 2026 01:22
Date: Mon, 09 Nov 2026 01:22
127 lines
13378 bytes
13378 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 · Low: 0
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 new per-device cap is enforced in only one place, when
zerocopy_fill_skb_from_devmem() (net/core/datagram.c:737) first…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
tcp_clone_payload() (net/ipv4/tcp_output.c:2699-2703) can merge frags…
--
net: devmem: add a per-device netmem TX frag size limit
This commit adds a netmem_tx_max_frag_size field to struct net_device,
defaulting to PAGE_SIZE, and copies it into the devmem dmabuf binding
when the binding is created. zerocopy_fill_skb_from_devmem() then caps
each devmem TX frag to that limit.
> diff --git a/net/core/datagram.c b/net/core/datagram.c
> index 489d92fe6dae8..a8d3f87d38c58 100644
> --- a/net/core/datagram.c
> +++ b/net/core/datagram.c
> @@ -734,6 +734,7 @@ zerocopy_fill_skb_from_devmem(struct sk_buff *skb, struct iov_iter *from,
>
> size = min_t(size_t, size, length);
> size = min_t(size_t, size, iter_iov_len(from));
> + size = min_t(size_t, size, binding->tx_max_frag_size);
[Severity: Medium]
Is this the only place the new cap is enforced? The netmem.rst text added
by this patch says "Devmem TX frags are capped at
netdev->netmem_tx_max_frag_size". TCP MTU probing looks like it can merge
the capped frags back together later.
tcp_mtu_probe()->tcp_can_coalesce_send_queue_head() uses
tcp_skb_can_collapse(). That check only compares skb_pure_zcopy_same() and
skb_frags_readable(), so two devmem skbs pass it. tcp_mtu_probe() then
calls tcp_clone_payload():
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, so for devmem frags only
offset contiguity is checked.
Suppose this line splits one large net_iov into two frags, for example
(niov0, 0, 4K) and (niov0, 4K, 4K). Those two frags would be merged into
one frag of up to probe_size bytes. tcp_transmit_skb() then hands it to
the driver, and nothing checks it against binding->tx_max_frag_size.
At this commit TX net_iovs are still PAGE_SIZE, because
netdev_nl_bind_tx_doit() passes PAGE_SHIFT. So the merged frag can't go
past the default cap yet.
The later patch in the series, "net: devmem: size TX net_iovs from the
dmabuf sg table", lets TX net_iovs grow to 2MB. After that, take a device
left at the PAGE_SIZE default that runs a jumbo MTU with MTU probing
enabled. It would get probe frags of roughly MTU size, which is above its
advertised cap.
In-tree drivers seem fine with this today. bnxt and fbnic advertise 32K,
mlx5 advertises U32_MAX, and gve already splits frags into its own
descriptors. Even so, the documented limit would not hold.
Could tcp_clone_payload() compare skb_frag_netmem() and stop merging once
the binding cap is reached? Another option is to skip MTU probe
coalescing for unreadable skbs.
[Severity: High]
This isn't a bug introduced by this patch, but the same merge check in
tcp_clone_payload() looks like it can also combine frags from different
net_iovs. skb_frag_page() returns NULL for both frags, so the page
comparison always passes and only the offsets are compared.
For example, take a single sendmsg on a devmem TX socket with
iov[0] = {dmabuf offset 0, len 2048} and
iov[1] = {dmabuf offset 6144, len 2048}. zerocopy_fill_skb_from_devmem()
builds:
frag0 = (niov0, off 0, 2048)
frag1 = (niov1, off 2048, 2048)
Suppose tcp_mtu_probe() then builds a probe that covers both frags.
tcp_clone_payload() sees that frag1's offset equals frag0's end, so it
extends frag0 to (niov0, 0, 4096) and never copies frag1's netmem.
Wouldn't the probe then carry dmabuf bytes [2048, 4096) instead of
[6144, 8192)?
The NIC computes the checksum over the wrong bytes, so the receiver
accepts them. If the probe is ACKed, tcp_eat_one_skb() has already
consumed the original skbs, so the stream stays corrupted.
The merged range stays inside niov0. So the result is wrong data from the
sender's own dmabuf, not an out-of-bounds DMA.
Should the merge test compare skb_frag_netmem(), the way
skb_can_coalesce_netmem() does? Nothing later in the series changes
tcp_output.c.
>
> netmem_inc_ref(net_iov_to_netmem(niov));
> skb_add_rx_frag_netmem(skb, i, net_iov_to_netmem(niov), off,
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261105222058.944293-1-sdf%40fomichev.me
Technical Details
Message-ID:
<179418737701.994134.5100743053640770189@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358939-linux-kernel-netdev=dewy.ruReferences:
<20261105222058.944293-5-sdf@fomichev.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358939-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v3 4/9] net: devmem: add a per-device netmem TX frag size limit Date: Mon, 09 Nov 2026 01:22:57 +0000 Organization: Usenet Network Message-ID: <179418737701.994134.5100743053640770189@kernel.org> References: <20261105222058.944293-5-sdf@fomichev.me> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="247300"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:0w41vI94jrfN83DAYx3J7+CezyM= sha256:vezx0s9VkO2K14Lx3GOQyT24jtu2CEeBLNu9xdJfwQ8= sha1:6rfSv1XSFqu4stpVbcl9Txe6oEw= sha256:4s/gogsh/JUejTwh2+SrqFOAcrHwPdWC9isWbLI0olk= 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 95AA011368A; Mon, 9 Nov 2026 04:48:57 +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 XaHzzsd4TvYm; Mon, 9 Nov 2026 04:48:53 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-358939-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 4C7ED1120A8; Mon, 9 Nov 2026 04:48:45 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id B88134642D; Mon, 9 Nov 2026 01:26:01 +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=1794187385; b=Hnp6nMquobVP0XdX/bARJ2jHyZ2IP/YDuk83ZsIlE6gtsPuKzqQ21Ah1wY39lw4SJDFS cERirpnqzS4MMFarOAP7qt5exmtncD9DqLS8IenhPRlaUeCO8pOnxny5UNxMVHPkmy3ib A9kTxYvXKjLA7/BtWiuMxrdEJTnJEnrSyRVdwUV94pBUp5beEBBL0y0kY2IiK7gHgGB3/ hYsossX9Uo1cDpBTjgEk2b2GW+5WiCKB0mrIgzbfWRuLGHvqbabUMtoOnt/gkEYtmP8An 8yAUqQK6fOL5JZ/mNzn8GppM0zKXmexBMWGgd1raH4Yoo1MojrsoMazsQPVlq+QoWYA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794187385; 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=8pW4eoUoFBjt45/T7wxAAHU7qXhZjgsirRTlsHsjZ0A=; b=oF1grJb5NbxeGl1P6d/bZLpGOqyIMLuFVbDe8JiiLSGuVeBh2C+qMGfvHt1FaCDUs39Q qwx4VopBKXLGsC8syxUhCAArePGUfBrgljGhOW28Czafc705hOI9A78koqhNWi5zX/iPe tRrRqr2dNjXl+aObDctWR4r4ns4kwvidunZuKrejlvw3sYpBkEKoD7fxfNaNPkX4gVwmK JaIf1bo9yycplZ5BjYNkie/7z8KvDKoyxUgfyPDLB5FDF05AhAtSJH0FJZ54Mm0tbMBnz f/xCJ2pQgUBljW31178EAUHzLEyD7qD797KKauGFo41E2nqAig/+lrJgnDdxF3HWJ6w== 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=SM7hLJSH; 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 8D41960A3823; Mon, 9 Nov 2026 01:23:05 +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=SM7hLJSH 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=1794187379; b=ocfwwbNjSNkh/w5Nhj+BhVs64oNZw9lKedsT5mm3zB0luTiuF/IWZUEspUzxsskbGwPo +Zb7gS+Q8KYNuLLTYXnaM4rv9ucm+xQnryUASHRN3yr7/so8RBzSUU0Reu5PROfG7ZGZ+ Cc1x8vi2noYfigfOS9ZM2GBWpWC4lgXt050NCiKUkxTzkYVKzctKBh+QwZ5bwqvbOpb9L OmkgL6tC3cqEn5CQdQxRRn+4ep0nhtaNP6a1zqNj+2QPGYuFmOsXA2qfE1fQxl4SPt92o FCkeRER70Lwcy8p79BG5nbaQ8gHVCwwtseUKN1NmDWjDCwEk+AwmD/Wej3vj+JxC39w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794187379; 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=8pW4eoUoFBjt45/T7wxAAHU7qXhZjgsirRTlsHsjZ0A=; b=tMdSG3zD19trqPuYFTxsN3Sqq101mkJ7vo8/bOfQSOEwAiVSuHmPgNClbJhppvgiIjsA W1cqYZzMCizfJC9nS5hddp7y91dY/MsMfvYpvAO7XQn8Fx59IdZeBdACoP52EGvfWH1Kr QnvXNFRF+7Y3jNK54kno+5mUKZclHfOgf35QrzJsG6hoZBbp2sw006TXhj/66/NTpxow7 iTxZX5eDdaSUuTgqBPhHWLku5I0OzwcgG2L6ktGvUaJ9koZeyWXZ4m62wYiDoihLVRWVI r6xKZRW/8/F7BMdY9jki3LD+fsVvkjHAWoDfFo4wCjzxOPz3vHMe0y/69U7CPz1+41A== 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=SM7hLJSH; 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 66577606EE84; Mon, 9 Nov 2026 01:22:59 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A2A21F008A6; Mon, 9 Nov 2026 01:22:57 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794187379; bh=8pW4eoUoFBjt45/T7wxAAHU7qXhZjgsirRTlsHsjZ0A=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=SM7hLJSHd5+AFw12MzAmxSxVbibhYITBmJA8aVgBYlj8hFxvLBeTOsFsSdfXAWrDc 08k/cpqJcOepBYtuqgG/w9hvljxgGhYBXzz/2RfFCAsj4dyf7bHso4mK/yD2P/YSOX 0wqKuVVvd0FPfROMzcDo7FcfdrvEHhVcUmbKNFkbWHYkKqLJirthZrasblprJdD2Dc u6RV7lJYEBxfXsP6LQHJC1EKfRNM+BFgr2rgWSaTmCC9+t0EipIgH6WkKqKgxRgMOz iKMtJ+X9VksbMGJyxx49zYq1MtJ7szgbfPJyVNFIHYVIDWLpInWV7ODXUOcEdEcwG1 pCSJUQ322/0+g== X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, edumazet@kernel.org, horms@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, alexanderduyck@fb.com, kernel-team@meta.com, sdf@fomichev.me, dimitri.daskalakis1@gmail.com, almasrymina@google.com, dtatulea@nvidia.com, bobbyeshleman@meta.com, asml.silence@gmail.com, daniel@iogearbox.net, razor@blackwall.org, leitao@debian.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kselftest@vger.kernel.org, leon@kernel.org X-In-Reply-To: <20261105222058.944293-5-sdf@fomichev.me> 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