BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Björn Töpel" <bjorn@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [RFC net-next 11/15] xdp: Copy provider buffers on pass and redirect
Date: Sat, 03 Oct 2026 19:02:38 +0000	[thread overview]
Message-ID: <20261003190239.B15771F0089C@smtp.kernel.org> (raw)
In-Reply-To: <20261002190018.696925-12-bjorn@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: xdp: payload truncation in xdp_build_skb_from_zc() when metadata unsupported
--

commit a36f92358b032a7e20669d832f27102e55f9f4eb
Author: Björn Töpel <bjorn@kernel.org>

xdp: Copy provider buffers on pass and redirect

This commit introduces logic to copy provider buffers into kernel pages
on pass and redirects, handling fragments appropriately. It splits the
copy from the release for redirects, maintaining the classic zero-copy
path while resolving frag addresses through xdp_frag_address().

> diff --git a/net/core/xdp.c b/net/core/xdp.c
> index 386240bd24c98..b7f16f44dac22 100644
> --- a/net/core/xdp.c
> +++ b/net/core/xdp.c
[ ... ]
> @@ -638,6 +718,9 @@ struct sk_buff *xdp_build_skb_from_buff(const struct xdp_buff *xdp)
>  	u32 nr_frags = 0;
>  	int metalen;
>  
> +	if (xdp_buff_has_netmem(xdp))
> +		return xdp_build_skb_from_zc(xdp);
> +
>  	if (unlikely(xdp_buff_has_frags(xdp))) {

[Severity: High]
Does generalizing xdp_build_skb_from_zc() to handle all netmem buffers cause
a payload truncation when metadata is unsupported?

Previously, xdp_build_skb_from_zc() only handled pure XSK buffers, where
data_meta == data is guaranteed. Now, it can receive generic provider-backed
netmem buffers.

If a netmem provider driver does not support metadata and initializes the
buffer via xdp_prepare_buff() with false, xdp->data_meta is set to
xdp->data + 1.

Looking at the length calculation and copy in xdp_build_skb_from_zc():

struct sk_buff *xdp_build_skb_from_zc(struct xdp_buff *xdp)
{
        u32 headroom = xdp->data_meta - xdp->data_hard_start;
        ...
        u32 len = xdp->data_end - xdp->data_meta;
        ...
        memcpy(__skb_put(skb, len), xdp->data_meta, len);
}

Without checking xdp_data_meta_unsupported(xdp), it blindly uses
xdp->data_meta to determine the length and as the source for memcpy().

Could this cause the first byte of every packet to be truncated and the
payload to be shifted by one byte, leading to silent data corruption on
XDP_PASS?

Should xdp_build_skb_from_zc() check xdp_data_meta_unsupported(xdp) similar
to how xdp_copy_zc_to_xdp_frame() handles it?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261002190018.696925-1-bjorn@kernel.org?part=11

  reply	other threads:[~2026-10-03 19:02 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 19:00 [RFC net-next 00/15] xsk: Zero copy through page-pool memory providers Björn Töpel
2026-10-02 19:00 ` [RFC net-next 01/15] xdp: Size zero-copy skb heads by their contents Björn Töpel
2026-10-02 19:00 ` [RFC net-next 02/15] eth: fbnic: Report the logical XDP RX queue Björn Töpel
2026-10-02 19:00 ` [RFC net-next 03/15] net: Add memory provider capabilities Björn Töpel
2026-10-03  4:13   ` Mina Almasry
2026-10-09 14:54     ` Björn Töpel
2026-10-03 19:02   ` sashiko-bot
2026-10-05 16:26   ` Stanislav Fomichev
2026-10-02 19:00 ` [RFC net-next 04/15] net: Let memory providers set RX buffer headroom Björn Töpel
2026-10-05 16:52   ` Stanislav Fomichev
2026-10-02 19:00 ` [RFC net-next 05/15] page_pool: Extend memory provider operations Björn Töpel
2026-10-05 16:51   ` Stanislav Fomichev
2026-10-02 19:00 ` [RFC net-next 06/15] xdp: Track non-page netmem in receive buffers Björn Töpel
2026-10-05 17:01   ` Stanislav Fomichev
2026-10-02 19:00 ` [RFC net-next 07/15] xsk: Keep the DMA mapping in the buffer pool Björn Töpel
2026-10-02 19:00 ` [RFC net-next 08/15] xsk: Handle a detached FILL ring in RX wakeup Björn Töpel
2026-10-02 19:00 ` [RFC net-next 09/15] xsk: Add a page-pool memory provider for UMEM Björn Töpel
2026-10-05 17:38   ` Stanislav Fomichev
2026-10-02 19:00 ` [RFC net-next 10/15] xsk: Add RX helpers for page-pool drivers Björn Töpel
2026-10-02 19:00 ` [RFC net-next 11/15] xdp: Copy provider buffers on pass and redirect Björn Töpel
2026-10-03 19:02   ` sashiko-bot [this message]
2026-10-02 19:00 ` [RFC net-next 12/15] xsk: Receive provider UMEM without copying Björn Töpel
2026-10-02 19:00 ` [RFC net-next 13/15] eth: fbnic: Support AF_XDP zero-copy receive Björn Töpel
2026-10-03 19:02   ` sashiko-bot
2026-10-05 17:51   ` Stanislav Fomichev
2026-10-02 19:00 ` [RFC net-next 14/15] eth: fbnic: Support AF_XDP zero-copy transmit Björn Töpel
2026-10-02 19:00 ` [RFC net-next 15/15] Documentation: xsk: Document page-pool zero copy Björn Töpel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261003190239.B15771F0089C@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox