Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: mxs-dcp - fix source scatterlist length access
@ 2026-06-21 19:26 Thorsten Blum
  2026-06-21 22:31 ` Frank Li
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-06-21 19:26 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Frank Li, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Marek Vasut
  Cc: Thorsten Blum, stable, linux-crypto, imx, linux-arm-kernel,
	linux-kernel

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>
---
 drivers/crypto/mxs-dcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
index 133ebc998236..595b2fd84667 100644
--- a/drivers/crypto/mxs-dcp.c
+++ b/drivers/crypto/mxs-dcp.c
@@ -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;
 


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

* Re: [PATCH] crypto: mxs-dcp - fix source scatterlist length access
  2026-06-21 19:26 [PATCH] crypto: mxs-dcp - fix source scatterlist length access Thorsten Blum
@ 2026-06-21 22:31 ` Frank Li
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2026-06-21 22:31 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Herbert Xu, David S. Miller, Frank Li, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Marek Vasut, stable,
	linux-crypto, imx, linux-arm-kernel, linux-kernel

>
> 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.

It'd beter add some description about copy sg to a bounce buffer to do
descrytpion, needn't map sg firstly and direct use the original
scatterlist length.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
>
> Fixes: 15b59e7c3733 ("crypto: mxs - Add Freescale MXS DCP driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  drivers/crypto/mxs-dcp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
> index 133ebc998236..595b2fd84667 100644
> --- a/drivers/crypto/mxs-dcp.c
> +++ b/drivers/crypto/mxs-dcp.c
> @@ -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;
>
>


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

end of thread, other threads:[~2026-06-21 22:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-21 19:26 [PATCH] crypto: mxs-dcp - fix source scatterlist length access Thorsten Blum
2026-06-21 22:31 ` Frank Li

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