Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH] crypto: fix larval lookup
@ 2008-08-18  7:02 Christian Hohnstaedt
  2008-08-19  5:05 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Hohnstaedt @ 2008-08-18  7:02 UTC (permalink / raw)
  To: Herbert Xu; +Cc: Crypto Mailing List


crypto_alg_mod_lookup() runs in a timeout (60s) for unknown algos.

crypto_larval_error() doesn't find the larval and thus doesn't
finish crypto_larval_wait, because
the larval->mask has the CRYPTO_ALG_TESTED bit set, while
crypto_alg_lookup() is called without that bit in the mask
and the mask comparison in __crypto_alg_lookup fails.

Since larvals itself never get tested, it seems ok to 
reset that bit.

Signed-off-by: Christian Hohnstaedt <chohnstaedt@innominate.com>
---
 crypto/api.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/crypto/api.c b/crypto/api.c
index cd232d4..0a4012e 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -118,7 +118,7 @@ struct crypto_larval *crypto_larval_alloc(const char *name, u32 type, u32 mask)
 	if (!larval)
 		return ERR_PTR(-ENOMEM);
 
-	larval->mask = mask;
+	larval->mask = mask & ~CRYPTO_ALG_TESTED;
 	larval->alg.cra_flags = CRYPTO_ALG_LARVAL | type;
 	larval->alg.cra_priority = -1;
 	larval->alg.cra_destroy = crypto_larval_destroy;
-- 
1.5.6.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: fix larval lookup
  2008-08-18  7:02 [PATCH] crypto: fix larval lookup Christian Hohnstaedt
@ 2008-08-19  5:05 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2008-08-19  5:05 UTC (permalink / raw)
  To: Christian Hohnstaedt; +Cc: herbert, linux-crypto

Christian Hohnstaedt <christian@hohnstaedt.de> wrote:
> 
> crypto_alg_mod_lookup() runs in a timeout (60s) for unknown algos.
> 
> crypto_larval_error() doesn't find the larval and thus doesn't
> finish crypto_larval_wait, because
> the larval->mask has the CRYPTO_ALG_TESTED bit set, while
> crypto_alg_lookup() is called without that bit in the mask
> and the mask comparison in __crypto_alg_lookup fails.
> 
> Since larvals itself never get tested, it seems ok to 
> reset that bit.
> 
> Signed-off-by: Christian Hohnstaedt <chohnstaedt@innominate.com>

Thanks for catching this! However, we do want to keep the TESTED
bit in case someone specifically requests for an untested algorithm.

So I'm going to fix it as follows, by using the original type
and mask for error propagation.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff --git a/crypto/algboss.c b/crypto/algboss.c
index a635784..d6dc18f 100644
--- a/crypto/algboss.c
+++ b/crypto/algboss.c
@@ -45,6 +45,9 @@ struct cryptomgr_param {
 
 	char larval[CRYPTO_MAX_ALG_NAME];
 	char template[CRYPTO_MAX_ALG_NAME];
+
+	u32 otype;
+	u32 omask;
 };
 
 struct crypto_test_param {
@@ -82,8 +85,7 @@ out:
 	module_put_and_exit(0);
 
 err:
-	crypto_larval_error(param->larval, param->type.data.type,
-			    param->type.data.mask);
+	crypto_larval_error(param->larval, param->otype, param->omask);
 	goto out;
 }
 
@@ -179,6 +181,9 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
 	param->type.data.mask = larval->mask & ~CRYPTO_ALG_TESTED;
 	param->tb[0] = &param->type.attr;
 
+	param->otype = larval->alg.cra_flags;
+	param->omask = larval->mask;
+
 	memcpy(param->larval, larval->alg.cra_name, CRYPTO_MAX_ALG_NAME);
 
 	thread = kthread_run(cryptomgr_probe, param, "cryptomgr_probe");

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-19  5:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-18  7:02 [PATCH] crypto: fix larval lookup Christian Hohnstaedt
2008-08-19  5:05 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox