From: sashiko-bot@kernel.org
To: "Srinivas Neeli" <srinivas.neeli@amd.com>
Cc: devicetree@vger.kernel.org, linux-rt-devel@lists.linux.dev,
robh@kernel.org, conor+dt@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 7/8] net: xilinx: tsn: add the endpoint TX data path
Date: Sat, 17 Oct 2026 09:34:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-175445@kernel.org> (raw)
In-Reply-To: <20261016-patches_v2_external-v3-7-e33d3960ca1e@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: Use-after-free of skb in ep_start_xmit() due to late timestamping
--
commit 6fa02caf949cb04194e431c851b503c66e08312c
Author: Srinivas Neeli <srinivas.neeli@amd.com>
net: xilinx: tsn: add the endpoint TX data path
This commit adds the transmit path so the endpoint can send frames. It
selects the TX channel by indexing tx_chans[] with the frame's logical
queue, maps the frame, and submits it to the DMA engine.
> diff --git a/drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c b/drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c
> index 0a13e04d40575..bd8cd504cefb4 100644
> --- a/drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c
> +++ b/drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c
[ ... ]
> +static netdev_tx_t ep_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> +{
[ ... ]
> + spin_lock_bh(&xchan->tx_lock);
> + cookie = dmaengine_submit(dma_tx_desc);
> + if (dma_submit_error(cookie)) {
> + spin_unlock_bh(&xchan->tx_lock);
> + skbuf_dma->skb = NULL;
> + goto err_unmap_sg;
> + }
> + WRITE_ONCE(xchan->ring_head, xchan->ring_head + 1);
> + netdev_tx_sent_queue(txq, skb->len);
> + netif_txq_maybe_stop(txq,
> + CIRC_SPACE(xchan->ring_head,
> + READ_ONCE(xchan->ring_tail),
> + xchan->ring_size),
> + 2, 2);
> + spin_unlock_bh(&xchan->tx_lock);
> +
> + skb_tx_timestamp(skb);
[Severity: High]
Is there a use-after-free risk for the skb here?
If dmaengine_submit() successfully transfers ownership of the descriptor to
the DMA engine, and the lock is subsequently released via spin_unlock_bh(),
could the following sequence occur:
CPU1 calls dmaengine_submit() and unlocks xchan->tx_lock.
The hardware begins processing the descriptor and triggers the completion
callback on another CPU.
CPU2 executes ep_dma_tx_cb(), unmaps the buffer, and frees the skb using
dev_consume_skb_any(skb).
CPU1 resumes execution and calls skb_tx_timestamp(skb), which attempts to
access the shinfo area of the already-freed skb.
Should skb_tx_timestamp() be called before the transmit lock is dropped,
or prior to handing the skb over to dmaengine_submit()?
> + dma_async_issue_pending(xchan->chan);
> +
> + return NETDEV_TX_OK;
> +
> +err_unmap_sg:
> + dma_unmap_sg(xchan->dma_dev, skbuf_dma->sgl, sg_len, DMA_TO_DEVICE);
> +err_drop_skb:
> dev_kfree_skb_any(skb);
> DEV_STATS_INC(ndev, tx_dropped);
> return NETDEV_TX_OK;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261016-patches_v2_external-v3-0-e33d3960ca1e@amd.com?part=7
next prev parent reply other threads:[~2026-10-17 9:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 9:31 [PATCH net-next v3 0/8] Add Xilinx TSN Endpoint Ethernet MAC driver Srinivas Neeli
2026-10-16 9:32 ` [PATCH net-next v3 1/8] dt-bindings: net: add Xilinx TSN Endpoint Ethernet MAC Srinivas Neeli
2026-10-16 9:32 ` [PATCH net-next v3 2/8] net: xilinx: tsn: add TSN endpoint wrapper driver Srinivas Neeli
2026-10-16 9:32 ` [PATCH net-next v3 3/8] net: xilinx: tsn: add endpoint MAC driver skeleton Srinivas Neeli
2026-10-16 9:32 ` [PATCH net-next v3 4/8] net: xilinx: tsn: parse endpoint DMA channel configuration Srinivas Neeli
2026-10-16 9:32 ` [PATCH net-next v3 5/8] net: xilinx: tsn: bring up the endpoint MCDMA channels Srinivas Neeli
2026-10-16 9:32 ` [PATCH net-next v3 6/8] net: xilinx: tsn: add the endpoint RX data path Srinivas Neeli
2026-10-17 9:34 ` sashiko-bot
2026-10-16 9:32 ` [PATCH net-next v3 7/8] net: xilinx: tsn: add the endpoint TX " Srinivas Neeli
2026-10-17 9:34 ` sashiko-bot [this message]
2026-10-16 9:32 ` [PATCH net-next v3 8/8] net: xilinx: tsn: deliver endpoint RX frames to DSA user ports Srinivas Neeli
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-175445@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=srinivas.neeli@amd.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
all inboxes | Powered by JetHome®