Thread (5 messages) 5 messages, 3 authors, 2017-10-31
STALE3254d

[PATCH] crypto: testmgr: don't allocate IV on stack

From: Gilad Ben-Yossef <gilad@benyossef.com>
Date: 2017-10-31 07:56:36
Also in: lkml
Subsystem: crypto api, the rest · Maintainers: Herbert Xu, "David S. Miller", Linus Torvalds

The IV was allocated on the stack in testmgr skcipher tests.
Since HW based tfm providers need to DMA the IV to the HW,
this leads to problems and is detected by the DMA-API debug
code.

Fix it by allocating the IV using kmalloc instead.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
 crypto/testmgr.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 7125ba3..88d0c57 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1085,12 +1085,16 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
 	const char *e, *d;
 	struct tcrypt_result result;
 	void *data;
-	char iv[MAX_IVLEN];
+	char *iv;
 	char *xbuf[XBUFSIZE];
 	char *xoutbuf[XBUFSIZE];
 	int ret = -ENOMEM;
 	unsigned int ivsize = crypto_skcipher_ivsize(tfm);
 
+	iv = kmalloc(MAX_IVLEN, GFP_KERNEL);
+	if (!iv)
+		goto out_nobuf;
+
 	if (testmgr_alloc_buf(xbuf))
 		goto out_nobuf;
 
@@ -1331,6 +1335,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc,
 		testmgr_free_buf(xoutbuf);
 out_nooutbuf:
 	testmgr_free_buf(xbuf);
+	kfree(iv);
 out_nobuf:
 	return ret;
 }
-- 
2.7.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help