Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Thomas Fourier <fourier.thomas@gmail.com>
Cc: Thomas Fourier <fourier.thomas@gmail.com>,
	Ayush Sawal <ayush.sawal@chelsio.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Harsh Jain <harsh@chelsio.com>,
	linux-crypto@vger.kernel.org (open list:CXGB4 CRYPTO DRIVER
	(chcr)), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] crypto: chelsio - unmap the IV with its mapped size
Date: Fri, 27 Nov 2026 17:31:49 +0100	[thread overview]
Message-ID: <20261127163151.59138-2-fourier.thomas@gmail.com> (raw)

chcr_aead_dma_map() maps reqctx->iv with IV + reqctx->b0_len bytes, but
when mapping the source or destination scatterlist fails its error path
unmaps only IV bytes. For CCM b0_len is not zero, so the unmap may leave
parts of the buffer mapped. This may violate safety garuaties provided
by IOMMU for example.

Unmap with IV + reqctx->b0_len, as chcr_aead_dma_unmap() does.

Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Fixes: 4262c98aab95 ("crypto: chelsio - Remove separate buffer used for DMA map B0 block in CCM")
---
 drivers/crypto/chelsio/chcr_algo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index e2f2b2a6200e..ca4bde6b7b1f 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -2544,7 +2544,8 @@ int chcr_aead_dma_map(struct device *dev,
 
 	return 0;
 err:
-	dma_unmap_single(dev, reqctx->iv_dma, IV, DMA_BIDIRECTIONAL);
+	dma_unmap_single(dev, reqctx->iv_dma, IV + reqctx->b0_len,
+			 DMA_BIDIRECTIONAL);
 	return -ENOMEM;
 }
 
-- 
2.53.0


                 reply	other threads:[~2026-11-27 16:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261127163151.59138-2-fourier.thomas@gmail.com \
    --to=fourier.thomas@gmail.com \
    --cc=ayush.sawal@chelsio.com \
    --cc=davem@davemloft.net \
    --cc=harsh@chelsio.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.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