Skip to content
This repository has been archived by the owner on Sep 18, 2022. It is now read-only.

Commit

Permalink
crypto: api - Only abort operations on fatal signal
Browse files Browse the repository at this point in the history
commit 3fc89adb9fa4beff31374a4bf50b3d099d88ae83 upstream.

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.

Signed-off-by: Herbert Xu <[email protected]>
Signed-off-by: Zefan Li <[email protected]>
  • Loading branch information
herbertx authored and lizf-os committed Apr 27, 2016
1 parent 4333b97 commit 394d806
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crypto/ablkcipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name,
err:
if (err != -EAGAIN)
break;
if (signal_pending(current)) {
if (fatal_signal_pending(current)) {
err = -EINTR;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion crypto/algapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ static void crypto_wait_for_test(struct crypto_larval *larval)
crypto_alg_tested(larval->alg.cra_driver_name, 0);
}

err = wait_for_completion_interruptible(&larval->completion);
err = wait_for_completion_killable(&larval->completion);
WARN_ON(err);

out:
Expand Down
6 changes: 3 additions & 3 deletions crypto/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg)
struct crypto_larval *larval = (void *)alg;
long timeout;

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

alg = larval->adult;
Expand Down Expand Up @@ -441,7 +441,7 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
err:
if (err != -EAGAIN)
break;
if (signal_pending(current)) {
if (fatal_signal_pending(current)) {
err = -EINTR;
break;
}
Expand Down Expand Up @@ -558,7 +558,7 @@ void *crypto_alloc_tfm(const char *alg_name,
err:
if (err != -EAGAIN)
break;
if (signal_pending(current)) {
if (fatal_signal_pending(current)) {
err = -EINTR;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion crypto/crypto_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ static struct crypto_alg *crypto_user_aead_alg(const char *name, u32 type,
err = PTR_ERR(alg);
if (err != -EAGAIN)
break;
if (signal_pending(current)) {
if (fatal_signal_pending(current)) {
err = -EINTR;
break;
}
Expand Down

0 comments on commit 394d806

Please sign in to comment.