mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] crypto: sl3516 - drop invalid sg_dma_len checks before DMA mapping
@ 2026-07-10  7:42 Thorsten Blum
  2026-07-10 10:17 ` Linus Walleij
  2026-07-17  8:16 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2026-07-10  7:42 UTC (permalink / raw)
  To: Corentin Labbe, Hans Ulli Kroll, Linus Walleij, Herbert Xu,
	David S. Miller
  Cc: Thorsten Blum, linux-arm-kernel, linux-crypto, linux-kernel

sg_dma_len() is only valid after mapping the scatterlist with
dma_map_sg(). However, sl3516_ce_need_fallback() checks it before the
source and destination scatterlists are mapped. Thus, a stale DMA length
that is not a multiple of 16 could incorrectly force a software fallback
when CONFIG_NEED_SG_DMA_LENGTH=y.

Remove the invalid checks; the existing scatterlist length checks are
sufficient.

Fixes: 46c5338db7bd ("crypto: sl3516 - Add sl3516 crypto engine")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/crypto/gemini/sl3516-ce-cipher.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/crypto/gemini/sl3516-ce-cipher.c b/drivers/crypto/gemini/sl3516-ce-cipher.c
index 583010b2d007..02ec4282333b 100644
--- a/drivers/crypto/gemini/sl3516-ce-cipher.c
+++ b/drivers/crypto/gemini/sl3516-ce-cipher.c
@@ -56,10 +56,6 @@ static bool sl3516_ce_need_fallback(struct skcipher_request *areq)
 			ce->fallback_mod16++;
 			return true;
 		}
-		if ((sg_dma_len(sg) % 16) != 0) {
-			ce->fallback_mod16++;
-			return true;
-		}
 		if (!IS_ALIGNED(sg->offset, 16)) {
 			ce->fallback_align16++;
 			return true;
@@ -72,10 +68,6 @@ static bool sl3516_ce_need_fallback(struct skcipher_request *areq)
 			ce->fallback_mod16++;
 			return true;
 		}
-		if ((sg_dma_len(sg) % 16) != 0) {
-			ce->fallback_mod16++;
-			return true;
-		}
 		if (!IS_ALIGNED(sg->offset, 16)) {
 			ce->fallback_align16++;
 			return true;

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

* Re: [PATCH] crypto: sl3516 - drop invalid sg_dma_len checks before DMA mapping
  2026-07-10  7:42 [PATCH] crypto: sl3516 - drop invalid sg_dma_len checks before DMA mapping Thorsten Blum
@ 2026-07-10 10:17 ` Linus Walleij
  2026-07-17  8:16 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2026-07-10 10:17 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Corentin Labbe, Hans Ulli Kroll, Herbert Xu, David S. Miller,
	linux-arm-kernel, linux-crypto, linux-kernel

On Fri, Jul 10, 2026 at 9:42 AM Thorsten Blum <thorsten.blum@linux.dev> wrote:

> sg_dma_len() is only valid after mapping the scatterlist with
> dma_map_sg(). However, sl3516_ce_need_fallback() checks it before the
> source and destination scatterlists are mapped. Thus, a stale DMA length
> that is not a multiple of 16 could incorrectly force a software fallback
> when CONFIG_NEED_SG_DMA_LENGTH=y.
>
> Remove the invalid checks; the existing scatterlist length checks are
> sufficient.
>
> Fixes: 46c5338db7bd ("crypto: sl3516 - Add sl3516 crypto engine")
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Looks right to me.
Acked-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

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

* Re: [PATCH] crypto: sl3516 - drop invalid sg_dma_len checks before DMA mapping
  2026-07-10  7:42 [PATCH] crypto: sl3516 - drop invalid sg_dma_len checks before DMA mapping Thorsten Blum
  2026-07-10 10:17 ` Linus Walleij
@ 2026-07-17  8:16 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2026-07-17  8:16 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Corentin Labbe, Hans Ulli Kroll, Linus Walleij, David S. Miller,
	linux-arm-kernel, linux-crypto, linux-kernel

On Fri, Jul 10, 2026 at 09:42:17AM +0200, Thorsten Blum wrote:
> sg_dma_len() is only valid after mapping the scatterlist with
> dma_map_sg(). However, sl3516_ce_need_fallback() checks it before the
> source and destination scatterlists are mapped. Thus, a stale DMA length
> that is not a multiple of 16 could incorrectly force a software fallback
> when CONFIG_NEED_SG_DMA_LENGTH=y.
> 
> Remove the invalid checks; the existing scatterlist length checks are
> sufficient.
> 
> Fixes: 46c5338db7bd ("crypto: sl3516 - Add sl3516 crypto engine")
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  drivers/crypto/gemini/sl3516-ce-cipher.c | 8 --------
>  1 file changed, 8 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2026-07-17  8:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-10  7:42 [PATCH] crypto: sl3516 - drop invalid sg_dma_len checks before DMA mapping Thorsten Blum
2026-07-10 10:17 ` Linus Walleij
2026-07-17  8:16 ` Herbert Xu

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

Powered by JetHome