Article View: linux.kernel.netdev
Article #25237Re: [PATCH net v2 2/4] xdp: Size zero-copy skbs from the data, not the frame size
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 12:39
Date: Tue, 01 Dec 2026 12:39
114 lines
12653 bytes
12653 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] The commit message makes the overflow fixed by this patch look
narrower than it is.
--
xdp: Size zero-copy skbs from the data, not the frame size
This commit changes xdp_build_skb_from_zc() to size the skb head from the
data instead of the XSk frame size, so long packets no longer overwrite
the skb shared info. It also stops rounding the head and fragment copies
up with LARGEST_ALIGN(). Heads that do not fit in a page now get a
kmalloc'd head from __netdev_alloc_skb().
Link: https://lore.kernel.org/bpf/20260629072300.1664622-1-clecigne@google.com/
> xdp_build_skb_from_zc() gives the skb head the frame size of the XSk
> buffer, and the skb shared info takes the end of it. A device may fill
> a single-buffer XSk frame to its end, so a long packet overwrites the
> shared info of the new skb with packet data. For example, with 4K
> chunks, MTU 3800, an xdp.frags program that returns XDP_PASS and a
> socket bound without XDP_USE_SG, a 3814 byte frame needs 256 + 3814 +
> 320 = 4390 bytes and gets 4096. The last patch of this series lets
> multi-buffer pools and bpf_xdp_adjust_tail() reach the end of the
> frame as well.
[ ... ]
> Reported by Clément Lecigne, and found again by an AI code review
> agent. Reproduced only with out-of-tree code: a test module, and the
> AF_XDP page-pool RFC on fbnic in QEMU.
[Severity: Medium]
Does this description make the overflow look harder to hit than it is?
The example needs 4K chunks, MTU 3800, an xdp.frags program and a non-SG
socket. In the baseline tree, the old xdp_build_skb_from_zc() also seems
to overflow with a common setup:
- 2K chunks
- no UMEM headroom
- the default 1500 MTU
- any XDP program that returns XDP_PASS on a zero-copy queue
No frags program is needed.
In-tree drivers reach this function on every XDP_PASS:
ice_clean_rx_irq_zc()->xdp_build_skb_from_zc()
__libeth_xsk_run_pass()->xdp_build_skb_from_zc() (idpf via libeth)
gve_rx_xsk_dqo()->xdp_build_skb_from_zc()
The pool sizes for that setup come from here:
net/xdp/xsk_buff_pool.c:xp_create_and_assign_umem() {
...
pool->frame_len = umem->chunk_size - umem->headroom -
XDP_PACKET_HEADROOM;
...
xskb->xdp.frame_sz = umem->chunk_size - umem->headroom;
...
}
This gives frame_sz = 2048 and frame_len = 1792.
For a pool without XDP_UMEM_SG_FLAG, xsk_pool_get_rx_frame_size() reserves
no tailroom. It returns ALIGN_DOWN(1792, 128) = 1792, and libeth gives
that to the device as fq->buf_len.
The old code then did:
u32 truesize = xdp->frame_sz;
...
skb = napi_build_skb(data, truesize);
...
skb_reserve(skb, xdp->data_meta - xdp->data_hard_start);
memcpy(__skb_put(skb, len), xdp->data_meta, LARGEST_ALIGN(len));
The system page pool returns a 2048-byte fragment. Then
napi_build_skb()->__finalize_skb_around() puts skb->end at
2048 - 320 = 1728.
skb_reserve(256) plus __skb_put(1514) moves tail to 1770. The memcpy() of
LARGEST_ALIGN(1514) = 1520 bytes then writes up to offset 1776.
That overwrites 48 bytes of the skb_shared_info that was just initialised
(nr_frags, frag_list, gso_*, dataref, destructor_arg). The sender of any
full-size 1500 MTU frame controls those bytes.
The new code handles this case: size = 1770, SKB_HEAD_ALIGN(1770) = 2112,
and end = 1792. The concern is only with the changelog.
Could the commit message describe the 2K chunk / standard MTU case on
in-tree drivers and the remote memory corruption impact? It currently
says "Reproduced only with out-of-tree code". The fuller description
would help stable and CVE triage judge how urgent the fix is.
The changelogs of the later patches in the series, "intel: Copy the exact
length of XSk packets to skbs" and "xsk: Keep the shared info of zero-copy
buffers in kernel memory", don't seem to cover this case either.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130123737.125432-1-bjorn%40kernel.org
Technical Details
Message-ID:
<179612875635.3146.8031227810272631513@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375027-linux-kernel-netdev=dewy.ruReferences:
<20261130123737.125432-3-bjorn@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375027-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2 2/4] xdp: Size zero-copy skbs from the data, not the frame size Date: Tue, 01 Dec 2026 12:39:16 +0000 Organization: Usenet Network Message-ID: <179612875635.3146.8031227810272631513@kernel.org> References: <20261130123737.125432-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="1710342"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:gNtiGQJRVs4DDNQabrRv4ifI0gI= sha256:iZBC94nKbGPyTI7bgMtO3RDueVcs9gC9RoFq33al4qg= sha1:dopdiaJRQzxEYiaCfO2V5Wa5BTY= sha256:8t+dIyocs6w02kz2kWRpjtTwzk72Bh+1IKs4HGCizdo= 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 73DE111737F; Tue, 1 Dec 2026 15:39:38 +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 a-sHL4BsK1Sp; Tue, 1 Dec 2026 15:39:34 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-375027-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 6BAAD11737C; Tue, 1 Dec 2026 15:39:25 +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 8C33424F3C; Tue, 1 Dec 2026 12:39:23 +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=1796128759; b=NBbHfwaUmcOaaj97TC9h1p06zI/LwcjiqbnT2TtggOmhxz+qC0h0K2lyBXfebF5H31/Y LWJn+AjDbbhkggYIttitdU+mJkyZzwixTpXUcAqL4JeRVl+7L2n5RyeMZVfAA+1xW02bi XyFqxp34hJvRzUDWWalczYKL5j+3zzryoGlAPeODTID9T+1qJPRcvw8Rl5habURvJ+f4+ OpUM70bF17iK+TOlfUw6MoCxTtvKBQqeHvzJVSMcqZz3fnyM7d60eQPtgCTenSWX4z0AF wTfkeRsz6NReNDnvYcMnSdF55GdLcr8D5TB7Bx+cL4/Eg6CM+TYJtN9e/RZ+0A+bG4A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796128759; 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=M1SYmdFe7BALv0lj9LIeV+RaNfoTb3vaTEODieEJmFo=; b=eQQ5XMY/Xo8Sd2VJAysFnuJpLNJSL7bTGmlnsGPf4rf6SkYfgWx9yOBfvcoUKRVkFU4q UcfqjNx2xjy195UA/lgg47ZROVudZtHsBdkbNAh5lcOGwqIwCb6nbFo5hxh9ETnDn1h+A DqWEyCv4HwLEGT16lTKWdIzn42DRExHh07y680tytXbTMeM3x7YzloPnkdoQLY5jWNlCB KqhF6iLm0lESEmmcjlPyB9T05r6WdQs80b3dKVdzt0idgePyob95LGLmB251jhdDbRMiU gHNOrziDaiztEnGN2jxvhp6UFz1SwCzey3kCDz87eCdvdL3LOOekyc0I1EAc/QC29+Q== 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=crMsqrSZ; 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 95706606A32E; Tue, 1 Dec 2026 12:39:19 +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=crMsqrSZ 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=1796128758; b=MUOzFwVRgfGVW2AMyCuB3agnkZ901gQhGCMTPUd/MTLt/KA2eEd+AJPmDUWr78qsGmcv YIe2JfdNpmKjtpvMor5/7ny3rrfJ6UJVNy70SLNuf/VgJ39nkYCEqMVal5LhWf6ydC3ht luKw1neGQkelHev45awrCL/bmyC1X0ZgC6EtRkuuLTcHQkFjHVsMhScZ4pR7K1TcoWauf av3M4a4kDSXE2KZYRAHVNqI4rZXo7VNvqrVR1vpB6zmm9lOpF9oeO7mrge8rofpll9xZk OpwkquvR+diInl7zUyJi0w9EKynyzG9bUNp7xq7N6sd63fYk7EnyrpGh+jie7G1qeNQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796128758; 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=M1SYmdFe7BALv0lj9LIeV+RaNfoTb3vaTEODieEJmFo=; b=WCDSvaYYTqzCDPMNXfX12S7Visbr0IkrUx29MTlXNRs98kUu8OlkI+uIZI/b8KBVDiPw f4crk4NkFHXtjy6CVAueexAMKPQNxylsaL86HavK5iZIv45goc4nick52+FitewSWqzao RBNBWWE+KGoh28exzc5SqFXdE03+R5afG/Pu9BfhpEF2uTXwZ6iYtXSeAl6U1z1JnK4GM rYvPoo999edlJ4ui13K5K9X3yugDAFqNYu6lRr500yF33HTZYm6/U74hLmJpnIYz5i4Yn QM34XDPPlyreNEZwgNUHsA9yVQY6PEVeIha5dZaJ+5OjyKfF7D6oiYFtQ82a/QhNGQw== 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=crMsqrSZ; 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 B6D03606A338; Tue, 1 Dec 2026 12:39:18 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD52F1F000C1; Tue, 1 Dec 2026 12:39:16 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796128758; bh=M1SYmdFe7BALv0lj9LIeV+RaNfoTb3vaTEODieEJmFo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=crMsqrSZIHMd6ImtF1P1VAigt4kFpS4qFGNAEGECG6d42/fAUfrkqQ7RYHxdBiMwo uj+fPrGDU3odovfnkSUES/x8s3SdnxTmymKABkVfV20LsISPrc7vBJn/EKHCs2bGOn JOyBUm57KcjveMoe8D0++yonuMYjlyp/n55D4WNFu8a5iC9r/URRRLJWN8SwbpPNrF rdeEa4YRNMqE3/2U5U2RNCNsfuCxUJ7wF/gI+Hxc1soF8+FexgO6r2jVD6FLieju1A 0FNFhyZNoQ91Nmm8PZWTqefe1Ku7/63RafHrNqrhAasvfpv+Y+FdeAkmJJtoodG90o 4C9MCsc6G3b5w== 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, 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, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, intel-wired-lan@lists.osuosl.org, clecigne@google.com X-In-Reply-To: <20261130123737.125432-3-bjorn@kernel.org> 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