From: sashiko-bot@kernel.org
To: "Wenjia Zhang" <wenjia.zhang@oss.qualcomm.com>,
"Bartosz Golaszewski" <brgl@kernel.org>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org, "Wenjia Zhang" <wenjz@qti.qualcomm.com>
Subject: Re: [PATCH 3/4] crypto: qce - Bound ahash input DMA to the current segment
Date: Tue, 01 Dec 2026 03:02:29 +0000 [thread overview]
Message-ID: <sashiko-outbox-242399@kernel.org> (raw)
In-Reply-To: <20261201-codex-qce-dma-bounds-upstream-20261201-v1-3-c15d01b45bce@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] crypto: qce: missing CRYPTO_ALG_ALLOCATES_MEMORY in
qce_ahash_register_one()
- [Low] crypto: qce: missing Fixes trailer for ahash input DMA bounding
fix
--
commit 1b196f099887dc46df99e46259af8be85b93abbd
Author: Wenjia Zhang <wenjz@qti.qualcomm.com>
> crypto: qce - Bound ahash input DMA to the current segment
>
> Hash updates submit complete blocks and retain any remaining bytes for a
> later submission. Reducing req->nbytes to the current segment does not
> shorten the source scatterlist. sg_nents_for_len() only counts entries,
> so mapping the last entry in full can send the retained bytes to BAM as
> well. The DMA input then exceeds the programmed hash segment and the
> request can fail.
>
> Build a source table bounded to req->nbytes for each hardware submission
> and validate its total mapped length. Pass the mapped entry count to DMA
> descriptor preparation, while retaining the original entry count for
> unmapping.
>
> Free the table on completion and submission failure, and restore the
> caller's original source list and byte count if submission fails.
>
> Signed-off-by: Wenjia Zhang <wenjz@qti.qualcomm.com>
[Severity: Low]
Since this fixes a bug present since the driver was added, should it
include a Fixes tag?
Fixes: ec8f5d8f6f76 ("crypto: qce - Qualcomm crypto engine driver")
> diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c
> index 3dca00e53e473..1f7ed0e15afdf 100644
> --- a/drivers/crypto/qce/sha.c
> +++ b/drivers/crypto/qce/sha.c
> @@ -31,6 +31,47 @@ static const u32 std_iv_sha256[SHA256_DIGEST_SIZE / sizeof(u32)] = {
> SHA256_H4, SHA256_H5, SHA256_H6, SHA256_H7
> };
>
> +static int qce_ahash_prepare_src(struct ahash_request *req)
> +{
> + struct qce_sha_reqctx *rctx = ahash_request_ctx_dma(req);
> + struct scatterlist *sg;
> + gfp_t gfp;
> + int ret;
> +
> + rctx->src_nents = sg_nents_for_len(req->src, req->nbytes);
> + if (rctx->src_nents <= 0)
> + return rctx->src_nents ?: -EINVAL;
> +
> + gfp = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
> + GFP_KERNEL : GFP_ATOMIC;
> + ret = sg_alloc_table(&rctx->src_tbl, rctx->src_nents, gfp);
[Severity: Medium]
Should qce_ahash_register_one() now set CRYPTO_ALG_ALLOCATES_MEMORY in
base->cra_flags (like qce_skcipher_register_one() and
qce_aead_register_one() do)?
qce_ahash_prepare_src() now calls sg_alloc_table() during request
processing, while qce_ahash_register_one() still sets only
CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY. Block I/O callers such as
dm-integrity that mask out CRYPTO_ALG_ALLOCATES_MEMORY when calling
crypto_alloc_ahash() can bind to QCE ahash algorithms and trigger
GFP_KERNEL allocations from a GFP_NOIO block I/O context when
CRYPTO_TFM_REQ_MAY_SLEEP is set, risking memory reclaim recursion
deadlocks.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-codex-qce-dma-bounds-upstream-20261201-v1-0-c15d01b45bce@oss.qualcomm.com?part=3
next prev parent reply other threads:[~2026-12-01 3:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 2:54 [PATCH 0/4] QCE data DMA transfer length fixes Wenjia Zhang
2026-12-01 2:54 ` [PATCH 1/4] crypto: qce - Bound AEAD input DMA to the programmed segment Wenjia Zhang
2026-12-01 3:06 ` sashiko-bot
2026-12-01 5:06 ` Kuldeep Singh
2026-12-01 2:54 ` [PATCH 2/4] crypto: qce - Size CCM decrypt output DMA for the tag length Wenjia Zhang
2026-12-01 3:13 ` sashiko-bot
2026-12-01 2:54 ` [PATCH 3/4] crypto: qce - Bound ahash input DMA to the current segment Wenjia Zhang
2026-12-01 3:02 ` sashiko-bot [this message]
2026-12-01 2:54 ` [PATCH 4/4] crypto: qce - Bound skcipher input DMA to cryptlen Wenjia Zhang
2026-12-01 3:01 ` sashiko-bot
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-242399@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=brgl@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wenjia.zhang@oss.qualcomm.com \
--cc=wenjz@qti.qualcomm.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.