Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH 0/3] crypto: qce - fix CCM AAD buffer leak and the AEAD error paths
@ 2026-10-16  2:09 ZhaoJinming
  2026-10-16  2:09 ` [PATCH 1/3] crypto: qce - unmap the correct scatterlist in the CCM error path ZhaoJinming
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ZhaoJinming @ 2026-10-16  2:09 UTC (permalink / raw)
  To: Bartosz Golaszewski, Herbert Xu, David S. Miller, Thara Gopinath
  Cc: linux-crypto, linux-arm-msm, linux-kernel, ZhaoJinming, stable

This series fixes a memory leak in the QCE AEAD driver together with two
bugs in the error handling around it.

qce_aead_ccm_prepare_buf_assoclen() allocates rctx->adata for every CCM
request that carries associated data, but the buffer is never freed.

While preparing that fix, two problems in the error path of
qce_aead_async_req_handle() turned out to matter:

  - It unmaps req->src although rctx->src_sg is the scatterlist that was
    passed to dma_map_sg().  For CCM requests with associated data,
    rctx->src_sg carries the AAD buffer, so its mapping is leaked, and
    freeing rctx->adata there would free memory that is still DMA-mapped.

  - A dma_map_sg() failure for the source scatterlist is not detected,
    because the result is checked for a negative value while
    dma_map_sg() returns 0 on failure.  The error path then unmaps a
    scatterlist that was never mapped.

Patch 1 unmaps the correct scatterlist, patch 2 adds the missing frees
and patch 3 fixes the dma_map_sg() check.

All three were reported as pre-existing in the Sashiko review of the QCE
BAM locking series.  They touch the same function that was recently fixed
by commit 7f2345f47dd1 ("crypto: qce - fix CCM AAD buffer
underallocation").

Signed-off-by: ZhaoJinming <zhaojinming@uniontech.com>
---
ZhaoJinming (3):
      crypto: qce - unmap the correct scatterlist in the CCM error path
      crypto: qce - fix memory leak of the CCM AAD buffer
      crypto: qce - check dma_map_sg() result for the source scatterlist

 drivers/crypto/qce/aead.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
---
base-commit: 0fcb05b72344f40806cbe810de8872f1698bf053
change-id: 20261015-fix-qce-ccm-adata-leak-1ef34f172ba1

Best regards,
--  
ZhaoJinming <zhaojinming@uniontech.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-10-16 15:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16  2:09 [PATCH 0/3] crypto: qce - fix CCM AAD buffer leak and the AEAD error paths ZhaoJinming
2026-10-16  2:09 ` [PATCH 1/3] crypto: qce - unmap the correct scatterlist in the CCM error path ZhaoJinming
2026-10-16  2:09 ` [PATCH 2/3] crypto: qce - fix memory leak of the CCM AAD buffer ZhaoJinming
2026-10-16  2:09 ` [PATCH 3/3] crypto: qce - check dma_map_sg() result for the source scatterlist ZhaoJinming
2026-10-16 13:40 ` [PATCH 0/3] crypto: qce - fix CCM AAD buffer leak and the AEAD error paths Bartosz Golaszewski
2026-10-16 15:56 ` Eric Biggers

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