2015-01-28 20:40:04

by Cristian Stoica

[permalink] [raw]
Subject: [PATCH] crypto: tcrypt: do not allocate iv on stack for aead speed tests

See also: 9bac019dad8098a77cce555d929f678e22111783

Signed-off-by: Cristian Stoica <[email protected]>
---
crypto/tcrypt.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 2b2486a..4b9e23f 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -280,16 +280,20 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
struct scatterlist *sgout;
const char *e;
void *assoc;
- char iv[MAX_IVLEN];
+ char *iv;
char *xbuf[XBUFSIZE];
char *xoutbuf[XBUFSIZE];
char *axbuf[XBUFSIZE];
unsigned int *b_size;
unsigned int iv_len;

+ iv = kzalloc(MAX_IVLEN, GFP_KERNEL);
+ if (!iv)
+ return;
+
if (aad_size >= PAGE_SIZE) {
pr_err("associate data length (%u) too big\n", aad_size);
- return;
+ goto out_noxbuf;
}

if (enc == ENCRYPT)
@@ -355,7 +359,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,

iv_len = crypto_aead_ivsize(tfm);
if (iv_len)
- memset(&iv, 0xff, iv_len);
+ memset(iv, 0xff, iv_len);

crypto_aead_clear_flags(tfm, ~0);
printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ",
@@ -408,6 +412,7 @@ out_nooutbuf:
out_noaxbuf:
testmgr_free_buf(xbuf);
out_noxbuf:
+ kfree(iv);
return;
}

--
2.2.0


2015-02-04 10:01:12

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: tcrypt: do not allocate iv on stack for aead speed tests

On Wed, Jan 28, 2015 at 01:07:32PM +0200, Cristian Stoica wrote:
> See also: 9bac019dad8098a77cce555d929f678e22111783
>
> Signed-off-by: Cristian Stoica <[email protected]>

All three patches applied. Thanks!
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt