๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by netdev-bot+sashiko Sat, 28 Nov 2026 10:03
Re: [PATCH net v9 4/6] veth: use the page_pool mem type when running XDP on an skb
#23838
Author: netdev-bot+sashiko
Date: Sat, 28 Nov 2026 10:03
98 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads