From: Stanislav Fomichev <sdf.kernel@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net 2/6] xsk: pass TX metadata pointer by reference
Date: Wed, 29 Jul 2026 08:59:48 -0700 [thread overview]
Message-ID: <amojZw5ZTajq6Kqb@devvm7509.cco0.facebook.com> (raw)
In-Reply-To: <20260728162042.27EE01F000E9@smtp.kernel.org>
On 07/28, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>
> Pre-existing issues:
> - [Critical] `xsk_tx_metadata_to_compl()` returns early when `meta == NULL` without clearing the `compl` output structure, leading to arbitrary kernel memory writes during TX completion.
> --
>
> --- Patch [2]: [PATCH net 2/6] xsk: pass TX metadata pointer by reference ---
> commit 83fcec7a0c0075ec991849b8d99f6d6cd083c335
> Author: Stanislav Fomichev <sdf.kernel@gmail.com>
>
> xsk: pass TX metadata pointer by reference
>
> Completion handling needs to know whether a timestamp was requested when
> the metadata was processed. Let xsk_tx_metadata_request() update the
> caller's metadata pointer so that decision can be carried forward without
> rereading user-controlled flags.
>
> [ ... ]
>
> > diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h
> > index 8b51876efbed1..06c081feff42d 100644
> > --- a/include/net/xdp_sock.h
> > +++ b/include/net/xdp_sock.h
> > @@ -153,17 +153,19 @@ static inline void xsk_tx_metadata_to_compl(struct xsk_tx_metadata *meta,
>
> [Severity: Critical]
> This isn't a bug introduced by this patch, but I noticed that
> xsk_tx_metadata_to_compl() returns early without explicitly clearing the
> compl structure when meta is NULL:
>
> static inline void xsk_tx_metadata_to_compl(struct xsk_tx_metadata *meta,
> struct xsk_tx_metadata_compl *compl)
> {
> if (!meta)
> return;
>
> In drivers like mlx5e_xsk_tx(), compl is declared on the stack and passed in
> uninitialized:
>
> mlx5e_xsk_tx() {
> if (xp_tx_metadata_enabled(sq->xsk_pool)) {
> struct xsk_tx_metadata_compl compl;
>
> xsk_tx_metadata_to_compl(meta, &compl);
> ...
> mlx5e_xdpi_fifo_push(..., { .xsk_meta = compl });
> }
> }
>
> If an untrusted user sends a packet with invalid flags, causing meta to be
> NULL, could the uninitialized stack garbage in compl be pushed to the NAPI TX
> completion FIFO? Would this cause the completion path to dereference a garbage
> pointer and write a hardware timestamp to arbitrary kernel memory?
>
> Similarly, in stmmac_xdp_xmit_zc():
>
> stmmac_xdp_xmit_zc() {
> ...
> xsk_tx_metadata_to_compl(meta,
> &tx_q->tx_skbuff_dma[entry].xsk_meta);
> }
>
> Could this early return leave a stale pointer from a previous packet in the
> descriptor ring, leading to an accidental overwrite of userspace UMEM?
I think this is now addressed by:
- [PATCH net 3/6] xsk: clear metadata pointer when no timestamp is requested
next prev parent reply other threads:[~2026-07-29 16:08 UTC|newest]
Thread overview: 19+ 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-29 15:54 ` Stanislav Fomichev
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-29 15:59 ` Stanislav Fomichev [this message]
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
2026-07-29 16:03 ` Stanislav Fomichev
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-29 16:06 ` Stanislav Fomichev
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 15:58 ` Stanislav Fomichev
2026-07-29 9:39 ` [PATCH net 0/6] xsk: harden TX metadata validation against races Maciej Fijalkowski
2026-07-29 16:08 ` Stanislav Fomichev
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=amojZw5ZTajq6Kqb@devvm7509.cco0.facebook.com \
--to=sdf.kernel@gmail.com \
--cc=bpf@vger.kernel.org \
--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