🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by bot+bpf-ci Tue, 24 Nov 2026 11:32
Re: [PATCH v8 bpf 3/7] xdp: introduce xdp_convert_skb_to_buff()
#21735
Author: bot+bpf-ci
Date: Tue, 24 Nov 2026 11:32
97 lines
12084 bytes
--===============5305319266284041173==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

> xdp: introduce xdp_convert_skb_to_buff()

TL;DR:
- Kernel-doc may wrongly say the head is page_pool backed only if copied; a
  future caller could free a page_pool page via page_frag_free()
- Commit message may omit a stable backport prerequisite (e6d90293fd16)

> diff --git a/include/net/xdp.h b/include/net/xdp.h
> --- a/include/net/xdp.h
> +++ b/include/net/xdp.h

[ ... ]

> +/**
> + * xdp_convert_skb_to_buff - build an xdp_buff on top of an skb
> + * @skb: skb to describe, packet data is taken from its MAC header onwards
> + * @xdp: xdp_buff to initialize
> + * @xdp_rxq: Rx queue info to attach to @xdp
> + *
> + * Sets the memory type of @xdp_rxq to MEM_TYPE_PAGE_POOL; the change stays
> + * on @xdp_rxq after the call. A non-linear @skb is expected to have gone
> + * through skb_pp_cow_data(), so all of its fragments are page_pool backed.
> + * The head is page_pool backed only if the whole skb was copied that way:
> + * a caller that may release the head through the memory type, e.g. by
> + * converting @xdp to an xdp_frame, has to set the type that matches it.
> + */

Is the statement "The head is page_pool backed only if the whole skb was
copied that way" accurate?

A driver can build an skb on a page_pool page and call
skb_mark_for_recycle() without any copy.  For example,
mvneta_swbm_build_skb() does:

    skb = napi_build_skb(xdp->data_hard_start, PAGE_SIZE);
    ...
    skb_mark_for_recycle(skb);
    skb_reserve(skb, xdp->data - xdp->data_hard_start);

and reserves MVNETA_SKB_HEADROOM, which is at least XDP_PACKET_HEADROOM.

netif_receive_generic_xdp() only calls netif_skb_check_for_xdp() when:

    if (skb_cloned(skb) || skb_is_nonlinear(skb) ||
        skb_headroom(skb) < XDP_PACKET_HEADROOM) {

so a linear, uncloned skb like that reaches bpf_prog_run_generic_xdp() ->
xdp_convert_skb_to_buff() with a page_pool head that was never copied.

Nothing breaks today, since generic XDP never releases the head through the
mem type, and veth takes its own page references before consume_skb().

But a future caller that turns @xdp into an xdp_frame and relies on this
sentence to pick MEM_TYPE_PAGE_SHARED for an uncopied head would free a
page_pool page with page_frag_free().

Could the wording say that the head is only known to be page_pool backed
after the copy, or that it may be page_pool backed for other reasons, so
that callers check rather than assume?

[ ... ]

Separately, the commit message has this paragraph:

> The problem exists since v6.9, see Fixes:. The stable range starts at
> 6.4.x, because the veth fix later in this series, which goes back to
> v6.4, uses this helper. Before v6.9 generic XDP linearizes all skbs, so
> there the mem type set here is never consulted.

Is the last sentence accurate for stable kernels between v6.4 and v6.9?

The mem type is written to the shared netdev rxq, and the write stays
there.  In those kernels bpf_prog_test_run_xdp() runs multi-buffer test
packets with alloc_page() frags on
__netif_get_rx_queue(loopback_dev, 0)->xdp_rxq, and reads that mem type
when the test program shrinks frags.

On a kernel that has this patch but not e6d90293fd16 ("bpf: test_run: Use a
private rxq info for XDP test runs"), those alloc_page() frags would be
freed as page_pool pages.

Should the commit message record e6d90293fd16 as a backport prerequisite,
the way the veth commit lists its prerequisites?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/45379686209
--===============5305319266284041173==--
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