diff options
author | Eric Biggers <ebiggers@google.com> | 2016-11-23 13:24:35 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-11-28 08:23:24 -0500 |
commit | eb0955935e2ae3aa1fc9c34ec684ffe086e81da7 (patch) | |
tree | d806f4da3cc1988882c9802555eddb1b4dc08905 /crypto/testmgr.c | |
parent | 93aafb6d4f328aab0264863cf7b5faa3d0978a86 (diff) |
crypto: testmgr - don't use stack buffer in test_acomp()
With virtually-mapped stacks (CONFIG_VMAP_STACK=y), using the
scatterlist crypto API with stack buffers is not allowed, and with
appropriate debugging options will cause the
'BUG_ON(!virt_addr_valid(buf));' in sg_set_buf() to be triggered.
Use a heap buffer instead.
Fixes: d7db7a882deb ("crypto: acomp - update testmgr with support for acomp")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/testmgr.c')
-rw-r--r-- | crypto/testmgr.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 6ac46966800b..67e68c0f9e61 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
@@ -1448,17 +1448,21 @@ static int test_acomp(struct crypto_acomp *tfm, struct comp_testvec *ctemplate, | |||
1448 | { | 1448 | { |
1449 | const char *algo = crypto_tfm_alg_driver_name(crypto_acomp_tfm(tfm)); | 1449 | const char *algo = crypto_tfm_alg_driver_name(crypto_acomp_tfm(tfm)); |
1450 | unsigned int i; | 1450 | unsigned int i; |
1451 | char output[COMP_BUF_SIZE]; | 1451 | char *output; |
1452 | int ret; | 1452 | int ret; |
1453 | struct scatterlist src, dst; | 1453 | struct scatterlist src, dst; |
1454 | struct acomp_req *req; | 1454 | struct acomp_req *req; |
1455 | struct tcrypt_result result; | 1455 | struct tcrypt_result result; |
1456 | 1456 | ||
1457 | output = kmalloc(COMP_BUF_SIZE, GFP_KERNEL); | ||
1458 | if (!output) | ||
1459 | return -ENOMEM; | ||
1460 | |||
1457 | for (i = 0; i < ctcount; i++) { | 1461 | for (i = 0; i < ctcount; i++) { |
1458 | unsigned int dlen = COMP_BUF_SIZE; | 1462 | unsigned int dlen = COMP_BUF_SIZE; |
1459 | int ilen = ctemplate[i].inlen; | 1463 | int ilen = ctemplate[i].inlen; |
1460 | 1464 | ||
1461 | memset(output, 0, sizeof(output)); | 1465 | memset(output, 0, dlen); |
1462 | init_completion(&result.completion); | 1466 | init_completion(&result.completion); |
1463 | sg_init_one(&src, ctemplate[i].input, ilen); | 1467 | sg_init_one(&src, ctemplate[i].input, ilen); |
1464 | sg_init_one(&dst, output, dlen); | 1468 | sg_init_one(&dst, output, dlen); |
@@ -1507,7 +1511,7 @@ static int test_acomp(struct crypto_acomp *tfm, struct comp_testvec *ctemplate, | |||
1507 | unsigned int dlen = COMP_BUF_SIZE; | 1511 | unsigned int dlen = COMP_BUF_SIZE; |
1508 | int ilen = dtemplate[i].inlen; | 1512 | int ilen = dtemplate[i].inlen; |
1509 | 1513 | ||
1510 | memset(output, 0, sizeof(output)); | 1514 | memset(output, 0, dlen); |
1511 | init_completion(&result.completion); | 1515 | init_completion(&result.completion); |
1512 | sg_init_one(&src, dtemplate[i].input, ilen); | 1516 | sg_init_one(&src, dtemplate[i].input, ilen); |
1513 | sg_init_one(&dst, output, dlen); | 1517 | sg_init_one(&dst, output, dlen); |
@@ -1555,6 +1559,7 @@ static int test_acomp(struct crypto_acomp *tfm, struct comp_testvec *ctemplate, | |||
1555 | ret = 0; | 1559 | ret = 0; |
1556 | 1560 | ||
1557 | out: | 1561 | out: |
1562 | kfree(output); | ||
1558 | return ret; | 1563 | return ret; |
1559 | } | 1564 | } |
1560 | 1565 | ||