diff options
author | Eric Biggers <ebiggers@google.com> | 2019-01-06 15:46:05 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-01-10 08:37:31 -0500 |
commit | 6db43410179bc40419a9859ebb333f178a49829d (patch) | |
tree | a54c32b7655a47c8c8a45604b45d65f3990a0a3c | |
parent | 06bbf753476dab23eb262cb5fbab6d6d277a0ba3 (diff) |
crypto: adiantum - initialize crypto_spawn::inst
crypto_grab_*() doesn't set crypto_spawn::inst, so templates must set it
beforehand. Otherwise it will be left NULL, which causes a crash in
certain cases where algorithms are dynamically loaded/unloaded. E.g.
with CONFIG_CRYPTO_CHACHA20_X86_64=m, the following caused a crash:
insmod chacha-x86_64.ko
python -c 'import socket; socket.socket(socket.AF_ALG, 5, 0).bind(("skcipher", "adiantum(xchacha12,aes)"))'
rmmod chacha-x86_64.ko
python -c 'import socket; socket.socket(socket.AF_ALG, 5, 0).bind(("skcipher", "adiantum(xchacha12,aes)"))'
Fixes: 059c2a4d8e16 ("crypto: adiantum - add Adiantum support")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | crypto/adiantum.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crypto/adiantum.c b/crypto/adiantum.c index 6651e713c45d..5564e73266a6 100644 --- a/crypto/adiantum.c +++ b/crypto/adiantum.c | |||
@@ -539,6 +539,8 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb) | |||
539 | ictx = skcipher_instance_ctx(inst); | 539 | ictx = skcipher_instance_ctx(inst); |
540 | 540 | ||
541 | /* Stream cipher, e.g. "xchacha12" */ | 541 | /* Stream cipher, e.g. "xchacha12" */ |
542 | crypto_set_skcipher_spawn(&ictx->streamcipher_spawn, | ||
543 | skcipher_crypto_instance(inst)); | ||
542 | err = crypto_grab_skcipher(&ictx->streamcipher_spawn, streamcipher_name, | 544 | err = crypto_grab_skcipher(&ictx->streamcipher_spawn, streamcipher_name, |
543 | 0, crypto_requires_sync(algt->type, | 545 | 0, crypto_requires_sync(algt->type, |
544 | algt->mask)); | 546 | algt->mask)); |
@@ -547,6 +549,8 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb) | |||
547 | streamcipher_alg = crypto_spawn_skcipher_alg(&ictx->streamcipher_spawn); | 549 | streamcipher_alg = crypto_spawn_skcipher_alg(&ictx->streamcipher_spawn); |
548 | 550 | ||
549 | /* Block cipher, e.g. "aes" */ | 551 | /* Block cipher, e.g. "aes" */ |
552 | crypto_set_spawn(&ictx->blockcipher_spawn, | ||
553 | skcipher_crypto_instance(inst)); | ||
550 | err = crypto_grab_spawn(&ictx->blockcipher_spawn, blockcipher_name, | 554 | err = crypto_grab_spawn(&ictx->blockcipher_spawn, blockcipher_name, |
551 | CRYPTO_ALG_TYPE_CIPHER, CRYPTO_ALG_TYPE_MASK); | 555 | CRYPTO_ALG_TYPE_CIPHER, CRYPTO_ALG_TYPE_MASK); |
552 | if (err) | 556 | if (err) |