aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/testmgr.c
diff options
context:
space:
mode:
authorRabin Vincent <rabin.vincent@axis.com>2015-01-09 10:25:28 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2015-01-13 06:30:44 -0500
commit8a45ac12ec5b6ee67f8559c78ae11d9af8b821ee (patch)
tree6e3930b39740e7070c50dc62101340a3e634175c /crypto/testmgr.c
parent8155330aad477c5b1337895a6922df76817f0874 (diff)
crypto: testmgr - don't use interruptible wait in tests
tcrypt/testmgr uses wait_for_completion_interruptible() everywhere when it waits for a request to be completed. If it's interrupted, then the test is aborted and the request is freed. However, if any of these calls actually do get interrupted, the result will likely be a kernel crash, when the driver handles the now-freed request. Use wait_for_completion() instead. Signed-off-by: Rabin Vincent <rabin.vincent@axis.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/testmgr.c')
-rw-r--r--crypto/testmgr.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 037368d34586..235b1fff04c4 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -181,10 +181,9 @@ static void testmgr_free_buf(char *buf[XBUFSIZE])
181static int wait_async_op(struct tcrypt_result *tr, int ret) 181static int wait_async_op(struct tcrypt_result *tr, int ret)
182{ 182{
183 if (ret == -EINPROGRESS || ret == -EBUSY) { 183 if (ret == -EINPROGRESS || ret == -EBUSY) {
184 ret = wait_for_completion_interruptible(&tr->completion); 184 wait_for_completion(&tr->completion);
185 if (!ret)
186 ret = tr->err;
187 reinit_completion(&tr->completion); 185 reinit_completion(&tr->completion);
186 ret = tr->err;
188 } 187 }
189 return ret; 188 return ret;
190} 189}
@@ -353,12 +352,11 @@ static int __test_hash(struct crypto_ahash *tfm, struct hash_testvec *template,
353 break; 352 break;
354 case -EINPROGRESS: 353 case -EINPROGRESS:
355 case -EBUSY: 354 case -EBUSY:
356 ret = wait_for_completion_interruptible( 355 wait_for_completion(&tresult.completion);
357 &tresult.completion); 356 reinit_completion(&tresult.completion);
358 if (!ret && !(ret = tresult.err)) { 357 ret = tresult.err;
359 reinit_completion(&tresult.completion); 358 if (!ret)
360 break; 359 break;
361 }
362 /* fall through */ 360 /* fall through */
363 default: 361 default:
364 printk(KERN_ERR "alg: hash: digest failed " 362 printk(KERN_ERR "alg: hash: digest failed "
@@ -569,12 +567,11 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
569 break; 567 break;
570 case -EINPROGRESS: 568 case -EINPROGRESS:
571 case -EBUSY: 569 case -EBUSY:
572 ret = wait_for_completion_interruptible( 570 wait_for_completion(&result.completion);
573 &result.completion); 571 reinit_completion(&result.completion);
574 if (!ret && !(ret = result.err)) { 572 ret = result.err;
575 reinit_completion(&result.completion); 573 if (!ret)
576 break; 574 break;
577 }
578 case -EBADMSG: 575 case -EBADMSG:
579 if (template[i].novrfy) 576 if (template[i].novrfy)
580 /* verification failure was expected */ 577 /* verification failure was expected */
@@ -720,12 +717,11 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
720 break; 717 break;
721 case -EINPROGRESS: 718 case -EINPROGRESS:
722 case -EBUSY: 719 case -EBUSY:
723 ret = wait_for_completion_interruptible( 720 wait_for_completion(&result.completion);
724 &result.completion); 721 reinit_completion(&result.completion);
725 if (!ret && !(ret = result.err)) { 722 ret = result.err;
726 reinit_completion(&result.completion); 723 if (!ret)
727 break; 724 break;
728 }
729 case -EBADMSG: 725 case -EBADMSG:
730 if (template[i].novrfy) 726 if (template[i].novrfy)
731 /* verification failure was expected */ 727 /* verification failure was expected */
@@ -1002,12 +998,11 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
1002 break; 998 break;
1003 case -EINPROGRESS: 999 case -EINPROGRESS:
1004 case -EBUSY: 1000 case -EBUSY:
1005 ret = wait_for_completion_interruptible( 1001 wait_for_completion(&result.completion);
1006 &result.completion); 1002 reinit_completion(&result.completion);
1007 if (!ret && !((ret = result.err))) { 1003 ret = result.err;
1008 reinit_completion(&result.completion); 1004 if (!ret)
1009 break; 1005 break;
1010 }
1011 /* fall through */ 1006 /* fall through */
1012 default: 1007 default:
1013 pr_err("alg: skcipher%s: %s failed on test %d for %s: ret=%d\n", 1008 pr_err("alg: skcipher%s: %s failed on test %d for %s: ret=%d\n",
@@ -1097,12 +1092,11 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
1097 break; 1092 break;
1098 case -EINPROGRESS: 1093 case -EINPROGRESS:
1099 case -EBUSY: 1094 case -EBUSY:
1100 ret = wait_for_completion_interruptible( 1095 wait_for_completion(&result.completion);
1101 &result.completion); 1096 reinit_completion(&result.completion);
1102 if (!ret && !((ret = result.err))) { 1097 ret = result.err;
1103 reinit_completion(&result.completion); 1098 if (!ret)
1104 break; 1099 break;
1105 }
1106 /* fall through */ 1100 /* fall through */
1107 default: 1101 default:
1108 pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n", 1102 pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n",