From 64ec50fa86d6fa4397c8bcc8b89af18658d8d35c Mon Sep 17 00:00:00 2001 From: Cristian Stoica Date: Fri, 28 Jun 2013 15:56:20 +0300 Subject: crypto: fix typo in comment Signed-off-by: Cristian Stoica Signed-off-by: Jiri Kosina --- crypto/api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crypto/api.c') diff --git a/crypto/api.c b/crypto/api.c index 3b618033..320ea4d8 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -391,7 +391,7 @@ EXPORT_SYMBOL_GPL(__crypto_alloc_tfm); * @mask: Mask for type comparison * * This function should not be used by new algorithm types. - * Plesae use crypto_alloc_tfm instead. + * Please use crypto_alloc_tfm instead. * * crypto_alloc_base() will first attempt to locate an already loaded * algorithm. If that fails and the kernel supports dynamically loadable -- cgit v1.2.3 From ab1e03aa3491739b223aeef5878dc4bac6ee807f Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Sun, 8 Sep 2013 14:33:50 +1000 Subject: crypto: api - Fix race condition in larval lookup crypto_larval_lookup should only return a larval if it created one. Any larval created by another entity must be processed through crypto_larval_wait before being returned. Otherwise this will lead to a larval being killed twice, which will most likely lead to a crash. Cc: stable@vger.kernel.org Reported-by: Kees Cook Tested-by: Kees Cook Signed-off-by: Herbert Xu --- crypto/api.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'crypto/api.c') diff --git a/crypto/api.c b/crypto/api.c index 320ea4d8..a2b39c5f 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -34,6 +34,8 @@ EXPORT_SYMBOL_GPL(crypto_alg_sem); BLOCKING_NOTIFIER_HEAD(crypto_chain); EXPORT_SYMBOL_GPL(crypto_chain); +static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg); + struct crypto_alg *crypto_mod_get(struct crypto_alg *alg) { return try_module_get(alg->cra_module) ? crypto_alg_get(alg) : NULL; @@ -144,8 +146,11 @@ static struct crypto_alg *crypto_larval_add(const char *name, u32 type, } up_write(&crypto_alg_sem); - if (alg != &larval->alg) + if (alg != &larval->alg) { kfree(larval); + if (crypto_is_larval(alg)) + alg = crypto_larval_wait(alg); + } return alg; } -- cgit v1.2.3