Article View: linux.kernel.netdev
Article #26873Re: [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 10:39
Date: Fri, 04 Dec 2026 10:39
70 lines
11356 bytes
11356 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message understates how much of the shared info the
old xdp_build_skb_from_zc() let a sender overwrite.
--
xdp: Size zero-copy skbs from the data, not the frame size
This patch changes how xdp_build_skb_from_zc() sizes the skb head. It now
uses data_end - data_hard_start instead of the XSk frame size, so packet
data can no longer overwrite the skb_shared_info. It also copies the exact
head and fragment lengths instead of rounding them up with LARGEST_ALIGN().
Heads larger than a page now come from __netdev_alloc_skb().
Link: https://lore.kernel.org/bpf/20260629072300.1664622-1-clecigne@google.com/
> With 2K chunks, no UMEM
> headroom and the default MTU, a 1514 byte frame that XDP passes on
> ice, idpf or gve needs 256 + 1514 + 320 = 2090 bytes and gets 2048.
> The sender controls up to 48 bytes of the shared info, its frag list
> among them.
[Severity: Low]
Is "up to 48 bytes" the real upper bound, or only the overflow for this
example? The 48 bytes come from 1514 rounded up to 1520 by LARGEST_ALIGN():
256 + 1520 + 320 - 2048 = 48.
For single-buffer pools, xsk_pool_get_rx_frame_size() subtracts the shared
info tailroom only for multi-buffer pools:
include/net/xdp_sock_drv.h:xsk_pool_get_rx_frame_size() {
...
mbuf = pool->dev && (umem->flags & XDP_UMEM_SG_FLAG);
frame_size -= xsk_pool_get_tailroom(mbuf);
return ALIGN_DOWN(frame_size, 128);
}
xp_create_and_assign_umem() sets frame_sz to the whole chunk:
xskb->xdp.frame_sz = umem->chunk_size - umem->headroom;
The commit message says a device may fill a single-buffer frame to its
end. In that case data_end - data_hard_start can equal frame_sz. One
example is a 2K chunk whose 1792 byte rx buffer is filled after a raised
MTU. Another is 4K chunks with 3840 byte frames.
The old code built the head with napi_build_skb(data, xdp->frame_sz). That
left only frame_sz - 320 bytes of linear room. So the copy would overwrite
all of SKB_DATA_ALIGN(sizeof(struct skb_shared_info)), which is 320 bytes
on x86_64, including frags[]. With 4K chunks, the LARGEST_ALIGN() rounding
could also write past the page handed out by the system page pool.
The sender also controls more than the frag list in the first 48 bytes.
The flags, nr_frags, frag_list, dataref and destructor_arg fields all sit
there. A chosen SKBFL_ZEROCOPY_* flag combined with a chosen
destructor_arg gives a callback pointer.
Could the commit message give the worst case as the whole shared info
rather than 48 bytes? The code change closes the whole overflow. Only the
stated impact looks understated.
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203095647.3448925-1-bjorn%40kernel.org
Technical Details
Message-ID:
<179638077683.3146.7227826095174306078@kernel.org>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377254-linux-kernel-netdev=dewy.ruReferences:
<20261203095647.3448925-3-bjorn@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377254-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size Date: Fri, 04 Dec 2026 10:39:36 +0000 Organization: Usenet Network Message-ID: <179638077683.3146.7227826095174306078@kernel.org> References: <20261203095647.3448925-3-bjorn@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2742240"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:L54+BwMLvnrSR/9pmLrwHTkOBT0= sha256:NZoGguOGBG7D1FUyDdj1CKoNFi4zsKel8GYKTxrSDYw= sha1:YRYlrytMiv9Cf/G7bTQb7jf/aYM= sha256:5FN/qMgJHkp7+QeRdfRkVgp0bCRvfWo2z+E0EHWq3nM= 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 AF64A117BA6; Fri, 4 Dec 2026 13:39:56 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.541 X-Spam-Status: No, score=-3.541 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, 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 4dWR_o2Yx1yz; Fri, 4 Dec 2026 13:39:52 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377254-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 469D0117BA1; Fri, 4 Dec 2026 13:39:44 +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 8B7AD31EAF; Fri, 4 Dec 2026 10:39:40 +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=1796380780; b=TZC96oCgg7k0SG1RR0SSe32F1wxDBQJ0fql5GKt+ZyEykTuDzpy+ELHF/TE8zJRiyRVa sGvsUxq0I2auJxRXB3VJ4E8y40tdO7cdK+kIkAJtGtai7yNY3zvrCYuYm5MBNKSYQ6a+V eCkBpqfpslCPWJjePfp2UNO5/3N3u0LoMUM0Lblo5chioKCG8Ja6Jc923ij5o7tpeVq65 m2R+N5MM7S+JnQSlOwbdfTz1m5EEaY/ftJT36iiZEF58pAMYpngeWv/pjS8qCEVJzjwtz PvynmYn0f619N6JyHC37rPwTsHYKow9RNnKruTtmYbmS5KgoAFbg1XieP/80fzo53nw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380780; 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=PKFmj5ZNDapJCKJ82oIiLh5xRZr/fsNW3Ip8Xm/kAnc=; b=AG9X0xmo+QlcBSIJOOQVRHoFojLY6axj+BG5nqxvkItwFmxf93yDpgEgHtLOuwilUAeH wEHix8Wt0IvRDuRIb8oRaK+iynywZG2yZa/L3wD+A2+HIH5ulZArAuNswt/MHgi7Icby2 JN62D7py9r0YTJvS+RJ72JBLZEIRK0tj3miLKP7Nh74JNkEKap4s1cWWeH9vo/LFGVK7d xyu7cJz+trIhv6v/uwb6tI9WASa3AUdkF92cHUplCcZJjuDc4vm2AlVWvXQLYaUeSR9Gx KEVCZ0UYQZfvtqYu7BmCk8e/rC18PzsLrdrBr0U93VE/QR70fneZgx8f6VuZ/+xm6gg== 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=Sfmob8KV; 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 F073F606A338; Fri, 4 Dec 2026 10:39:39 +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=Sfmob8KV 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=1796380779; b=uzPXmVaw7CP9/wOoCHh1ewg97/Dfp0dp1Za3PJAf+EVfrH21EsSNSBkfiII75IE6gk1H Nfu0GtvcnRI+du+Lk1bEHKwcy2/qZm7S0E3D6F4bW8RgzHrr/SCfOfBjV8Z5JOF4DtGQa TqE6WDGhTeJ6HZ3CXRWq42Ig3GbfYRcBTFnsvI72qtn12tR/zyKhAzEIGUVK5p37+lxVk TUIlYukFJCeae0p6dsks9mFzAb4m5QR06B78aj/o4wgnIGFVh7KIGbJaMN69kAlOCdJLH qmAqYqpaBdpJbOOUOGMCzbiqtaK4YAHa1LNr75o3mPm3mss5x3J3CUHo6IgHSoxcy3A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380779; 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=PKFmj5ZNDapJCKJ82oIiLh5xRZr/fsNW3Ip8Xm/kAnc=; b=O+Z2iqYEEWNVrKjCal0xouXE9m93V9HzW8g/35vQ8XOXH6chiJNaKIVom7x4NhgdTUo9 oOIDkRIb6zG99q2zv4qqrQDuf+iq2ENqxNrpFp6NKuF8VYDO4huBEXCMXiX/0iKZMQbOk 4DJzjLUnquPKY1G7R9XM4U8dfruIEEHxxW3LaNCmWhLqMSvtlw/bCD10rZzyf+96xyiIT /4qxDSTDEsj2YwhTQtCt5QE73wYTxDafFGw/AVaPJtOMkc4PKj+Zdq9ZNz9WrKwh/RArk aIw4UhipqHdEYWB3+3wW2blVvcImfn0H6NGotWnsyM1n3UBUgeGFuTBQMkpOpfhhgVQ== 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=Sfmob8KV; 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 1C0F1606A32C; Fri, 4 Dec 2026 10:39:39 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DE671F00897; Fri, 4 Dec 2026 10:39:37 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796380778; bh=PKFmj5ZNDapJCKJ82oIiLh5xRZr/fsNW3Ip8Xm/kAnc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Sfmob8KVwyNdB6QmeYDV7dLkBJV3E3pxh2YnUpPnbQv6RQkcHKXgqte4bnmJLFGAW iCw0mdA+qPPmg9m2YIz4YLuZnd533yUj2dIE1KZw/YNO3UkVKFs0Hg2C7iP3Up1l/X laltjos+p6Fl64SBQZNDb9SpzC4ULagBEGrY2v4fSZLRBiAihGWrJlx6H+8KWhWxm4 dalnqUiVLvmFiWeaa1DxKHOIS0QAhmS7HLPEdZ94NhjdHtI2OCs39aaHRmZEU6Q9OV Tq71fBnM23ITlu/tnORx2HmCssVmB+MqP1rA0Z9mY+3UVnWB0dL4U/tbO8Y0MM/CMU 5l5Ux4NxIdv6A== X-Cc: magnus.karlsson@intel.com, maciej.fijalkowski@intel.com, aleksander.lobakin@intel.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, andrew+netdev@lunn.ch, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, netdev@vger.kernel.org, bpf@vger.kernel.org, horms@kernel.org, sdf@fomichev.me, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev, intel-wired-lan@lists.osuosl.org, clecigne@google.com, michal.swiatkowski@linux.intel.com, sriram.yagnaraman@ericsson.com, kurt@linutronix.de X-In-Reply-To: <20261203095647.3448925-3-bjorn@kernel.org> X-sashiko-severity: Low 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