๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #15436

Re: [PATCH net-next v4 4/5] net: devmem: size TX net_iovs from the dmabuf sg table

#15436
From: netdev-bot+sashiko
Date: Thu, 12 Nov 2026 22:49
123 lines
12333 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท 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] This patch makes devmem TX net_iovs up to 2MB.

--

net: devmem: size TX net_iovs from the dmabuf sg table

This commit lets TX devmem bindings choose the net_iov size from the
dmabuf sg table. It uses the largest power of two between PAGE_SIZE and
2MB that aligns every DMA segment. netdev_nl_bind_tx_doit() now passes
niov_shift 0 to request this, so hugepage-backed udmabufs get 2MB TX
net_iovs.

> diff --git a/net/core/devmem.c b/net/core/devmem.c
> index c6868f39261ad..7135280488971 100644
> --- a/net/core/devmem.c
> +++ b/net/core/devmem.c

[ ... ]

> @@ -387,6 +400,17 @@ net_devmem_bind_dmabuf(struct net_device *dev, void *vdev,
>  		goto err_unmap;
>  	}
>  
> +	if (!niov_shift) {
> +		niov_size = SZ_2M;
> +		while (niov_size > PAGE_SIZE &&
> +		       (!IS_ALIGNED(dmabuf->size, niov_size) ||
> +			!net_devmem_sgt_aligned(binding->sgt, niov_size)))
> +			niov_size /= 2;
> +		niov_shift = ilog2(niov_size);
> +	}

[Severity: Medium]
netdev_nl_bind_tx_doit() now passes 0 here. That means a 2MB aligned,
hugepage-backed dmabuf gets 2MB TX net_iovs no matter which device it is
bound to. Can this produce frags that bnxt silently truncates?

Before this patch, every devmem TX frag was capped at PAGE_SIZE. Now
zerocopy_fill_skb_from_devmem() limits a frag only by niov_size - off,
the copy length and the iov length:

net/core/datagram.c:zerocopy_fill_skb_from_devmem() {
    ...
		size = min_t(size_t, size, length);
		size = min_t(size_t, size, iter_iov_len(from));

		netmem_inc_ref(net_iov_to_netmem(niov));
		skb_add_rx_frag_netmem(skb, i, net_iov_to_netmem(niov), off,
				       size, size);
    ...
}

So with BIG TCP enabled (gso_max_size > 65536), a single frag can be 64KB
or larger.

In bnxt_init_one(), bnxt sets dev->netmem_tx = NETMEM_TX_DMA and calls
netif_set_tso_max_size(dev, GSO_MAX_SIZE). bnxt_start_xmit() then writes
the frag length into the BD without checking its size:

drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_start_xmit() {
    ...
		len = skb_frag_size(frag);
		mapping = skb_frag_dma_map(&pdev->dev, frag, 0, len,
					   DMA_TO_DEVICE);
    ...
		flags = len << TX_BD_LEN_SHIFT;
		txbd->tx_bd_len_flags_type = cpu_to_le32(flags);
    ...
}

TX_BD_LEN is (0xffff << 16), so the length field is 16 bits wide. A 65536
byte frag would be written as 0, and a 70000 byte frag as 4464. The DMA
mapping and BQL still use the full length. Depending on the hardware, the
result could be a corrupted LSO payload on the wire or a TX error and
ring reset.

The "Dropped oversize" check in bnxt_start_xmit() only looks at gso_size
plus hdr_len for GSO skbs, so it does not catch this.

The commit message says:

    bnxt doesn't handle them yet. It has a 16-bit BD length and needs a
    separate fix.

That fix does not appear in this series, and it is not listed as a
prerequisite. The only bnxt change in the series is "bnxt_en: let the
stack segment GSO skbs with too many frags". It handles nr_frags >
TX_MAX_FRAGS in bnxt_features_check(), but it does not limit frag size.

NETDEV_CMD_BIND_TX does not require GENL_ADMIN_PERM. Once an admin enables
BIG TCP on a bnxt port, any local user who can create such a dmabuf (for
example a udmabuf from a hugetlb memfd) could reach this path.

MSG_ZEROCOPY from huge pages can already hit the same truncation. This
patch adds a new path to it through devmem TX, in the BIG TCP setup the
patch is meant to enable.

Should the auto-selected niov size be capped per device until bnxt is
fixed? Or could the bnxt fix land before this patch?

