Article View: linux.kernel.netdev
Article #23838Re: [PATCH net v9 4/6] veth: use the page_pool mem type when running XDP on an skb
From: netdev-bot+sashiko
Date: Sat, 28 Nov 2026 10:03
Date: Sat, 28 Nov 2026 10:03
98 lines
12306 bytes
12306 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] In drivers/net/veth.c, veth_convert_skb_to_xdp_buff() now
always sets rxq->mem.type = MEM_TYPE_PAGE_POOL.
--
veth: use the page_pool mem type when running XDP on an skb
veth now runs the XDP program on an skb with an on-stack rxq info whose
mem type is MEM_TYPE_PAGE_POOL. Frags that the program shrinks away go
back to the page_pool they came from. On XDP_TX and XDP_REDIRECT,
veth_xdp_get() switches the mem type back to MEM_TYPE_PAGE_SHARED, and
the saved rq->xdp_mem is removed.
Link: https://lore.kernel.org/all/DN3QVHST3PUQ.3NINFUW0FL9IW@gmail.com/
> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> index cce253b58c2bc..8bb015c133760 100644
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c
[ ... ]
> @@ -773,7 +776,9 @@ static int veth_convert_skb_to_xdp_buff(struct veth_rq *rq,
> /* SKB "head" area always have tailroom for skb_shared_info */
> frame_sz = skb_end_pointer(skb) - skb->head;
> frame_sz += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
> - xdp_init_buff(xdp, frame_sz, &rq->xdp_rxq);
> + /* the prog can free only frags and they came from skb_pp_cow_data() */
> + rxq->mem.type = MEM_TYPE_PAGE_POOL;
> + xdp_init_buff(xdp, frame_sz, rxq);
[Severity: Medium]
Is the invariant in this comment guaranteed by the code?
Earlier in veth_convert_skb_to_xdp_buff(), the copy into page_pool
memory depends on skb_is_nonlinear(), which tests skb->data_len:
if (skb_shared(skb) || skb_head_is_locked(skb) ||
skb_is_nonlinear(skb) ||
skb_headroom(skb) < XDP_PACKET_HEADROOM) {
if (skb_pp_cow_data(rq->page_pool, pskb, XDP_PACKET_HEADROOM))
goto drop;
The frags flag set just below depends on nr_frags instead:
if (skb_shinfo(skb)->nr_frags) {
skb_shinfo(skb)->xdp_frags_size = skb->data_len;
xdp_buff_set_frags_flag(xdp);
Take an skb that is unshared and unlocked, has enough headroom, and has
nr_frags > 0 but data_len == 0 (all frags are zero-length). It skips
skb_pp_cow_data() and keeps its original frag pages, which are not
page_pool pages. It still gets XDP_FLAGS_HAS_FRAGS and runs with
MEM_TYPE_PAGE_POOL.
Suppose a frags-aware program then calls bpf_xdp_adjust_tail() with a
negative offset. For each zero-size frag, bpf_xdp_frags_shrink_tail()
computes shrink = 0, and bpf_xdp_shrink_data() treats the frag as fully
consumed:
bpf_xdp_adjust_tail()
bpf_xdp_frags_shrink_tail()
bpf_xdp_shrink_data() /* release = (size == shrink) */
__xdp_return(netmem, MEM_TYPE_PAGE_POOL, ...)
page_pool_put_full_netmem(netmem_get_pp(netmem), ...)
For MEM_TYPE_PAGE_POOL, __xdp_return() does not check netmem_is_pp().
Wouldn't netmem_get_pp() then read a pp pointer from a page that was
never part of a page_pool? Before this patch, the same frag went through
page_frag_free() under MEM_TYPE_PAGE_SHARED, which releases it correctly.
I could not find a concrete source of such an skb reaching veth_xmit(),
and the usual skb helpers avoid leaving zero-size frags behind. However,
nothing in veth rejects that state.
The sibling change "xdp: run generic XDP on frags with a copy of the rxq
info" uses skb_is_nonlinear() for the copy decision, the frags flag and
MEM_TYPE_PAGE_POOL. Could the frags flag here also be set from
skb_is_nonlinear()? Alternatively, MEM_TYPE_PAGE_POOL could be used only
when skb_pp_cow_data() actually ran, keeping MEM_TYPE_PAGE_SHARED
otherwise.
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127100132.1977890-1-sst%40poczta.fm
Technical Details
Message-ID:
<179586023747.3135.10147454988994351806@kernel.org>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373084-linux-kernel-netdev=dewy.ruReferences:
<20261127100132.1977890-5-sst@poczta.fm>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373084-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v9 4/6] veth: use the page_pool mem type when running XDP on an skb Date: Sat, 28 Nov 2026 10:03:57 +0000 Organization: Usenet Network Message-ID: <179586023747.3135.10147454988994351806@kernel.org> References: <20261127100132.1977890-5-sst@poczta.fm> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="927520"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:kFV+u/G9HV99p44aDstFEO4klEU= sha256:sU922wld5taemFqrpGQmaquw2ojnegTRQOH4uV+qT0Q= sha1:cpLRXEshvEsTiE2rh0klEtJCr6g= sha256:yCGROv6Pti5p1+AFT+CSyd9se8QvzssRbbpBNcunWvM= 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 CD5D8125F73; Sat, 28 Nov 2026 13:04:25 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 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, 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 eVhub1HANqoI; Sat, 28 Nov 2026 13:04:22 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-373084-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 AB3A8125F72; Sat, 28 Nov 2026 13:04:12 +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 6E77625D47; Sat, 28 Nov 2026 10:04:06 +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=1795860241; b=uxjTILoPK91cT13dkwgkLfiMr0oT7y6tMgKcVDK0kQ3bOVvqGgH9+C7qTzj8smsWz0zd 4RnpXQB3898x1KUSoQ8S8u7rHBUQfDp3nbxaFhX4D56QNBr1c7cmdIv+WYyKXYT6vZ5WO Z8TSKcgurjiss2zRz0bNmdx7b4T0uBtItOwKA3CMTN9su93K1Ef2pAGkEbT+R1c7YrkM4 76OCPMSeWNc5snO8rfdf7wkYB2HewXFrK4dHmVyKmj1DudaoacJOufU630W6Nl4Nnv4ii 9tEXD4QL+jRa6NuXsgSkPYY8U9latcKC1BxrmsrXWsJxm27BfIQtIOoBRJb2c5PVZvA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795860241; 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=cqPxtPyOFKb6uO8nwJlphwDuGUng3FGbn1dSPlT7TjQ=; b=prdCe5w7d4KEwWiOcrP/mYeSh+FS4kpKTeqVtkTZJXxkEgDXaQj9stS7ltpFSm/8iIlm NZeJ1klV96P4otd9LIAP3axpnGDUM2nAYhnZ7Ds8XZx940F+t/c1F0izlA2XZ93fiqJrM X0f2zoiDOHfdPKaXo9lrDLX3lSEh54ON1ssB4stJNDFqoKKESk42J1QEgNiP9xe0ZKTIS ZExaw01rz9KlSHwkrNOvEQvemRRCMAgsIiELH4hRl0g83H1q0Tj1FZnRffWv5nXfS+2Bm CKbSp5JD2PNbkriTISz24AhzlPiWcZUAGFIcKGKsz5XUV5C3oME7V3AEtf02bzuW/mw== 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=L2RUwJrz; 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 696B3606A680; Sat, 28 Nov 2026 10:04:01 +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=L2RUwJrz 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=1795860240; b=y7fVAdkuguRvXDH7jKfcGI28EAJRl45TeiB0s/eOC0z0FzK3Dcj9tM9iu/3XSwj2bneV Povqt3rkTo7pMe26b6XSnPE0N5ttgqN+JM8gf7P9QYDYPcd4CcwUOY1pk6ZDmBxZvLDwZ 5eEflURZXgQozK33Jb6Lqm4LCJBpt8WHDzSSw3D2cSO6XNIR65mnTaUhmUO5EnD3J/7kO P6C8r8SSh+bw1NS2ETNTEFfaNFiliejGG1FiA5gvsHCIx+2J1jYKnmsr5WbJEs4ptGE0q l618RE56vj6cAB8VEL/GBg4FA4H9/uv2syj2MPe3V+Enf3EYZIuFxKBGmqg5kzBc86Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795860240; 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=cqPxtPyOFKb6uO8nwJlphwDuGUng3FGbn1dSPlT7TjQ=; b=qhwB+OXY7y1KtnsF4I7GGfbxqPKEmMAUznLCHBa1Xlc8dqZxbMqOrUk+EGYoDyGRvWg6 NNAJusuxD4TuBv+wunXsDbpGjD84/PEOOWX3r6fNXU93UcQgx2GmO4eJqKQJSDFtLVq+U /3LEe2eG7mivmOY5f4OMYs4DftkxDqCHzpfh8C0x1Jgh5MD4ECq5cQM9VjWw2PCqxzi9a k+jwNwKfgoIx7nUAkOQldvguquz5qwM70ZuQDRrwrn5kWtMrflmZ1m0SVOAhS7d+qpX1q ajgfpx2h9Po2pO+PUuFy2AQKFY61lhHMqLYbZyYmrAx//zo4GDyvA8FzNHO10tqVEYw== 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=L2RUwJrz; 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 864AE606A32E; Sat, 28 Nov 2026 10:04:00 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA8C41F000C1; Sat, 28 Nov 2026 10:03:57 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795860239; bh=cqPxtPyOFKb6uO8nwJlphwDuGUng3FGbn1dSPlT7TjQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=L2RUwJrzxxZKmmo/OXjN51WpWsDN2oue9EWqn5z+aDhwG1cjslI7NAiBsU6E/a5Mg cIOfMjMFIzZ4W5cVyIqCV3YFDr/0nIWBvGGrvjau00AvtsZ7BZqJ1PPpky2sF4lxvt GcMAHczSe9Q8nan/IfCMfO8HHqnkU1yy6E0Z/NMbpm4DliVExhlEYBY1+l3mm7aokp Ydbt2pwNAhR2k7oULkJg8L64pqnksn6366dA18jOtpy1YmHxhBrGxjW+bNa8scQa1Y QfouXGouOwlmZ0kgvPth/be4ojDYgvBRqNEVVMcNyEtYj/XFYTu74T/ENmJtDtrhbx 04tuj57vYHLfg== X-Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me, bpf@vger.kernel.org, netdev@vger.kernel.org, jiayuan.chen@linux.dev, phx0fer@gmail.com, maciej.fijalkowski@intel.com, tianyi@cloudflare.com, tavip@google.com, toke@redhat.com, aleksander.lobakin@intel.com, lorenzo@kernel.org, lorenzo.bianconi@oss.qualcomm.com, ihor.solodrai@linux.dev, andrew+netdev@lunn.ch, willemb@google.com, horms@kernel.org, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, memxor@gmail.com, emil@etsalapatis.com, shuah@kernel.org, linux-kselftest@vger.kernel.org X-In-Reply-To: <20261127100132.1977890-5-sst@poczta.fm> 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