summaryrefslogtreecommitdiff
authorEric Biggers <ebiggers@google.com>2019-01-06 20:46:05 (GMT)
committer Eric Biggers <ebiggers@google.com>2019-01-18 20:43:35 (GMT)
commit1070b235af4633f9bac36d93db2af61e39e4fa0c (patch)
tree7125f153ef629a3899d5f867a8448f128c0c3324
parentb05264180a4d16c5b95cba9e66db33b06c68f032 (diff)
downloadcommon-1070b235af4633f9bac36d93db2af61e39e4fa0c.zip
common-1070b235af4633f9bac36d93db2af61e39e4fa0c.tar.gz
common-1070b235af4633f9bac36d93db2af61e39e4fa0c.tar.bz2
UPSTREAM: 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> (cherry picked from commit 6db43410179bc40419a9859ebb333f178a49829d) Test: Adiantum self-tests Change-Id: I248548c979b0ee9e63a35f8ae779741bb5967b6e
Diffstat
-rw-r--r--crypto/adiantum.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/crypto/adiantum.c b/crypto/adiantum.c
index 6651e71..5564e73 100644
--- a/crypto/adiantum.c
+++ b/crypto/adiantum.c
@@ -539,6 +539,8 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
ictx = skcipher_instance_ctx(inst);
/* Stream cipher, e.g. "xchacha12" */
+ crypto_set_skcipher_spawn(&ictx->streamcipher_spawn,
+ skcipher_crypto_instance(inst));
err = crypto_grab_skcipher(&ictx->streamcipher_spawn, streamcipher_name,
0, crypto_requires_sync(algt->type,
algt->mask));
@@ -547,6 +549,8 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
streamcipher_alg = crypto_spawn_skcipher_alg(&ictx->streamcipher_spawn);
/* Block cipher, e.g. "aes" */
+ crypto_set_spawn(&ictx->blockcipher_spawn,
+ skcipher_crypto_instance(inst));
err = crypto_grab_spawn(&ictx->blockcipher_spawn, blockcipher_name,
CRYPTO_ALG_TYPE_CIPHER, CRYPTO_ALG_TYPE_MASK);
if (err)