BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Petr Oros" <poros@redhat.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net] xsk: reset the mac header in the generic Tx path
Date: Tue, 18 Aug 2026 15:40:20 +0000	[thread overview]
Message-ID: <20260818154020.749521F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260817153957.3177627-1-poros@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Incomplete fix leaves skb->network_header and skb->transport_header uninitialized in generic XDP TX, causing out-of-bounds reads during checksum offload.
--

--- Patch [1]: [PATCH net] xsk: reset the mac header in the generic Tx path ---
commit 28a4ae00fcc18f8550bef3cea318942f60fe0720
Author: Petr Oros <poros@redhat.com>

xsk: reset the mac header in the generic Tx path

This commit fixes a bug where AF_XDP generic Tx leaves the MAC header
uninitialized, leading to out-of-bounds reads in drivers. It sets the
MAC header in xsk_skb_init_misc() to ensure the pointer stays in bounds.

> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 7855ee09c4b64..885427392cb6b 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -931,6 +931,7 @@ static int xsk_skb_init_misc(struct sk_buff *skb, struct xdp_sock *xs,
>  	skb->priority = READ_ONCE(xs->sk.sk_priority);
>  	skb->mark = READ_ONCE(xs->sk.sk_mark);
>  	skb->destructor = xsk_destruct_skb;
> +	skb_reset_mac_header(skb);

[Severity: High]
This is a pre-existing issue and was not introduced by the patch under review,
but does this incomplete fix leave skb->network_header and
skb->transport_header uninitialized?

If a userspace application uses an AF_XDP socket in generic TX mode with
the XDP_TXMD_FLAGS_CHECKSUM metadata flag set, xsk_skb_metadata() will set
skb->ip_summed = CHECKSUM_PARTIAL without initializing the network or
transport headers.

When the packet is passed to a NIC driver (like ice) that processes
CHECKSUM_PARTIAL, it reads skb_network_header() and skb_transport_header():

drivers/net/ethernet/intel/ice/ice_txrx.c:ice_tx_csum() {
    ...
		ip.hdr = skb_network_header(skb);
		l4.hdr = skb_transport_header(skb);
    ...
}

Because these headers are never initialized, network_header remains 0
(pointing to uninitialized SKB headroom) and transport_header remains ~0U
(65535 bytes past skb->head).

Could this lead to out-of-bounds reads when drivers dereference these
pointers, requiring us to safely anchor or parse the headers here as well
(for example, via skb_probe_transport_header() as was previously done for
AF_PACKET)?

>  	return 0;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260817153957.3177627-1-poros@redhat.com?part=1

      parent reply	other threads:[~2026-08-18 15:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17 15:39 [PATCH net] xsk: reset the mac header in the generic Tx path Petr Oros
2026-08-18 14:02 ` Jason Xing
2026-08-18 15:40 ` sashiko-bot [this message]

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=20260818154020.749521F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=poros@redhat.com \
    --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