* Re: [PATCH net] net: xdp: Fix skb->tail after bpf_xdp_adjust_tail() in generic mode
2026-11-26 12:55 [PATCH net] net: xdp: Fix skb->tail after bpf_xdp_adjust_tail() in generic mode Sechang Lim
@ 2026-11-26 12:58 ` netdev-bot+sinfo
2026-11-26 13:15 ` Sechang Lim
2026-11-27 12:58 ` netdev-bot+sashiko
1 sibling, 1 reply; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-26 12:58 UTC (permalink / raw)
To: Sechang Lim
Cc: netdev, bpf, davem, edumazet, kuba, pabeni, willemb, horms, ast,
daniel, hawk, john.fastabend, sdf, tehnerd
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: xdp: Fix skb->tail after bpf_xdp_adjust_tail() in generic mode
2026-11-26 12:55 [PATCH net] net: xdp: Fix skb->tail after bpf_xdp_adjust_tail() in generic mode Sechang Lim
2026-11-26 12:58 ` netdev-bot+sinfo
@ 2026-11-27 12:58 ` netdev-bot+sashiko
1 sibling, 0 replies; 4+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 12:58 UTC (permalink / raw)
To: rhkrqnwk98
Cc: netdev, bpf, davem, edumazet, kuba, pabeni, willemb, horms, ast,
daniel, hawk, john.fastabend, sdf, tehnerd
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · 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).
- [High] Generic XDP assumes the frame left after the BPF program runs
still covers the mac_len bytes of L2 header that it subtracts.
--
net: xdp: Fix skb->tail after bpf_xdp_adjust_tail() in generic mode
This patch changes how bpf_prog_run_generic_xdp() recomputes skb->tail
after bpf_xdp_adjust_tail() has moved data_end. It now subtracts mac_len,
because the XDP frame starts mac_len bytes before skb->data. Without this,
skb->tail could land past skb->end, and a later tc bpf_skb_change_tail()
would write out of bounds.
> diff --git a/net/core/dev.c b/net/core/dev.c
> index cd0796a1dbfdf..1934e11c4401a 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -5737,7 +5737,7 @@ u32 bpf_prog_run_generic_xdp(struct sk_buff *skb, struct xdp_buff *xdp,
> /* check if bpf_xdp_adjust_tail was used */
> off = xdp->data_end - orig_data_end;
> if (off != 0) {
> - skb_set_tail_pointer(skb, xdp->data_end - xdp->data);
> + skb_set_tail_pointer(skb, xdp->data_end - xdp->data - mac_len);
> skb->len += off; /* positive on grow, negative on shrink */
[Severity: High]
This line assumes the frame left after the XDP program still covers the
mac_len bytes being subtracted. Is that guaranteed?
bpf_xdp_adjust_tail() only enforces a floor of ETH_HLEN relative to
xdp->data, not mac_len:
net/core/filter.c:bpf_xdp_adjust_tail() {
...
if (unlikely(data_end < xdp->data + ETH_HLEN))
return -EINVAL;
...
}
bpf_xdp_frags_shrink_tail() uses the same ETH_HLEN floor for nonlinear
frames.
In generic XDP, mac_len can be larger than ETH_HLEN. One example is a GRE
device that uses ipgre_header_ops (no remote, or a multicast remote). On
such a device, __ipgre_rcv() leaves mac_header at the outer IP header:
net/ipv4/ip_gre.c:__ipgre_rcv() {
...
if (tunnel->dev->header_ops == &ipgre_header_ops)
skb_pop_mac_header(skb);
...
}
So mac_len is at least 24 by the time do_xdp_generic() runs. The IPoIB
pseudo-header has a similar effect.
Take mac_len = 24 and headlen H, with a program that shrinks the frame to
data_end = xdp->data + 14:
off = -(H + 10)
skb_set_tail_pointer(skb, 14 - 24) -> skb->tail = skb->data - 10
skb->len += off -> skb->len wraps to 0xfffffff6
Before this patch tail was at least skb->data + 14. With it, tail ends up
before skb->data. The skb->len wrap is not new; it happened before this
patch too.
With that state, can the KASAN splat from the commit message still be
reached? A tc program that calls bpf_skb_change_tail(skb, 4096) sees
new_len < skb->len and takes the trim path:
bpf_skb_change_tail()
pskb_trim_rcsum()
__skb_trim() -> skb->tail = skb->data + 4096
That can put tail past skb->end. A second call that grows the skb then
reaches __skb_grow() with a negative skb_tailroom(), no expand happens,
and bpf_skb_grow_rcsum() writes past the buffer.
Even without tc, ip_rcv_core() trusts the wrapped skb->len and calls
pskb_trim_rcsum(skb, iph->tot_len). tot_len comes from the received inner
header, so this could also move tail past skb->end.
The adjust_head fixup earlier in bpf_prog_run_generic_xdp() has a similar
gap. bpf_xdp_adjust_head() also keeps only ETH_HLEN bytes:
if (unlikely(data < data_start ||
data > xdp->data_end - ETH_HLEN))
return -EINVAL;
So off in __skb_pull(skb, off) can reach headlen + mac_len - ETH_HLEN. On
a linear skb that is larger than skb->len, and skb->len wraps silently.
Would it make sense to drop or clamp the frame here when
xdp->data_end - xdp->data < mac_len, and to do the same for the
adjust_head path? Another option is a lower bound in the helpers that
accounts for the generic XDP mac_len.
> }
>
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126125558.2032158-1-rhkrqnwk98%40gmail.com
^ permalink raw reply [flat|nested] 4+ messages in thread