Commit 89027579 authored by Herbert Xu's avatar Herbert Xu

crypto: xts - Propagate NEED_FALLBACK bit

When we're used as a fallback algorithm, we should propagate
the NEED_FALLBACK bit when searching for the underlying ECB mode.

This just happens to fix a hang too because otherwise the search
may end up loading the same module that triggered this XTS creation.

Cc: stable@vger.kernel.org #4.10
Fixes: f1c131b4 ("crypto: xts - Convert to skcipher")
Reported-by: default avatarHarald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 016df0ab
...@@ -463,6 +463,7 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb) ...@@ -463,6 +463,7 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
struct xts_instance_ctx *ctx; struct xts_instance_ctx *ctx;
struct skcipher_alg *alg; struct skcipher_alg *alg;
const char *cipher_name; const char *cipher_name;
u32 mask;
int err; int err;
algt = crypto_get_attr_type(tb); algt = crypto_get_attr_type(tb);
...@@ -483,18 +484,19 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb) ...@@ -483,18 +484,19 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
ctx = skcipher_instance_ctx(inst); ctx = skcipher_instance_ctx(inst);
crypto_set_skcipher_spawn(&ctx->spawn, skcipher_crypto_instance(inst)); crypto_set_skcipher_spawn(&ctx->spawn, skcipher_crypto_instance(inst));
err = crypto_grab_skcipher(&ctx->spawn, cipher_name, 0,
crypto_requires_sync(algt->type, mask = crypto_requires_off(algt->type, algt->mask,
algt->mask)); CRYPTO_ALG_NEED_FALLBACK |
CRYPTO_ALG_ASYNC);
err = crypto_grab_skcipher(&ctx->spawn, cipher_name, 0, mask);
if (err == -ENOENT) { if (err == -ENOENT) {
err = -ENAMETOOLONG; err = -ENAMETOOLONG;
if (snprintf(ctx->name, CRYPTO_MAX_ALG_NAME, "ecb(%s)", if (snprintf(ctx->name, CRYPTO_MAX_ALG_NAME, "ecb(%s)",
cipher_name) >= CRYPTO_MAX_ALG_NAME) cipher_name) >= CRYPTO_MAX_ALG_NAME)
goto err_free_inst; goto err_free_inst;
err = crypto_grab_skcipher(&ctx->spawn, ctx->name, 0, err = crypto_grab_skcipher(&ctx->spawn, ctx->name, 0, mask);
crypto_requires_sync(algt->type,
algt->mask));
} }
if (err) if (err)
......
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