Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH] crypto: chelsio - unmap the IV with its mapped size
@ 2026-11-27 16:31 Thomas Fourier
  0 siblings, 0 replies; only message in thread
From: Thomas Fourier @ 2026-11-27 16:31 UTC (permalink / raw)
  Cc: Thomas Fourier, Ayush Sawal, Herbert Xu, David S. Miller,
	Harsh Jain, open list:CXGB4 CRYPTO DRIVER (chcr), open list

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-27 16:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 16:31 [PATCH] crypto: chelsio - unmap the IV with its mapped size Thomas Fourier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox