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 4/4] crypto: qce - Bound skcipher input DMA to cryptlen
Date: Tue, 01 Dec 2026 03:01:43 +0000 [thread overview]
Message-ID: <sashiko-outbox-242397@kernel.org> (raw)
In-Reply-To: <20261201-codex-qce-dma-bounds-upstream-20261201-v1-4-c15d01b45bce@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] crypto: qce: missing Fixes trailer for unbounded req->src DMA
mapping
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Critical] crypto: qce: error code inversion in
qce_skcipher_async_req_handle() [1]
--
commit a975096f0c2cdacb9670c485b8f959458f058af4
Author: Wenjia Zhang <wenjz@qti.qualcomm.com>
> crypto: qce - Bound skcipher input DMA to cryptlen
>
> When a skcipher request uses different source and destination lists, the
> driver maps the source entries returned by sg_nents_for_len(). That
> helper does not shorten the last entry to cryptlen. A request whose
> final entry extends beyond the payload therefore sends excess data to
> BAM and can fail because the input exceeds the programmed segment. This
> also affects in-place requests using two lists for the same pages.
>
> Build a separate source table bounded to cryptlen for this path,
> referencing the existing pages without copying the payload. Validate the
> total mapped input length before starting the engine, including the path
> that shares the destination mapping.
>
> Unmap the owned source table and free it on completion and every
> submission error path.
>
> Signed-off-by: Wenjia Zhang <wenjz@qti.qualcomm.com>
[Severity: Low]
Since this fixes unbounded DMA mapping of req->src that has been present
since the driver was introduced, should this include a Fixes tag?
Fixes: ec8f5d8f6f76 ("crypto: qce - Qualcomm crypto engine driver")
> diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c
> index 7067c4c20c1e7..150a140287df5 100644
> --- a/drivers/crypto/qce/skcipher.c
> +++ b/drivers/crypto/qce/skcipher.c
[ ... ]
> @@ -131,17 +169,25 @@ qce_skcipher_async_req_handle(struct crypto_async_request *async_req)
> }
>
> if (diff_dst) {
> - src_nents = dma_map_sg(qce->dma_dev, req->src, rctx->src_nents, dir_src);
> + ret = qce_skcipher_prepare_src(req, gfp);
> + if (ret)
> + goto error_unmap_dst;
[Severity: Critical]
This problem wasn't introduced by this patch, but earlier in
qce_skcipher_async_req_handle() [1], doesn't returning
-rctx->dst_nents when rctx->dst_nents < 0 invert the negative error code
from sg_nents_for_len() into a positive value?
drivers/crypto/qce/skcipher.c:qce_skcipher_async_req_handle() {
...
if (rctx->dst_nents < 0) {
dev_err(qce->dev, "Invalid numbers of dst SG.\n");
return -rctx->dst_nents;
}
...
}
When a request provides a destination scatterlist shorter than
req->cryptlen, sg_nents_for_len() returns -EINVAL, and negating it causes
callers such as AF_ALG to treat the failed request as a positive byte
count and read uninitialized destination memory.
[1] https://sashiko.dev/#/bug/linux-0ba52c88-bdb7-4c9e-8c47-2ec58cfe9437
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-codex-qce-dma-bounds-upstream-20261201-v1-0-c15d01b45bce@oss.qualcomm.com?part=4
prev parent reply other threads:[~2026-12-01 3:01 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
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 [this message]
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-242397@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.