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 1/4] crypto: qce - Bound AEAD input DMA to the programmed segment
Date: Tue, 01 Dec 2026 03:06:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-242400@kernel.org> (raw)
In-Reply-To: <20261201-codex-qce-dma-bounds-upstream-20261201-v1-1-c15d01b45bce@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] crypto: qce - unbounded src_sg on in-place CCM decrypt in
qce_aead_ccm_prepare_buf()
- [Low] crypto: qce - missing Fixes trailer in commit message
--
commit f3b55d49bd062185aa02d0a7a7eedf329e6ab5f7
Author: Wenjia Zhang <wenjz@qti.qualcomm.com>
> crypto: qce - Bound AEAD input DMA to the programmed segment
>
> An AEAD source scatterlist can contain bytes beyond the input segment,
> such as space reserved for an output authentication tag.
> sg_nents_for_len() counts the entries covering a length but does not
> shorten the final entry. Mapping the original list can therefore pass
> those trailing bytes to BAM, exceeding the programmed crypto segment and
> causing transfer errors or timeouts.
>
> Build a bounded source table for separately mapped input lists,
> referencing the original pages and limiting the final entry to the
> required length. Validate the total mapped input length against the
> configured segment. Include the authentication tag for CCM decryption,
> where hardware consumes it, but exclude it for authenc decryption, where
> software verifies it.
>
> Handle the zero return from dma_map_sg() as a mapping failure and
> release the allocated scatterlist tables on completion and preparation
> or submission errors.
>
> Signed-off-by: Wenjia Zhang <wenjz@qti.qualcomm.com>
[Severity: Low]
Since this fixes AEAD DMA mapping bugs, should it include a Fixes tag for
9363efb4181c ("crypto: qce - Add support for AEAD algorithms")?
> diff --git a/drivers/crypto/qce/aead.c b/drivers/crypto/qce/aead.c
> index 2065c46162c21..793913b33da6f 100644
> --- a/drivers/crypto/qce/aead.c
> +++ b/drivers/crypto/qce/aead.c
[ ... ]
> @@ -336,8 +350,9 @@ static int qce_aead_ccm_prepare_buf(struct aead_request *req)
>
> cryptlen = rctx->cryptlen + ctx->authsize;
> if (diff_dst) {
> - rctx->src_nents = sg_nents_for_len(req->src, cryptlen);
> - rctx->src_sg = req->src;
> + ret = qce_aead_prepare_src_buf(req, cryptlen);
> + if (ret)
> + return ret;
> sg = qce_aead_prepare_dst_buf(req);
> if (IS_ERR(sg))
> return PTR_ERR(sg);
[Severity: Medium]
Does the !diff_dst branch just below this leave rctx->src_sg and
rctx->dst_sg unbounded for in-place CCM decryption with zero assoclen?
drivers/crypto/qce/aead.c:qce_aead_ccm_prepare_buf() {
...
} else {
rctx->src_nents = sg_nents_for_len(req->src, cryptlen);
rctx->src_sg = req->src;
rctx->dst_nents = rctx->src_nents;
rctx->dst_sg = rctx->src_sg;
}
...
}
Because req->src is used directly without clamping the final entry to
cryptlen, any trailing bytes in the scatterlist remain mapped, causing the
new qce_aead_check_input() check to see dma_len != expected and reject the
request with -EINVAL. The !diff_dst branch also skips checking for a
negative return from sg_nents_for_len(), which would pass -EINVAL as nents
to dma_map_sg() if req->src is shorter than cryptlen.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-codex-qce-dma-bounds-upstream-20261201-v1-0-c15d01b45bce@oss.qualcomm.com?part=1
next prev parent reply other threads:[~2026-12-01 3:06 UTC|newest]
Thread overview: 9+ 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 [this message]
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
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-242400@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox