Commit 8a45ac12 authored by Rabin Vincent's avatar Rabin Vincent Committed by Herbert Xu

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: default avatarRabin Vincent <rabin.vincent@axis.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 8155330a
...@@ -764,10 +764,9 @@ static inline int do_one_ahash_op(struct ahash_request *req, int ret) ...@@ -764,10 +764,9 @@ static inline int do_one_ahash_op(struct ahash_request *req, int ret)
if (ret == -EINPROGRESS || ret == -EBUSY) { if (ret == -EINPROGRESS || ret == -EBUSY) {
struct tcrypt_result *tr = req->base.data; struct tcrypt_result *tr = req->base.data;
ret = wait_for_completion_interruptible(&tr->completion); wait_for_completion(&tr->completion);
if (!ret)
ret = tr->err;
reinit_completion(&tr->completion); reinit_completion(&tr->completion);
ret = tr->err;
} }
return ret; return ret;
} }
...@@ -993,10 +992,9 @@ static inline int do_one_acipher_op(struct ablkcipher_request *req, int ret) ...@@ -993,10 +992,9 @@ static inline int do_one_acipher_op(struct ablkcipher_request *req, int ret)
if (ret == -EINPROGRESS || ret == -EBUSY) { if (ret == -EINPROGRESS || ret == -EBUSY) {
struct tcrypt_result *tr = req->base.data; struct tcrypt_result *tr = req->base.data;
ret = wait_for_completion_interruptible(&tr->completion); wait_for_completion(&tr->completion);
if (!ret)
ret = tr->err;
reinit_completion(&tr->completion); reinit_completion(&tr->completion);
ret = tr->err;
} }
return ret; return ret;
......
...@@ -181,10 +181,9 @@ static void testmgr_free_buf(char *buf[XBUFSIZE]) ...@@ -181,10 +181,9 @@ static void testmgr_free_buf(char *buf[XBUFSIZE])
static int wait_async_op(struct tcrypt_result *tr, int ret) static int wait_async_op(struct tcrypt_result *tr, int ret)
{ {
if (ret == -EINPROGRESS || ret == -EBUSY) { if (ret == -EINPROGRESS || ret == -EBUSY) {
ret = wait_for_completion_interruptible(&tr->completion); wait_for_completion(&tr->completion);
if (!ret)
ret = tr->err;
reinit_completion(&tr->completion); reinit_completion(&tr->completion);
ret = tr->err;
} }
return ret; return ret;
} }
...@@ -353,12 +352,11 @@ static int __test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, ...@@ -353,12 +352,11 @@ static int __test_hash(struct crypto_ahash *tfm, struct hash_testvec *template,
break; break;
case -EINPROGRESS: case -EINPROGRESS:
case -EBUSY: case -EBUSY:
ret = wait_for_completion_interruptible( wait_for_completion(&tresult.completion);
&tresult.completion);
if (!ret && !(ret = tresult.err)) {
reinit_completion(&tresult.completion); reinit_completion(&tresult.completion);
ret = tresult.err;
if (!ret)
break; break;
}
/* fall through */ /* fall through */
default: default:
printk(KERN_ERR "alg: hash: digest failed " printk(KERN_ERR "alg: hash: digest failed "
...@@ -569,12 +567,11 @@ static int __test_aead(struct crypto_aead *tfm, int enc, ...@@ -569,12 +567,11 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
break; break;
case -EINPROGRESS: case -EINPROGRESS:
case -EBUSY: case -EBUSY:
ret = wait_for_completion_interruptible( wait_for_completion(&result.completion);
&result.completion);
if (!ret && !(ret = result.err)) {
reinit_completion(&result.completion); reinit_completion(&result.completion);
ret = result.err;
if (!ret)
break; break;
}
case -EBADMSG: case -EBADMSG:
if (template[i].novrfy) if (template[i].novrfy)
/* verification failure was expected */ /* verification failure was expected */
...@@ -720,12 +717,11 @@ static int __test_aead(struct crypto_aead *tfm, int enc, ...@@ -720,12 +717,11 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
break; break;
case -EINPROGRESS: case -EINPROGRESS:
case -EBUSY: case -EBUSY:
ret = wait_for_completion_interruptible( wait_for_completion(&result.completion);
&result.completion);
if (!ret && !(ret = result.err)) {
reinit_completion(&result.completion); reinit_completion(&result.completion);
ret = result.err;
if (!ret)
break; break;
}
case -EBADMSG: case -EBADMSG:
if (template[i].novrfy) if (template[i].novrfy)
/* verification failure was expected */ /* verification failure was expected */
...@@ -1002,12 +998,11 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, ...@@ -1002,12 +998,11 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
break; break;
case -EINPROGRESS: case -EINPROGRESS:
case -EBUSY: case -EBUSY:
ret = wait_for_completion_interruptible( wait_for_completion(&result.completion);
&result.completion);
if (!ret && !((ret = result.err))) {
reinit_completion(&result.completion); reinit_completion(&result.completion);
ret = result.err;
if (!ret)
break; break;
}
/* fall through */ /* fall through */
default: default:
pr_err("alg: skcipher%s: %s failed on test %d for %s: ret=%d\n", 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,12 +1092,11 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
break; break;
case -EINPROGRESS: case -EINPROGRESS:
case -EBUSY: case -EBUSY:
ret = wait_for_completion_interruptible( wait_for_completion(&result.completion);
&result.completion);
if (!ret && !((ret = result.err))) {
reinit_completion(&result.completion); reinit_completion(&result.completion);
ret = result.err;
if (!ret)
break; break;
}
/* fall through */ /* fall through */
default: default:
pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n", pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment