Commit b5d9cdc9 authored by Herbert Xu's avatar Herbert Xu Committed by Luis Henriques

crypto: api - Only abort operations on fatal signal

commit 3fc89adb 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: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 2a2fb9c0
...@@ -695,7 +695,7 @@ struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name, ...@@ -695,7 +695,7 @@ struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name,
err: err:
if (err != -EAGAIN) if (err != -EAGAIN)
break; break;
if (signal_pending(current)) { if (fatal_signal_pending(current)) {
err = -EINTR; err = -EINTR;
break; break;
} }
......
...@@ -325,7 +325,7 @@ static void crypto_wait_for_test(struct crypto_larval *larval) ...@@ -325,7 +325,7 @@ static void crypto_wait_for_test(struct crypto_larval *larval)
crypto_alg_tested(larval->alg.cra_driver_name, 0); 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); WARN_ON(err);
out: out:
......
...@@ -172,7 +172,7 @@ static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg) ...@@ -172,7 +172,7 @@ static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg)
struct crypto_larval *larval = (void *)alg; struct crypto_larval *larval = (void *)alg;
long timeout; long timeout;
timeout = wait_for_completion_interruptible_timeout( timeout = wait_for_completion_killable_timeout(
&larval->completion, 60 * HZ); &larval->completion, 60 * HZ);
alg = larval->adult; alg = larval->adult;
...@@ -435,7 +435,7 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask) ...@@ -435,7 +435,7 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
err: err:
if (err != -EAGAIN) if (err != -EAGAIN)
break; break;
if (signal_pending(current)) { if (fatal_signal_pending(current)) {
err = -EINTR; err = -EINTR;
break; break;
} }
...@@ -552,7 +552,7 @@ void *crypto_alloc_tfm(const char *alg_name, ...@@ -552,7 +552,7 @@ void *crypto_alloc_tfm(const char *alg_name,
err: err:
if (err != -EAGAIN) if (err != -EAGAIN)
break; break;
if (signal_pending(current)) { if (fatal_signal_pending(current)) {
err = -EINTR; err = -EINTR;
break; break;
} }
......
...@@ -367,7 +367,7 @@ static struct crypto_alg *crypto_user_aead_alg(const char *name, u32 type, ...@@ -367,7 +367,7 @@ static struct crypto_alg *crypto_user_aead_alg(const char *name, u32 type,
err = PTR_ERR(alg); err = PTR_ERR(alg);
if (err != -EAGAIN) if (err != -EAGAIN)
break; break;
if (signal_pending(current)) { if (fatal_signal_pending(current)) {
err = -EINTR; err = -EINTR;
break; break;
} }
......
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