]> git.hungrycats.org Git - linux/commitdiff
crypto: mxs-dcp - fix source scatterlist length access
authorThorsten Blum <thorsten.blum@linux.dev>
Sun, 21 Jun 2026 19:26:16 +0000 (21:26 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sun, 5 Jul 2026 05:27:15 +0000 (13:27 +0800)
mxs_dcp_aes_block_crypt() uses sg_dma_len() without mapping the source
scatterlist with dma_map_sg() first. Therefore, sg_dma_len() is invalid
and could return zero or a stale DMA length, causing encryption and
decryption to process the wrong number of bytes when
CONFIG_NEED_SG_DMA_LENGTH=y.

Use the original scatterlist length instead.

Fixes: 15b59e7c3733 ("crypto: mxs - Add Freescale MXS DCP driver")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/mxs-dcp.c

index 133ebc998236262eade9b84711dd3f34747612b3..595b2fd84667ec5b6791a10aefc397074c324ec4 100644 (file)
@@ -353,7 +353,7 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
 
        for_each_sg(req->src, src, sg_nents(req->src), i) {
                src_buf = sg_virt(src);
-               len = sg_dma_len(src);
+               len = src->length;
                tlen += len;
                limit_hit = tlen > req->cryptlen;