DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: Frank.Li@kernel.org, vkoul@kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH v22 09/14] crypto: qce - Remove unused ignore_buf
Date: Fri, 17 Jul 2026 08:54:35 +0000	[thread overview]
Message-ID: <20260717085436.2B41C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260717-qcom-qce-cmd-descr-v22-9-ff0d18b27246@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Background workqueue is cancelled after DMA channels and memory are freed, leading to a UAF if the work executes concurrently during device teardown.
- [High] Self-deadlock in `qce_handle_queue` when completing a backlog request.
--

--- Patch [9]: [PATCH v22 09/14] crypto: qce - Remove unused ignore_buf ---
commit 2247b3c61623eab5bba053110822c8e653d692e5
Author: Bartosz Golaszewski <brgl@kernel.org>

crypto: qce - Remove unused ignore_buf

This commit removes the unused ignore_buf field from the qce_dma_data struct.
It also moves the QCE_IGNORE_BUF_SZ definition to dma.c since it is only
used locally.

> diff --git a/drivers/crypto/qce/dma.c b/drivers/crypto/qce/dma.c
> index 7ec9d72fd690f..d1daa229361aa 100644
> --- a/drivers/crypto/qce/dma.c
> +++ b/drivers/crypto/qce/dma.c
[ ... ]
> @@ -43,8 +45,6 @@ int devm_qce_dma_request(struct device *dev, struct qce_dma_data *dma)
>  		goto error_nomem;
>  	}
>  
> -	dma->ignore_buf = dma->result_buf + QCE_RESULT_BUF_SZ;
> -
>  	return devm_add_action_or_reset(dev, qce_dma_release, dma);

[Severity: High]
This is a pre-existing issue, but does device teardown have a race condition
leading to a use-after-free here?

During device unbind, devres executes cleanup actions in reverse order.
In drivers/crypto/qce/core.c:qce_crypto_probe(), the devm action to cancel
the work queue is registered before devm_qce_dma_request() is called:

    ret = devm_add_action_or_reset(dev, qce_cancel_work, &qce->done_work);

This means qce_cancel_work() will run after qce_dma_release().

If a dma transfer just completed and scheduled qce->done_work,
qce_dma_release() will terminate pending dma transfers and free dma->result_buf
before the worker thread is actually canceled.

Could the worker thread then execute qce_req_done_work() and attempt to submit
a new dma transfer using the freed dma->result_buf and dma channels?


[Severity: High]
This is another pre-existing issue, but is there a risk of a self-deadlock in
qce_handle_queue() when completing a backlog request?

In drivers/crypto/qce/core.c:qce_handle_queue():

    if (backlog) {
        scoped_guard(mutex, &qce->lock)
            crypto_request_complete(backlog, -EINPROGRESS);
    }

The crypto_request_complete() callback is invoked while holding qce->lock.

If the submitter's completion callback immediately submits another request
(which is standard behavior for dm-crypt or ipsec when waiting for queue
space), it calls qce_async_request_enqueue().

This would re-enter qce_handle_queue() and attempt to acquire the same
non-recursive qce->lock again.

Can this cause a kernel thread self-deadlock when the queue is full?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260717-qcom-qce-cmd-descr-v22-0-ff0d18b27246@oss.qualcomm.com?part=9

  reply	other threads:[~2026-07-17  8:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17  8:36 [PATCH v22 00/14] crypto/dmaengine: qce: introduce BAM locking and use DMA for register I/O Bartosz Golaszewski
2026-07-17  8:36 ` [PATCH v22 01/14] dmaengine: constify struct dma_descriptor_metadata_ops Bartosz Golaszewski
2026-07-17  8:36 ` [PATCH v22 02/14] dmaengine: qcom: bam_dma: free interrupt before the clock in error path Bartosz Golaszewski
2026-07-17  8:50   ` sashiko-bot
2026-07-17  8:36 ` [PATCH v22 03/14] dmaengine: qcom: bam_dma: convert tasklet to a BH workqueue Bartosz Golaszewski
2026-07-17  8:53   ` sashiko-bot
2026-07-17  8:36 ` [PATCH v22 04/14] dmaengine: qcom: bam_dma: Extend the driver's device match data Bartosz Golaszewski
2026-07-17  8:36 ` [PATCH v22 05/14] dmaengine: qcom: bam_dma: Add pipe_lock_supported flag support Bartosz Golaszewski
2026-07-17  8:36 ` [PATCH v22 06/14] dmaengine: qcom: bam_dma: add support for BAM locking Bartosz Golaszewski
2026-07-17  8:51   ` sashiko-bot
2026-07-17  8:36 ` [PATCH v22 07/14] crypto: qce - Cancel work on device detach Bartosz Golaszewski
2026-07-17  8:56   ` sashiko-bot
2026-07-17  8:36 ` [PATCH v22 08/14] crypto: qce - Include algapi.h in the core.h header Bartosz Golaszewski
2026-07-17  8:36 ` [PATCH v22 09/14] crypto: qce - Remove unused ignore_buf Bartosz Golaszewski
2026-07-17  8:54   ` sashiko-bot [this message]
2026-07-17  8:36 ` [PATCH v22 10/14] crypto: qce - Simplify arguments of devm_qce_dma_request() Bartosz Golaszewski
2026-07-17  8:36 ` [PATCH v22 11/14] crypto: qce - Use existing devres APIs in devm_qce_dma_request() Bartosz Golaszewski
2026-07-17  9:05   ` sashiko-bot
2026-07-17  8:36 ` [PATCH v22 12/14] crypto: qce - Map crypto memory for DMA Bartosz Golaszewski
2026-07-17  9:02   ` sashiko-bot
2026-07-17  8:36 ` [PATCH v22 13/14] crypto: qce - Add BAM DMA support for crypto register I/O Bartosz Golaszewski
2026-07-17  9:08   ` sashiko-bot
2026-07-17  8:36 ` [PATCH v22 14/14] crypto: qce - Communicate the base physical address to the dmaengine Bartosz Golaszewski

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=20260717085436.2B41C1F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox