Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: bjorn@kernel.org
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, andrew+netdev@lunn.ch,
	anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.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, intel-wired-lan@lists.osuosl.org,
	clecigne@google.com, michal.swiatkowski@linux.intel.com,
	sriram.yagnaraman@ericsson.com, kurt@linutronix.de
Subject: Re: [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size
Date: Fri, 04 Dec 2026 10:39:36 +0000	[thread overview]
Message-ID: <179638077683.3146.7227826095174306078@kernel.org> (raw)
In-Reply-To: <20261203095647.3448925-3-bjorn@kernel.org>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message understates how much of the shared info the
  old xdp_build_skb_from_zc() let a sender overwrite.

--

xdp: Size zero-copy skbs from the data, not the frame size

This patch changes how xdp_build_skb_from_zc() sizes the skb head. It now
uses data_end - data_hard_start instead of the XSk frame size, so packet
data can no longer overwrite the skb_shared_info. It also copies the exact
head and fragment lengths instead of rounding them up with LARGEST_ALIGN().
Heads larger than a page now come from __netdev_alloc_skb().

Link: https://lore.kernel.org/bpf/20260629072300.1664622-1-clecigne@google.com/

> With 2K chunks, no UMEM
> headroom and the default MTU, a 1514 byte frame that XDP passes on
> ice, idpf or gve needs 256 + 1514 + 320 = 2090 bytes and gets 2048.
> The sender controls up to 48 bytes of the shared info, its frag list
> among them.

[Severity: Low]
Is "up to 48 bytes" the real upper bound, or only the overflow for this
example? The 48 bytes come from 1514 rounded up to 1520 by LARGEST_ALIGN():
256 + 1520 + 320 - 2048 = 48.

For single-buffer pools, xsk_pool_get_rx_frame_size() subtracts the shared
info tailroom only for multi-buffer pools:

include/net/xdp_sock_drv.h:xsk_pool_get_rx_frame_size() {
    ...
	mbuf = pool->dev && (umem->flags & XDP_UMEM_SG_FLAG);
	frame_size -= xsk_pool_get_tailroom(mbuf);

	return ALIGN_DOWN(frame_size, 128);
}

xp_create_and_assign_umem() sets frame_sz to the whole chunk:

	xskb->xdp.frame_sz = umem->chunk_size - umem->headroom;

The commit message says a device may fill a single-buffer frame to its
end. In that case data_end - data_hard_start can equal frame_sz. One
example is a 2K chunk whose 1792 byte rx buffer is filled after a raised
MTU. Another is 4K chunks with 3840 byte frames.

The old code built the head with napi_build_skb(data, xdp->frame_sz). That
left only frame_sz - 320 bytes of linear room. So the copy would overwrite
all of SKB_DATA_ALIGN(sizeof(struct skb_shared_info)), which is 320 bytes
on x86_64, including frags[]. With 4K chunks, the LARGEST_ALIGN() rounding
could also write past the page handed out by the system page pool.

The sender also controls more than the frag list in the first 48 bytes.
The flags, nr_frags, frag_list, dataref and destructor_arg fields all sit
there. A chosen SKBFL_ZEROCOPY_* flag combined with a chosen
destructor_arg gives a callback pointer.

Could the commit message give the worst case as the whole shared info
rather than 48 bytes? The code change closes the whole overflow. Only the
stated impact looks understated.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203095647.3448925-1-bjorn%40kernel.org

  parent reply	other threads:[~2026-12-04 10:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  9:56 [PATCH net v3 0/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-03  9:56 ` [PATCH net v3 1/4] libeth: xsk: Count each XDP_TX buffer on its own Björn Töpel
2026-12-04 10:39   ` netdev-bot+sashiko
2026-12-03  9:56 ` [PATCH net v3 2/4] xdp: Size zero-copy skbs from the data, not the frame size Björn Töpel
2026-12-03 14:04   ` Maciej Fijalkowski
2026-12-04 10:39   ` netdev-bot+sashiko [this message]
2026-12-03  9:56 ` [PATCH net v3 3/4] intel: Copy the exact length of XSk packets to skbs Björn Töpel
2026-12-03 14:07   ` Maciej Fijalkowski
2026-12-03  9:56 ` [PATCH net v3 4/4] xsk: Keep the shared info of zero-copy buffers in kernel memory Björn Töpel
2026-12-03 15:16   ` Maciej Fijalkowski
2026-12-04 10:39   ` netdev-bot+sashiko

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=179638077683.3146.7227826095174306078@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrii@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clecigne@google.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=emil@etsalapatis.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=ihor.solodrai@linux.dev \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=michal.swiatkowski@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=sriram.yagnaraman@ericsson.com \
    --cc=willemb@google.com \
    --cc=yonghong.song@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