From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: vkoul@kernel.org, Frank.Li@kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH v19 09/14] crypto: qce - Remove unused ignore_buf
Date: Tue, 26 May 2026 15:57:38 +0000 [thread overview]
Message-ID: <20260526155738.D9F431F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260526-qcom-qce-cmd-descr-v19-9-08472fdcbf4a@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [Critical] The asynchronous workqueue accesses freed DMA channels, freed memory, and a destroyed mutex during device teardown due to incorrect devres registration order.
- [High] The driver leaks uninitialized kernel heap memory or previous cryptographic results to user space when a hardware error occurs.
- [High] Sensitive 3DES key material is copied to a stack buffer but is not explicitly zeroized before the function returns.
--
commit d001aa784f83034e2199faf1b8d96703d4ecbbb7
Author: Bartosz Golaszewski <brgl@kernel.org>
crypto: qce - Remove unused ignore_buf
This commit removes the unused ignore_buf pointer from the qce_dma_data
struct and moves the QCE_IGNORE_BUF_SZ definition directly into dma.c
since it is not used outside of this compilation unit.
> 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;
> -
[Severity: High]
This is a pre-existing issue, but does the allocation of result_buf risk
leaking uninitialized kernel heap memory or stale cryptographic results to
user space?
In devm_qce_dma_request(), result_buf is allocated with kmalloc() without
the __GFP_ZERO flag. During asynchronous request completion in
qce_ahash_done() and qce_aead_done(), the driver appears to unconditionally
copy the digest, authentication tag, or IV from these buffers to the caller's
output buffers (e.g., req->result) which often map directly to user space.
If a hardware error occurs and the BAM DMA fails to write to the result
buffer, wouldn't this copy operation expose uninitialized heap memory or
previous request data before qce_check_status() can handle the error?
[Severity: Critical]
This is a pre-existing issue, but I noticed a potential use-after-free
during device teardown related to the devres registration order here.
If qce_crypto_probe() registers the devres action to cancel the
asynchronous workqueue (qce_cancel_work) first, and then calls
devm_qce_dma_request() and devm_mutex_init(), won't the teardown happen
in reverse order?
During device detach, the LIFO devres execution would destroy the mutex
and free the DMA channels and buffers before actually canceling the
workqueue. If a DMA callback schedules qce->done_work just before DMA
termination, could qce_req_done_work() execute concurrently during
teardown, attempting to acquire the destroyed qce->lock and using the
freed DMA resources?
> return devm_add_action_or_reset(dev, qce_dma_release, dma);
>
> error_nomem:
[ ... ]
> diff --git a/drivers/crypto/qce/dma.h b/drivers/crypto/qce/dma.h
> index 31629185000e1..fc337c435cd14 100644
> --- a/drivers/crypto/qce/dma.h
> +++ b/drivers/crypto/qce/dma.h
[ ... ]
> @@ -31,7 +30,6 @@ struct qce_dma_data {
> struct dma_chan *txchan;
> struct dma_chan *rxchan;
> struct qce_result_dump *result_buf;
> - void *ignore_buf;
> };
>
> int devm_qce_dma_request(struct device *dev, struct qce_dma_data *dma);
[Severity: High]
This isn't a bug introduced by this patch, but while reviewing the
cryptographic operations I noticed an issue in qce_aead_setkey() and
qce_des3_setkey().
Sensitive 3DES key material is copied into a local stack array
u32 _key[6] to check for weak keys. However, the _key array doesn't
seem to be explicitly zeroized using memzero_explicit() before the
function returns.
Does this leave sensitive cryptographic key material on the kernel
stack, potentially allowing it to be leaked through subsequent
uninitialized stack reads?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260526-qcom-qce-cmd-descr-v19-0-08472fdcbf4a@oss.qualcomm.com?part=9
next prev parent reply other threads:[~2026-05-26 15:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 13:10 [PATCH v19 00/14] crypto/dmaengine: qce: introduce BAM locking and use DMA for register I/O Bartosz Golaszewski
2026-05-26 13:10 ` [PATCH v19 01/14] dmaengine: constify struct dma_descriptor_metadata_ops Bartosz Golaszewski
2026-05-26 13:10 ` [PATCH v19 02/14] dmaengine: qcom: bam_dma: free interrupt before the clock in error path Bartosz Golaszewski
2026-05-26 13:45 ` sashiko-bot
2026-05-26 13:10 ` [PATCH v19 03/14] dmaengine: qcom: bam_dma: convert tasklet to a BH workqueue Bartosz Golaszewski
2026-05-26 14:17 ` sashiko-bot
2026-05-26 13:10 ` [PATCH v19 04/14] dmaengine: qcom: bam_dma: Extend the driver's device match data Bartosz Golaszewski
2026-05-26 13:10 ` [PATCH v19 05/14] dmaengine: qcom: bam_dma: Add pipe_lock_supported flag support Bartosz Golaszewski
2026-05-26 13:10 ` [PATCH v19 06/14] dmaengine: qcom: bam_dma: add support for BAM locking Bartosz Golaszewski
2026-05-26 15:01 ` sashiko-bot
2026-05-26 13:10 ` [PATCH v19 07/14] crypto: qce - Cancel work on device detach Bartosz Golaszewski
2026-05-26 15:33 ` sashiko-bot
2026-05-26 13:10 ` [PATCH v19 08/14] crypto: qce - Include algapi.h in the core.h header Bartosz Golaszewski
2026-05-26 13:10 ` [PATCH v19 09/14] crypto: qce - Remove unused ignore_buf Bartosz Golaszewski
2026-05-26 15:57 ` sashiko-bot [this message]
2026-05-26 13:10 ` [PATCH v19 10/14] crypto: qce - Simplify arguments of devm_qce_dma_request() Bartosz Golaszewski
2026-05-26 13:10 ` [PATCH v19 11/14] crypto: qce - Use existing devres APIs in devm_qce_dma_request() Bartosz Golaszewski
2026-05-26 16:09 ` sashiko-bot
2026-05-26 13:11 ` [PATCH v19 12/14] crypto: qce - Map crypto memory for DMA Bartosz Golaszewski
2026-05-26 16:30 ` sashiko-bot
2026-05-26 13:11 ` [PATCH v19 13/14] crypto: qce - Add BAM DMA support for crypto register I/O Bartosz Golaszewski
2026-05-26 17:13 ` sashiko-bot
2026-05-26 13:11 ` [PATCH v19 14/14] crypto: qce - Communicate the base physical address to the dmaengine Bartosz Golaszewski
2026-05-26 18:20 ` sashiko-bot
2026-05-29 16:22 ` [PATCH v19 00/14] crypto/dmaengine: qce: introduce BAM locking and use DMA for register I/O Eric Biggers
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=20260526155738.D9F431F000E9@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