Skip to content

Commit 3fc89ad

Browse files
committed
crypto: api - Only abort operations on fatal signal
Currently a number of Crypto API operations may fail when a signal occurs. This causes nasty problems as the caller of those operations are often not in a good position to restart the operation. In fact there is currently no need for those operations to be interrupted by user signals at all. All we need is for them to be killable. This patch replaces the relevant calls of signal_pending with fatal_signal_pending, and wait_for_completion_interruptible with wait_for_completion_killable, respectively. Cc: stable@vger.kernel.org Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 8996eaf commit 3fc89ad

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎crypto/ablkcipher.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name,
706706
err:
707707
if (err != -EAGAIN)
708708
break;
709-
if (signal_pending(current)) {
709+
if (fatal_signal_pending(current)) {
710710
err = -EINTR;
711711
break;
712712
}

‎crypto/algapi.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ static void crypto_wait_for_test(struct crypto_larval *larval)
345345
crypto_alg_tested(larval->alg.cra_driver_name, 0);
346346
}
347347

348-
err = wait_for_completion_interruptible(&larval->completion);
348+
err = wait_for_completion_killable(&larval->completion);
349349
WARN_ON(err);
350350

351351
out:

‎crypto/api.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg)
172172
struct crypto_larval *larval = (void *)alg;
173173
long timeout;
174174

175-
timeout = wait_for_completion_interruptible_timeout(
175+
timeout = wait_for_completion_killable_timeout(
176176
&larval->completion, 60 * HZ);
177177

178178
alg = larval->adult;
@@ -445,7 +445,7 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
445445
err:
446446
if (err != -EAGAIN)
447447
break;
448-
if (signal_pending(current)) {
448+
if (fatal_signal_pending(current)) {
449449
err = -EINTR;
450450
break;
451451
}
@@ -562,7 +562,7 @@ void *crypto_alloc_tfm(const char *alg_name,
562562
err:
563563
if (err != -EAGAIN)
564564
break;
565-
if (signal_pending(current)) {
565+
if (fatal_signal_pending(current)) {
566566
err = -EINTR;
567567
break;
568568
}

‎crypto/crypto_user.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ static struct crypto_alg *crypto_user_skcipher_alg(const char *name, u32 type,
375375
err = PTR_ERR(alg);
376376
if (err != -EAGAIN)
377377
break;
378-
if (signal_pending(current)) {
378+
if (fatal_signal_pending(current)) {
379379
err = -EINTR;
380380
break;
381381
}

0 commit comments

Comments
 (0)