From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: Frank.Li@kernel.org, dmaengine@vger.kernel.org, vkoul@kernel.org
Subject: Re: [PATCH v18 11/14] crypto: qce - Use existing devres APIs in devm_qce_dma_request()
Date: Fri, 22 May 2026 17:15:34 +0000 [thread overview]
Message-ID: <20260522171534.C05B51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260522-qcom-qce-cmd-descr-v18-11-99103926bafc@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The asynchronous workqueue `done_work` is canceled after the DMA resources (`txchan`, `rxchan`, `result_buf`) are released during driver unbind, leading to a Use-After-Free (UAF).
--
commit 9b35f36899d792c9a860c0ba48fbc33cb494e4e0
Author: Bartosz Golaszewski <brgl@kernel.org>
crypto: qce - Use existing devres APIs in devm_qce_dma_request()
This patch switches devm_qce_dma_request() to use devm_kmalloc() and
devm_dma_request_chan(). This removes the need for custom resource release
handling and shrinks the function.
> diff --git a/drivers/crypto/qce/dma.c b/drivers/crypto/qce/dma.c
> index c29b0abe94453..3db46fc0c419a 100644
> --- a/drivers/crypto/qce/dma.c
> +++ b/drivers/crypto/qce/dma.c
> @@ -12,47 +12,26 @@
[ ... ]
> int devm_qce_dma_request(struct qce_device *qce)
> {
> struct qce_dma_data *dma = &qce->dma;
> struct device *dev = qce->dev;
>
> - dma->txchan = dma_request_chan(dev, "tx");
> + dma->result_buf = devm_kmalloc(dev, QCE_RESULT_BUF_SZ + QCE_IGNORE_BUF_SZ, GFP_KERNEL);
> + if (!dma->result_buf)
> + return -ENOMEM;
> +
> + dma->txchan = devm_dma_request_chan(dev, "tx");
> if (IS_ERR(dma->txchan))
> return dev_err_probe(dev, PTR_ERR(dma->txchan),
> "Failed to get TX DMA channel\n");
>
> - dma->rxchan = dma_request_chan(dev, "rx");
> - if (IS_ERR(dma->rxchan)) {
[ ... ]
> + dma->rxchan = devm_dma_request_chan(dev, "rx");
> + if (IS_ERR(dma->rxchan))
> + return dev_err_probe(dev, PTR_ERR(dma->rxchan),
> + "Failed to get RX DMA channel\n");
>
> -error_nomem:
> - dma_release_channel(dma->rxchan);
> -error_rx:
> - dma_release_channel(dma->txchan);
> - return ret;
> + return 0;
> }
[Severity: High]
This is a pre-existing issue, but could this devm transition expose a
use-after-free during driver unbind?
In qce_crypto_probe(), a devres action is added to cancel the done_work task
before devm_qce_dma_request() is called. Because the devres framework executes
cleanup actions in reverse order of registration (LIFO), during unbind or probe
failure, devres will first free these managed DMA resources (result_buf,
txchan, and rxchan) before calling cancel_work_sync() for done_work.
If done_work is pending or executing when the device is unbound via sysfs,
qce_req_done_work() can call qce_handle_queue(), which dequeues backlog
requests and submits them using the already freed result_buf and released DMA
channels.
Would it be safer to register the devres action for qce_cancel_work after
the DMA resources are allocated to ensure safe cleanup ordering?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260522-qcom-qce-cmd-descr-v18-0-99103926bafc@oss.qualcomm.com?part=11
next prev parent reply other threads:[~2026-05-22 17:15 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 13:39 [PATCH v18 00/14] crypto/dmaengine: qce: introduce BAM locking and use DMA for register I/O Bartosz Golaszewski
2026-05-22 13:39 ` [PATCH v18 01/14] dmaengine: constify struct dma_descriptor_metadata_ops Bartosz Golaszewski
2026-05-22 13:39 ` [PATCH v18 02/14] dmaengine: qcom: bam_dma: free interrupt before the clock in error path Bartosz Golaszewski
2026-05-22 14:17 ` sashiko-bot
2026-05-22 13:39 ` [PATCH v18 03/14] dmaengine: qcom: bam_dma: convert tasklet to a BH workqueue Bartosz Golaszewski
2026-05-22 14:37 ` sashiko-bot
2026-05-22 13:39 ` [PATCH v18 04/14] dmaengine: qcom: bam_dma: Extend the driver's device match data Bartosz Golaszewski
2026-05-22 13:39 ` [PATCH v18 05/14] dmaengine: qcom: bam_dma: Add pipe_lock_supported flag support Bartosz Golaszewski
2026-05-22 13:39 ` [PATCH v18 06/14] dmaengine: qcom: bam_dma: add support for BAM locking Bartosz Golaszewski
2026-05-22 15:25 ` sashiko-bot
2026-05-22 13:40 ` [PATCH v18 07/14] crypto: qce - Cancel work on device detach Bartosz Golaszewski
2026-05-22 15:57 ` sashiko-bot
2026-05-22 13:40 ` [PATCH v18 08/14] crypto: qce - Include algapi.h in the core.h header Bartosz Golaszewski
2026-05-22 13:40 ` [PATCH v18 09/14] crypto: qce - Remove unused ignore_buf Bartosz Golaszewski
2026-05-22 16:44 ` sashiko-bot
2026-05-22 13:40 ` [PATCH v18 10/14] crypto: qce - Simplify arguments of devm_qce_dma_request() Bartosz Golaszewski
2026-05-22 13:40 ` [PATCH v18 11/14] crypto: qce - Use existing devres APIs in devm_qce_dma_request() Bartosz Golaszewski
2026-05-22 17:15 ` sashiko-bot [this message]
2026-05-22 13:40 ` [PATCH v18 12/14] crypto: qce - Map crypto memory for DMA Bartosz Golaszewski
2026-05-22 17:56 ` sashiko-bot
2026-05-22 13:40 ` [PATCH v18 13/14] crypto: qce - Add BAM DMA support for crypto register I/O Bartosz Golaszewski
2026-05-22 13:40 ` [PATCH v18 14/14] crypto: qce - Communicate the base physical address to the dmaengine Bartosz Golaszewski
2026-05-24 20:49 ` [PATCH v18 00/14] crypto/dmaengine: qce: introduce BAM locking and use DMA for register I/O Eric Biggers
2026-05-25 5:44 ` Manivannan Sadhasivam
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=20260522171534.C05B51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=dmaengine@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/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.