From: Gilad Ben-Yossef <gilad@benyossef.com>
To: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: Ofir Drang <ofir.drang@arm.com>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] crypto: testmgr: don't allocate IV on stack
Date: Tue, 31 Oct 2017 07:56:26 +0000 [thread overview]
Message-ID: <1509436586-17500-1-git-send-email-gilad@benyossef.com> (raw)
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
next reply other threads:[~2017-10-31 7:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-31 7:56 Gilad Ben-Yossef [this message]
2017-10-31 7:59 ` Herbert Xu
2017-10-31 8:05 ` Gilad Ben-Yossef
2017-10-31 9:05 ` Horia Geantă
2017-10-31 10:19 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1509436586-17500-1-git-send-email-gilad@benyossef.com \
--to=gilad@benyossef.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ofir.drang@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®