Linux cryptographic layer development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jinming Zhao" <zhaojinming@uniontech.com>,
	"Bartosz Golaszewski" <brgl@kernel.org>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	"LABBE Corentin" <clabbe.montjoie@gmail.com>
Cc: linux-crypto@vger.kernel.org
Subject: Re: [PATCH] crypto: qce - use the mapped scatterlist count for ahash requests
Date: Fri, 13 Nov 2026 08:56:27 +0000	[thread overview]
Message-ID: <sashiko-outbox-212481@kernel.org> (raw)
In-Reply-To: <20261113-qce-ahash-dma-count-v1-1-0423b54d75c8@uniontech.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] crypto: qce - wrong nents passed to dma_unmap_sg() in ahash
  paths
--

commit a88269ea6101fd18834fc68bd1c31da34ddad7a9
Author: Jinming Zhao <zhaojinming@uniontech.com>

crypto: qce - use the mapped scatterlist count for ahash requests

This commit stores the entry count returned by dma_map_sg() in
rctx->src_nents so that qce_dma_prep_sgs() and the subsequent dma_unmap_sg()
calls use the mapped scatterlist count.

Link: https://sashiko.dev/#/patchset/20261016-fix-qce-ccm-adata-leak-v1-0-f54a82af2de0@uniontech.com

> diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c
> index b67d749db05f2..c53d0e53784e0 100644
> --- a/drivers/crypto/qce/sha.c
> +++ b/drivers/crypto/qce/sha.c
> @@ -97,6 +97,12 @@ static int qce_ahash_async_req_handle(struct crypto_async_request *async_req)
>  	if (!ret)
>  		return -EIO;
>  
> +	/*
> +	 * dma_map_sg() can coalesce entries, so use the number of mapped
> +	 * entries for the descriptor and for the later unmap.
> +	 */
> +	rctx->src_nents = ret;

[Severity: High]
Does overwriting rctx->src_nents pass the wrong entry count to
dma_unmap_sg()?

Both qce_ahash_done() and the error_unmap_src path pass rctx->src_nents to
dma_unmap_sg(), which the DMA API requires to be the original nents passed
to dma_map_sg() rather than the coalesced count it returned.  When
dma_map_sg() merges entries, unmapping with the smaller count triggers a
DMA-API debug warning and leaves trailing scatterlist segments unsynchronized
or unmapped.

Like qce_skcipher_async_req_handle(), keeping the return value of
dma_map_sg() in a local variable for qce_dma_prep_sgs() would preserve
rctx->src_nents for dma_unmap_sg().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261113-qce-ahash-dma-count-v1-1-0423b54d75c8@uniontech.com?part=1

      reply	other threads:[~2026-11-13  8:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  8:46 [PATCH] crypto: qce - use the mapped scatterlist count for ahash requests Jinming Zhao
2026-11-13  8:56 ` 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-212481@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=brgl@kernel.org \
    --cc=clabbe.montjoie@gmail.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=zhaojinming@uniontech.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