All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: arm64/sm4 - Fix possible crash in GCM cryption
@ 2023-01-18 14:19 ` Tianjia Zhang
  0 siblings, 0 replies; 14+ messages in thread
From: Tianjia Zhang @ 2023-01-18 14:19 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Catalin Marinas, Will Deacon,
	linux-crypto, linux-arm-kernel, linux-kernel
  Cc: Tianjia Zhang

When the cryption total length is zero, GCM cryption call
skcipher_walk_done() will cause an unexpected crash, so skip calling
this function to avoid possible crash when the GCM cryption length
is equal to zero.

Fixes: ae1b83c7d572 ("crypto: arm64/sm4 - add CE implementation for GCM mode")
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
 arch/arm64/crypto/sm4-ce-gcm-glue.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/crypto/sm4-ce-gcm-glue.c b/arch/arm64/crypto/sm4-ce-gcm-glue.c
index c450a2025ca9..9b63bcf9aa85 100644
--- a/arch/arm64/crypto/sm4-ce-gcm-glue.c
+++ b/arch/arm64/crypto/sm4-ce-gcm-glue.c
@@ -178,11 +178,13 @@ static int gcm_crypt(struct aead_request *req, struct skcipher_walk *walk,
 
 		kernel_neon_end();
 
-		err = skcipher_walk_done(walk, tail);
-		if (err)
-			return err;
-		if (walk->nbytes)
-			kernel_neon_begin();
+		if (walk->nbytes) {
+			err = skcipher_walk_done(walk, tail);
+			if (err)
+				return err;
+			if (walk->nbytes)
+				kernel_neon_begin();
+		}
 	} while (walk->nbytes > 0);
 
 	return 0;
-- 
2.24.3 (Apple Git-128)


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-01-31  9:41 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-18 14:19 [PATCH] crypto: arm64/sm4 - Fix possible crash in GCM cryption Tianjia Zhang
2023-01-18 14:19 ` Tianjia Zhang
2023-01-18 14:54 ` Herbert Xu
2023-01-18 14:54   ` Herbert Xu
2023-01-30  7:34   ` Tianjia Zhang
2023-01-30  7:34     ` Tianjia Zhang
2023-01-30  8:15     ` Herbert Xu
2023-01-30  8:15       ` Herbert Xu
2023-01-30  9:01       ` Herbert Xu
2023-01-30  9:01         ` Herbert Xu
2023-01-31  9:39         ` Tianjia Zhang
2023-01-31  9:39           ` Tianjia Zhang
2023-01-30  7:35 ` [PATCH v2] " Tianjia Zhang
2023-01-30  7:35   ` Tianjia Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.