From: sashiko-bot@kernel.org
To: "Keisuke Tsukuda" <tkdkei@outlook.jp>
Cc: "imx@lists.linux.dev" <imx@lists.linux.dev>, Frank.Li@kernel.org
Subject: Re: [PATCH net] net: fec: fix TSO DMA mapping failure handling
Date: Sat, 28 Nov 2026 03:39:26 +0000 [thread overview]
Message-ID: <sashiko-outbox-238437@kernel.org> (raw)
In-Reply-To: <20261127033906.9561-1-tkdkei@outlook.jp>
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:
- [Critical] net: fec: use-after-free in fec_enet_txq_submit_frag_skb()
[1]
--
commit 456fe9a775ff2f95a222a719c8b31ab3edda1c33
Author: Keisuke Tsukuda <tkdkei@outlook.jp>
net: fec: fix TSO DMA mapping failure handling
This commit fixes TSO DMA mapping error handling by returning -ENOMEM from
the descriptor helpers, keeping the first descriptor unready until all
mappings succeed, and preserving BD_ENET_TX_WRAP during descriptor cleanup.
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index f7636f23d1ebb..a2c760218e839 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
[ ... ]
> @@ -922,7 +927,7 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq,
> DMA_TO_DEVICE);
>
> /* Clear standard buffer descriptor fields */
> - tmp_bdp->cbd_sc = 0;
> + tmp_bdp->cbd_sc &= cpu_to_fec16(BD_ENET_TX_WRAP);
> tmp_bdp->cbd_datlen = 0;
> tmp_bdp->cbd_bufaddr = 0;
>
[Severity: Critical]
This problem wasn't introduced by this patch, but does
fec_enet_txq_submit_frag_skb() leave BD_ENET_TX_READY set on unmapped
fragment descriptors on DMA mapping failure [1]?
drivers/net/ethernet/freescale/fec_main.c:fec_enet_txq_submit_frag_skb() {
...
bdp->cbd_sc = cpu_to_fec16(status);
}
return bdp;
dma_mapping_error:
bdp = txq->bd.cur;
for (i = 0; i < frag; i++) {
bdp = fec_enet_get_nextdesc(bdp, &txq->bd);
dma_unmap_single(&fep->pdev->dev, fec32_to_cpu(bdp->cbd_bufaddr),
fec16_to_cpu(bdp->cbd_datlen), DMA_TO_DEVICE);
}
return ERR_PTR(-ENOMEM);
}
Each mapped fragment writes status with BD_ENET_TX_READY to bdp->cbd_sc,
and dma_mapping_error unmaps earlier fragments without clearing
BD_ENET_TX_READY or advancing txq->bd.cur. If the next transmitted packet
uses fewer descriptors than the aborted one, the trailing stale descriptors
remain marked ready and the MAC can DMA-read from the unmapped addresses.
[1] https://sashiko.dev/#/bug/linux-ad99904c-d478-49a5-bb3b-e4124919a833
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127033906.9561-1-tkdkei@outlook.jp?part=1
prev parent reply other threads:[~2026-11-28 3:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 3:39 [PATCH net] net: fec: fix TSO DMA mapping failure handling Keisuke Tsukuda
2026-11-27 6:29 ` Wei Fang
2026-11-28 3:39 ` 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=sashiko-outbox-238437@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tkdkei@outlook.jp \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.