> +	binding->niov_shift = niov_shift;
> +	niov_size = 1UL << niov_shift;
> +
>  	if (!IS_ALIGNED(dmabuf->size, niov_size)) {
>  		err = -EINVAL;
>  		NL_SET_ERR_MSG_FMT(extack,

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261111224740.2744522-1-sdf%40fomichev.me
Technical Details
Message-ID: <179452374171.2199510.7419014613400346072@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362237-linux-kernel-netdev=dewy.ru
References: <20261111224740.2744522-5-sdf@fomichev.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362237-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v4 4/5] net: devmem: size TX net_iovs from the dmabuf sg table
Date: Thu, 12 Nov 2026 22:49:01 +0000
Organization: Usenet Network
Message-ID: <179452374171.2199510.7419014613400346072@kernel.org>
References: <20261111224740.2744522-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="1204675"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Qx/grDm8w5/6KHQx1KLwkJYngb4= sha256:fOCgacixAR1073J4DBsCzC6OSwJ206Phi+b1byz5O5E= sha1:Z3g1qFWAPtbVRfUo2g10pbprGZU= sha256:2jBqMsrOuO1mutY8AlSDMXkqrxsFR5stwuXmIpHH6Aw=
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 8BE8E1143CA; Fri, 13 Nov 2026 02:27:52 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[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 vI5ZLmFAruQn; Fri, 13 Nov 2026 02:27:48 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-362237-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 2FB6F11400C; Fri, 13 Nov 2026 02:27:37 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 495366A49CA; Thu, 12 Nov 2026 22:49:21 +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=1794523744; b=WcTq9Wj0g9vLZ3fLZ9mEmlPVbKPSZqVKWKglOsUH4SYlA8UGPCj9Zz2UR1HpQytHMV8K KKXC4q5SaX9soaZVlVpDpfaoqNpZVwiT2TDLPthX1uMDa1Yz4qjWBFphYjnMTTi3XCCX3 uLfxBT3j8cYeRmX7feDvmR0w0lHXZU94wg1U3Qm9cn6KnHVUTrHh9zrJqr7bRLWvOEGwp 65ELJe06dKd0UUQ4g1ZHsyJea1vsBPqLitVN2JVCkZ+ZV0sZtbbBNHSHWFmkPXeGUGfDZ HweEXkjHYUJqRtgLEcSpFjKh96aqXvtGusjcxXjR+D6qJPr53nw+TgJ6h/xEbgpIJTA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794523744; 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=GbRc4oId6LYe34THYRyu66PRGg8zCXpBZWRDZ3yETCo=; b=2fi+K40wKgGgmDqyTdiM9OVLSGIMVZaMJSuhHA28hJQiJ6KlkkSr090K/vLF6FZ/Mwm4 1BE3zxekmxWMB4lTSVxiyqkxDoRAXElf3KhP9OOCy6X9kuA9eNBDmyjq9VgDjReXX9uQX BbkbOjNeqOnInBSfYY5opllc2McKP2mge2wA0i/hmaPMDMESDtZ+NhMlLw5qwJ8jAWcC1 WeksMi72ufSGsm1MLtsLj0C8d0hciTvX+JR++VCUvJdiVM0AfWcE2XwKWjRIpXGkL/Noh GbOA9v0lyovixaBmtKKnhildV93IWVdb0LbryBLDmRIbYi2skAO9k5KymNUeGFt7yXA==
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=NLC1eLBI; 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 943F5606A898; Thu, 12 Nov 2026 22:49:04 +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=NLC1eLBI
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=1794523743; b=DHaqgU0ktvmHOG1pWt1DECq7e0HVcpgf2bQy9TMWGIlXu0ZYjYiKhD3S7s4c/e5/YQUr PwEERmlzXu0Wqh8YipZKgx8aawoUFrIn1hEOrZocltYUqE3PjVFsXtCRI+2hoBKgqorNu VrBns7zH0203sPD3w4c2/gpe7uHxHkHs3MAsRLnCNY+u5wtp2XfbBJAI0XKPrsVQLPtp1 XeGbPrHU3xbFZl0tR/aA8TjL6zzkQO+m7JcUuZ3u2Ma6JAGMGIUfke66nEaWbiyHQFJRW 5pVrdeU26EQWNG4bL1KYtPX1MMxed+rDUxOHNjaRUPxs8SxVpw0u4+p73MLOCKSe/EA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794523743; 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=GbRc4oId6LYe34THYRyu66PRGg8zCXpBZWRDZ3yETCo=; b=nCgERK7egNyslFDCX8y7Widude0n6nIy3Ciipkgu/p6G5gekIv9M4naboJlfm0cACauN scwxL9gy1hbUTMwW6UwiWw1x9riJgWPkRNn/mep34nPkS0oEC+a2I6uuxF8fq4K5Lpkrm LwOnxtIvXQDp6CsVmet9J/qnLujPGMCGOOCdIxb6hJJZHrYoFYcOAGHXP1xNrgU5emXc+ CT2lnGXkPRaQ9xUFXtATILHXAr6Lv5AuKrUeDCbAX3sdzOSwXDVEiiaH8JkHbfmfHbKNg q2cnR5HD4Jj6VBv0QBnbLsDSHDRhXfyltRJGB0Nck1XmgK9X16a7VadB7JTVup8IqLA==
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=NLC1eLBI; 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 B09C8606A890; Thu, 12 Nov 2026 22:49:03 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29BD91F000CA; Thu, 12 Nov 2026 22:49:02 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794523743; bh=GbRc4oId6LYe34THYRyu66PRGg8zCXpBZWRDZ3yETCo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=NLC1eLBIsQcEMIYC4UALSZAP+eDj8jl+WS0MLatOxbw9swOzUPqlu0P84/xnkVR0M Z5+c/fhQEK333cuIEhiAGcS1LpQap01c3Z1dUfaSVzTCRFQH1/I56Y21fsomswuSsG gg2GSbDF8Sj4rNcuHgyBaYAXL0Es89FZTsZ3VVrjS37HzQ4LugNe1qfESLxLPrtyhb d/kn3gzg0LviK3yvRsagYe+u3CoB8OQbtx/LjlbRVmKzsZUID3G7Ta4TBmiN1WMeut VnCq8KBfmsCwUWDZ9dceOrM46X+RK2cCspYk3pBoVzNm9RrQmgg/VIk48RitZe0xCG kN32mwtsAHjlg==
X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, andrew+netdev@lunn.ch, edumazet@kernel.org, horms@kernel.org, shuah@kernel.org, almasrymina@google.com, sdf@fomichev.me, leitao@debian.org, dtatulea@nvidia.com, asml.silence@gmail.com, bobbyeshleman@meta.com, daniel@iogearbox.net, razor@blackwall.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
X-In-Reply-To: <20261111224740.2744522-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