BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tianyi Gao" <tianyi@cloudflare.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next 2/8] net: reserve extra TX headroom for local egress
Date: Sun, 08 Nov 2026 03:35:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-203545@kernel.org> (raw)
In-Reply-To: <4b2f20b9a7bcca58fced690d20916efab55ad31a.1794020868.git.tianyi@cloudflare.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] xsk: u16 overflow of skb->csum_start in xsk_skb_metadata() [1]
--

commit 5b52f2c11788442c9d7cb29588e09f1fbbe3b128
Author: David Keogh <dkeogh@amazon.com>

net: reserve extra TX headroom for local egress

This commit updates local packet allocation paths in IPv4, IPv6,
AF_PACKET, and AF_XDP to include the device's configured extra TX
headroom via LL_ALLOC_SPACE(), LL_ALLOC_SPACE_EX(), and
netdev_tx_alloc_headroom().

> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 781ba46eb1525..3ee8ad3fd1556 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -1045,7 +1045,8 @@ static struct sk_buff *xsk_build_skb_zerocopy(struct xdp_sock *xs,
>  	buffer = xsk_buff_raw_get_data(pool, addr);
>  
>  	if (!skb) {
> -		hr = max(NET_SKB_PAD, L1_CACHE_ALIGN(xs->dev->needed_headroom));
> +		hr = max(NET_SKB_PAD,
> +			 L1_CACHE_ALIGN(netdev_tx_alloc_headroom(xs->dev)));
>  
>  		skb = sock_alloc_send_skb(&xs->sk, hr, 1, &err);
>  		if (unlikely(!skb))
> @@ -1128,7 +1129,8 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
>  		len = desc->len;
>  
>  		if (!skb) {
> -			hr = max(NET_SKB_PAD, L1_CACHE_ALIGN(dev->needed_headroom));
> +			hr = max(NET_SKB_PAD,
> +				 L1_CACHE_ALIGN(netdev_tx_alloc_headroom(dev)));
>  			tr = dev->needed_tailroom;
>  			skb = sock_alloc_send_skb(&xs->sk, hr + len + tr, 1, &err);
>  			if (unlikely(!skb))

[Severity: High]
This problem wasn't introduced by this patch, but can hr + csum_start
overflow the u16 skb->csum_start field in xsk_skb_metadata() [1]?

net/xdp/xsk.c:xsk_skb_metadata() {
	...
	if (flags & XDP_TXMD_FLAGS_CHECKSUM) {
		csum_start = READ_ONCE(meta->request.csum_start);
		csum_offset = READ_ONCE(meta->request.csum_offset);

		if (unlikely(csum_start + csum_offset +
			     sizeof(__sum16) > desc->len))
			return -EINVAL;

		skb->csum_start = hr + csum_start;
		skb->csum_offset = csum_offset;
		skb->ip_summed = CHECKSUM_PARTIAL;
	}
	...
}

When a UMEM is registered with chunk_size equal to PAGE_SIZE on a 64KB
page kernel (or with a large headroom reservation), desc->len can be up to
65536 and hr + csum_start can exceed U16_MAX while still passing the
desc->len check.  Truncating the sum into skb->csum_start wraps it below
skb_headroom(skb), making skb_checksum_start_offset() negative and
triggering skb_dump() and WARN_ONCE() in skb_checksum_help() or passing a
malformed skb to the driver in validate_xmit_skb().

[1] https://sashiko.dev/#/bug/linux-38d27ef1-cee4-4d03-9410-7bc1d8e0c2f6

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794020868.git.tianyi@cloudflare.com?part=2

  reply	other threads:[~2026-11-08  3:35 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07  3:34 [PATCH net-next 0/8] net: configurable extra TX headroom for local egress Tianyi Gao
2026-11-07  3:34 ` [PATCH net-next 1/8] net: add tx_extra_headroom and LL_ALLOC_SPACE() Tianyi Gao
2026-11-07 14:51   ` Willem de Bruijn
2026-11-07 18:25     ` Tianyi Gao
2026-11-08 15:13       ` Willem de Bruijn
2026-11-08 21:43         ` Tianyi Gao
2026-11-10 14:48           ` Jesper Dangaard Brouer
2026-11-09  3:08         ` Stephen Hemminger
2026-11-09 15:49           ` Tianyi Gao
2026-11-10 16:23             ` Willem de Bruijn
2026-11-10 20:12               ` Tianyi Gao
2026-11-11  3:27                 ` Willem de Bruijn
2026-11-11 20:23             ` David Keogh
2026-11-11 20:37               ` David Keogh
2026-11-11 21:41                 ` Tianyi Gao
2026-11-11 23:19                   ` David Keogh
2026-11-12  0:03                     ` Tianyi Gao
2026-11-07  3:34 ` [PATCH net-next 2/8] net: reserve extra TX headroom for local egress Tianyi Gao
2026-11-08  3:35   ` sashiko-bot [this message]
2026-11-08 22:22     ` Tianyi Gao
2026-11-07  3:34 ` [PATCH net-next 3/8] rtnetlink: add IFLA_TX_EXTRA_HEADROOM Tianyi Gao
2026-11-07  3:34 ` [PATCH net-next 4/8] selftests: net: add tx_extra_headroom test Tianyi Gao
2026-11-07  3:34 ` [PATCH net-next 5/8] selftests: net: tx_extra_headroom: test a push at TC egress Tianyi Gao
2026-11-07  3:34 ` [PATCH net-next 6/8] selftests: net: add flag to send a frame in xdp_helper Tianyi Gao
2026-11-07  3:34 ` [PATCH net-next 7/8] selftests: net: tx_extra_headroom: test generic XDP on the veth peer Tianyi Gao
2026-11-07  3:34 ` [PATCH net-next 8/8] selftests: net: tx_extra_headroom: test veth peer at creation Tianyi Gao
2026-11-10 15:38   ` Jakub Kicinski
2026-11-10 15:45     ` Tianyi Gao

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=sashiko-outbox-203545@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tianyi@cloudflare.com \
    /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