All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto/testmgr: don't copy from source IV too much
@ 2015-09-03 11:32 Andrey Ryabinin
  2015-09-03 11:32 ` [PATCH] x86/crypto/ghash-intel: specify context size for ghash async algorithm Andrey Ryabinin
  2015-09-03 13:20 ` [PATCH] crypto/testmgr: don't copy from source IV too much Herbert Xu
  0 siblings, 2 replies; 8+ messages in thread
From: Andrey Ryabinin @ 2015-09-03 11:32 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, linux-crypto; +Cc: Andrey Ryabinin, linux-kernel

While the destination buffer 'iv' is MAX_IVLEN size,
the source 'template[i].iv' could be smaller. Thus
copying it via memcpy() leads to invalid memory access.
Use strlcpy() instead.

Signed-off-by: Andrey Ryabinin <aryabinin@odin.com>
---
 crypto/testmgr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index d0a42bd..d85221c 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -974,7 +974,7 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
 			continue;
 
 		if (template[i].iv)
-			memcpy(iv, template[i].iv, MAX_IVLEN);
+			strlcpy(iv, template[i].iv, MAX_IVLEN);
 		else
 			memset(iv, 0, MAX_IVLEN);
 
@@ -1049,7 +1049,7 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
 			continue;
 
 		if (template[i].iv)
-			memcpy(iv, template[i].iv, MAX_IVLEN);
+			strlcpy(iv, template[i].iv, MAX_IVLEN);
 		else
 			memset(iv, 0, MAX_IVLEN);
 
-- 
2.4.6

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

end of thread, other threads:[~2015-09-11 14:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-03 11:32 [PATCH] crypto/testmgr: don't copy from source IV too much Andrey Ryabinin
2015-09-03 11:32 ` [PATCH] x86/crypto/ghash-intel: specify context size for ghash async algorithm Andrey Ryabinin
2015-09-04 15:24   ` Herbert Xu
2015-09-03 13:20 ` [PATCH] crypto/testmgr: don't copy from source IV too much Herbert Xu
2015-09-04 16:42   ` Andrey Ryabinin
2015-09-05  2:04     ` Herbert Xu
2015-09-10 10:11   ` [PATCH v2] " Andrey Ryabinin
2015-09-11 14:14     ` Herbert Xu

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.