From: sashiko-bot@kernel.org
To: "Wolfram Sang" <wsa+renesas@sang-engineering.com>
Cc: Frank.Li@kernel.org, dmaengine@vger.kernel.org, vkoul@kernel.org
Subject: Re: [PATCH 1/8] dmaengine: ptdma: unmap descriptor before completing cookie
Date: Sat, 10 Oct 2026 12:57:19 +0000 [thread overview]
Message-ID: <sashiko-outbox-166555@kernel.org> (raw)
In-Reply-To: <20261010124348.19055-2-wsa+renesas@sang-engineering.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] dmaengine: ptdma: UAF in ae4_pending_work due to unremoved list entries
--
commit 45d9a162336ad9b005d6d181ab13de82d05d7cf3
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
dmaengine: ptdma: unmap descriptor before completing cookie
To ensure that buffers are flushed, make sure that the descriptor gets
unmapped before completing the cookie.
Link: https://lore.kernel.org/r/20261009093745.539924-1-vkoul@kernel.org
> diff --git a/drivers/dma/amd/ptdma/ptdma-dmaengine.c b/drivers/dma/amd/ptdma/ptdma-dmaengine.c
> index 628c49ce5de9d..7f51d1e6c727f 100644
> --- a/drivers/dma/amd/ptdma/ptdma-dmaengine.c
> +++ b/drivers/dma/amd/ptdma/ptdma-dmaengine.c
[ ... ]
> @@ -362,8 +362,8 @@ static void pt_cmd_callback_work(void *data, int err)
> if (desc->status != DMA_ERROR)
> desc->status = DMA_COMPLETE;
>
> - dma_cookie_complete(tx_desc);
> dma_descriptor_unmap(tx_desc);
> + dma_cookie_complete(tx_desc);
[Severity: High]
Can this result in a use-after-free when pt_terminate_all() is called?
pt_terminate_all() extracts all descriptors from the virt-dma channel and
frees them via vchan_dma_desc_free_list():
drivers/dma/amd/ptdma/ptdma-dmaengine.c:pt_terminate_all() {
...
vchan_dma_desc_free_list(&chan->vc, &head);
...
}
However, for AE4 DMA devices, descriptors are additionally added to the
ae4cmd_q->cmd list during pt_create_desc(). pt_terminate_all() fails to
remove the freed descriptors from this hardware pending command list, and
does not acquire ae4cmd_q->cmd_lock.
The asynchronous worker thread ae4_pending_work() then iterates over the
uncleaned list, removes the freed descriptor, and executes its callback:
drivers/dma/amd/ae4dma/ae4dma-dev.c:ae4_pending_work() {
...
cmd = list_first_entry(&ae4cmd_q->cmd, struct pt_cmd, entry);
list_del(&cmd->entry);
ae4_check_status_error(ae4cmd_q, ae4cmd_q->dridx);
cmd->pt_cmd_callback(cmd->data, cmd->ret);
...
}
Since pt_cmd_callback_work() is the callback invoked here, will this execution
dereference the freed descriptor pointers and cause list memory corruption?
> } else {
> tx_desc = NULL;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261010124348.19055-1-wsa+renesas@sang-engineering.com?part=1
next prev parent reply other threads:[~2026-10-10 12:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 12:43 [PATCH 0/8] dmaengine: unmap descriptor before completing cookie Wolfram Sang
2026-10-10 12:43 ` [PATCH 1/8] dmaengine: ptdma: " Wolfram Sang
2026-10-10 12:57 ` sashiko-bot [this message]
2026-10-12 14:51 ` Frank Li
2026-10-10 12:43 ` [PATCH 2/8] dmaengine: fsl_raid: " Wolfram Sang
2026-10-10 12:43 ` [PATCH 3/8] dmaengine: idxd: " Wolfram Sang
2026-10-13 22:54 ` Vinicius Costa Gomes
2026-10-10 12:43 ` [PATCH 4/8] dmaengine: ioat: " Wolfram Sang
2026-10-10 12:43 ` [PATCH 5/8] dmaengine: mv_xor_v2: " Wolfram Sang
2026-10-10 12:54 ` sashiko-bot
2026-10-10 12:43 ` [PATCH 6/8] dmaengine: plx_dma: " Wolfram Sang
2026-10-10 12:56 ` sashiko-bot
2026-10-13 20:06 ` Logan Gunthorpe
2026-10-10 12:43 ` [PATCH 7/8] dmaengine: switchtec-dma: " Wolfram Sang
2026-10-10 12:54 ` sashiko-bot
2026-10-13 20:06 ` Logan Gunthorpe
2026-10-10 12:43 ` [PATCH 8/8] dmaengine: xgene-dma: " Wolfram Sang
2026-10-12 10:42 ` [PATCH 0/8] dmaengine: " Wolfram Sang
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-166555@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
--cc=wsa+renesas@sang-engineering.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 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.