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] The commit message makes the overflow fixed by this patch look
narrower than it is.
--
xdp: Size zero-copy skbs from the data, not the frame size
This commit changes xdp_build_skb_from_zc() to size the skb head from the
data instead of the XSk frame size, so long packets no longer overwrite
the skb shared info. It also stops rounding the head and fragment copies
up with LARGEST_ALIGN(). Heads that do not fit in a page now get a
kmalloc'd head from __netdev_alloc_skb().
Link: https://lore.kernel.org/bpf/2026…@google.com/
> xdp_build_skb_from_zc() gives the skb head the frame size of the XSk
> buffer, and the skb shared info takes the end of it. A device may fill
> a single-buffer XSk frame to its end, so a long packet overwrites the
> shared info of the new skb with packet data. For example, with 4K
> chunks, MTU 3800, an xdp.frags program that returns XDP_PASS and a
> socket bound without XDP_USE_SG, a 3814 byte frame needs 256 + 3814 +
> 320 = 4390 bytes and gets 4096. The last patch of this series lets
> multi-buffer pools and bpf_xdp_adjust_tail() reach the end of the
> frame as well.
[ ... ]
> Reported by Clément Lecigne, and found again by an AI code review
> agent. Reproduced only with out-of-tree code: a test module, and the
> AF_XDP page-pool RFC on fbnic in QEMU.
[Severity: Medium]
Does this description make the overflow look harder to hit than it is?
The example needs 4K chunks, MTU 3800, an xdp.frags program and a non-SG
socket. In the baseline tree, the old xdp_build_skb_from_zc() also seems
to overflow with a common setup:
- 2K chunks
- no UMEM headroom
- the default 1500 MTU
- any XDP program that returns XDP_PASS on a zero-copy queue
No frags program is needed.
In-tree drivers reach this function on every XDP_PASS:
ice_clean_rx_irq_zc()->xdp_build_skb_from_zc()
__libeth_xsk_run_pass()->xdp_build_skb_from_zc() (idpf via libeth)
gve_rx_xsk_dqo()->xdp_build_skb_from_zc()
The pool sizes for that setup come from here:
net/xdp/xsk_buff_pool.c:xp_create_and_assign_umem() {
...
pool->frame_len = umem->chunk_size - umem->headroom -
XDP_PACKET_HEADROOM;
...
xskb->xdp.frame_sz = umem->chunk_size - umem->headroom;
...
}
This gives frame_sz = 2048 and frame_len = 1792.
For a pool without XDP_UMEM_SG_FLAG, xsk_pool_get_rx_frame_size() reserves
no tailroom. It returns ALIGN_DOWN(1792, 128) = 1792, and libeth gives
that to the device as fq->buf_len.
The old code then did:
u32 truesize = xdp->frame_sz;
...
skb = napi_build_skb(data, truesize);
...
skb_reserve(skb, xdp->data_meta - xdp->data_hard_start);
memcpy(__skb_put(skb, len), xdp->data_meta, LARGEST_ALIGN(len));
The system page pool returns a 2048-byte fragment. Then
napi_build_skb()->__finalize_skb_around() puts skb->end at
2048 - 320 = 1728.
skb_reserve(256) plus __skb_put(1514) moves tail to 1770. The memcpy() of
LARGEST_ALIGN(1514) = 1520 bytes then writes up to offset 1776.
That overwrites 48 bytes of the skb_shared_info that was just initialised
(nr_frags, frag_list, gso_*, dataref, destructor_arg). The sender of any
full-size 1500 MTU frame controls those bytes.
The new code handles this case: size = 1770, SKB_HEAD_ALIGN(1770) = 2112,
and end = 1792. The concern is only with the changelog.
Could the commit message describe the 2K chunk / standard MTU case on
in-tree drivers and the remote memory corruption impact? It currently
says "Reproduced only with out-of-tree code". The fuller description
would help stable and CVE triage judge how urgent the fix is.
The changelogs of the later patches in the series, "intel: Copy the exact
length of XSk packets to skbs" and "xsk: Keep the shared info of zero-copy
buffers in kernel memory", don't seem to cover this case either.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40kernel.org