BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Stanislav Fomichev" <sdf.kernel@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net 3/6] xsk: clear metadata pointer when no timestamp is requested
Date: Tue, 28 Jul 2026 16:20:40 +0000	[thread overview]
Message-ID: <20260728162040.7805A1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260727161959.885642-4-sdf@fomichev.me>

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

Pre-existing issues:
- [High] Integer overflow in `xsk_skb_metadata` when calculating `skb->csum_start`, leading to a potential kernel warning and panic (DoS).
--

--- Patch [3]: [PATCH net 3/6] xsk: clear metadata pointer when no timestamp is requested ---
commit 814027e56069dbb5716ac5b9f7f38aebab332dd6
Author: Stanislav Fomichev <sdf.kernel@gmail.com>

xsk: clear metadata pointer when no timestamp is requested

User space can change metadata flags after request processing. Rereading
them during completion can therefore make the kernel write a timestamp
that was not requested when the packet was submitted. Clear the metadata
pointer during request processing unless timestamp completion is requested.

> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c

[ ... ]

> @@ -998,6 +998,8 @@ static int xsk_skb_metadata(struct sk_buff *skb, void *buffer,
>  
>  	if (meta->flags & XDP_TXMD_FLAGS_LAUNCH_TIME)
>  		skb->skb_mstamp_ns = meta->request.launch_time;

[Severity: High]
This is a pre-existing issue, but can the checksum offset calculation
earlier in this function cause an integer overflow?

When handling XDP_TXMD_FLAGS_CHECKSUM, the code does:

    skb->csum_start = hr + csum_start;

On architectures with 64KB pages, csum_start can be large enough that
adding hr wraps the u16 skb->csum_start. This would result in
skb->csum_start being smaller than the headroom.

If pool->tx_sw_csum is true, this then calls skb_checksum_help(). Inside
skb_checksum_help(), the offset is calculated by subtracting headroom from
skb->csum_start, which yields a negative integer due to the wrap-around.

When this negative offset is compared against skb_headlen() (which is
unsigned), it is implicitly cast to a huge unsigned value:

net/core/dev.c:skb_checksum_help() {
    ...
    offset = skb_checksum_start_offset(skb);
    ...
    if (unlikely(offset >= skb_headlen(skb))) {
        DO_ONCE_LITE(skb_dump, KERN_ERR, skb, false);
        WARN_ONCE(true, "offset (%d) >= skb_headlen() (%u)\n", ...);
    ...
}

Could this allow an unprivileged user to trigger a kernel warning and
potentially panic the system if panic_on_warn is set?

> +	if (!(meta->flags & XDP_TXMD_FLAGS_TIMESTAMP))
> +		meta = NULL;
>  	xsk_tx_metadata_to_compl(meta, &skb_shinfo(skb)->xsk_meta);
>  
>  	return 0;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260727161959.885642-1-sdf@fomichev.me?part=3

  reply	other threads:[~2026-07-28 16:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 16:19 [PATCH net 0/6] xsk: harden TX metadata validation against races Stanislav Fomichev
2026-07-27 16:19 ` [PATCH net 1/6] xsk: require at least 16 bytes of TX metadata Stanislav Fomichev
2026-07-28 16:20   ` sashiko-bot
2026-07-27 16:19 ` [PATCH net 2/6] xsk: pass TX metadata pointer by reference Stanislav Fomichev
2026-07-28 16:20   ` sashiko-bot
2026-07-27 16:19 ` [PATCH net 3/6] xsk: clear metadata pointer when no timestamp is requested Stanislav Fomichev
2026-07-28 16:20   ` sashiko-bot [this message]
2026-07-27 16:19 ` [PATCH net 4/6] xsk: validate launch-time metadata size Stanislav Fomichev
2026-07-28 16:20   ` sashiko-bot
2026-07-27 16:19 ` [PATCH net 5/6] xsk: move xsk_tx_metadata_request() to xdp_sock_drv.h Stanislav Fomichev
2026-07-27 16:19 ` [PATCH net 6/6] xsk: validate metadata when processing requests Stanislav Fomichev
2026-07-28 16:20   ` sashiko-bot
2026-07-29  9:39 ` [PATCH net 0/6] xsk: harden TX metadata validation against races Maciej Fijalkowski

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=20260728162040.7805A1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sdf.kernel@gmail.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