Skip to content

Commit 8902757

Browse files
committed
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: [email protected] #4.10 Fixes: f1c131b ("crypto: xts - Convert to skcipher") Reported-by: Harald Freudenberger <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 016df0a commit 8902757

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

crypto/xts.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
463463
struct xts_instance_ctx *ctx;
464464
struct skcipher_alg *alg;
465465
const char *cipher_name;
466+
u32 mask;
466467
int err;
467468

468469
algt = crypto_get_attr_type(tb);
@@ -483,18 +484,19 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
483484
ctx = skcipher_instance_ctx(inst);
484485

485486
crypto_set_skcipher_spawn(&ctx->spawn, skcipher_crypto_instance(inst));
486-
err = crypto_grab_skcipher(&ctx->spawn, cipher_name, 0,
487-
crypto_requires_sync(algt->type,
488-
algt->mask));
487+
488+
mask = crypto_requires_off(algt->type, algt->mask,
489+
CRYPTO_ALG_NEED_FALLBACK |
490+
CRYPTO_ALG_ASYNC);
491+
492+
err = crypto_grab_skcipher(&ctx->spawn, cipher_name, 0, mask);
489493
if (err == -ENOENT) {
490494
err = -ENAMETOOLONG;
491495
if (snprintf(ctx->name, CRYPTO_MAX_ALG_NAME, "ecb(%s)",
492496
cipher_name) >= CRYPTO_MAX_ALG_NAME)
493497
goto err_free_inst;
494498

495-
err = crypto_grab_skcipher(&ctx->spawn, ctx->name, 0,
496-
crypto_requires_sync(algt->type,
497-
algt->mask));
499+
err = crypto_grab_skcipher(&ctx->spawn, ctx->name, 0, mask);
498500
}
499501

500502
if (err)

0 commit comments

Comments
 (0)