2009-04-20 22:14:52

by Chuck Ebbert

[permalink] [raw]
Subject: VIA Padlock driver no longer loads automatically

On x86 machines only aes_generic and aes_i586 get loaded automatically as of
kernel 2.6.29. Looks like this was caused by:

commit a760a6656e6f00bb0144a42a048cf0266646e22c
crypto: api - Fix module load deadlock with fallback algorithms

diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
index c42cd89..6118890 100644
--- a/arch/s390/crypto/aes_s390.c
+++ b/arch/s390/crypto/aes_s390.c
@@ -556,7 +556,7 @@ static void __exit aes_s390_fini(void)
module_init(aes_s390_init);
module_exit(aes_s390_fini);

-MODULE_ALIAS("aes");
+MODULE_ALIAS("aes-all");

MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm");
MODULE_LICENSE("GPL");
diff --git a/crypto/api.c b/crypto/api.c
index efe77df..38a2bc0 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -215,8 +215,19 @@ struct crypto_alg *crypto_larval_lookup(const char *name, u32 type, u32 mask)
mask &= ~(CRYPTO_ALG_LARVAL | CRYPTO_ALG_DEAD);
type &= mask;

- alg = try_then_request_module(crypto_alg_lookup(name, type, mask),
- name);
+ alg = crypto_alg_lookup(name, type, mask);
+ if (!alg) {
+ char tmp[CRYPTO_MAX_ALG_NAME];
+
+ request_module(name);
+
+ if (!((type ^ CRYPTO_ALG_NEED_FALLBACK) & mask) &&
+ snprintf(tmp, sizeof(tmp), "%s-all", name) < sizeof(tmp))
+ request_module(tmp);
+
+ alg = crypto_alg_lookup(name, type, mask);
+ }
+
if (alg)
return crypto_is_larval(alg) ? crypto_larval_wait(alg) : alg;

diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index 856b3cc..3f0fdd1 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -489,4 +489,4 @@ MODULE_DESCRIPTION("VIA PadLock AES algorithm support");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Michal Ludvig");

-MODULE_ALIAS("aes");
+MODULE_ALIAS("aes-all");
diff --git a/drivers/crypto/padlock-sha.c b/drivers/crypto/padlock-sha.c
index a7fbade..a2c8e85 100644
--- a/drivers/crypto/padlock-sha.c
+++ b/drivers/crypto/padlock-sha.c
@@ -304,7 +304,7 @@ MODULE_DESCRIPTION("VIA PadLock SHA1/SHA256 algorithms support.");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Michal Ludvig");

-MODULE_ALIAS("sha1");
-MODULE_ALIAS("sha256");
+MODULE_ALIAS("sha1-all");
+MODULE_ALIAS("sha256-all");
MODULE_ALIAS("sha1-padlock");
MODULE_ALIAS("sha256-padlock");


2009-04-21 05:53:46

by Herbert Xu

[permalink] [raw]
Subject: Re: VIA Padlock driver no longer loads automatically

On Mon, Apr 20, 2009 at 06:14:02PM -0400, Chuck Ebbert wrote:
> On x86 machines only aes_generic and aes_i586 get loaded automatically as of
> kernel 2.6.29. Looks like this was caused by:
>
> commit a760a6656e6f00bb0144a42a048cf0266646e22c
> crypto: api - Fix module load deadlock with fallback algorithms

Thanks for the report. This patch should fix the problem.

commit 37fc334cc8eb84f5fe0a5a1cbe6a6a68049e142a
Author: Herbert Xu <[email protected]>
Date: Tue Apr 21 13:27:16 2009 +0800

crypto: api - Fix algorithm module auto-loading

The commit a760a6656e6f00bb0144a42a048cf0266646e22c (crypto:
api - Fix module load deadlock with fallback algorithms) broke
the auto-loading of algorithms that require fallbacks. The
problem is that the fallback mask check is missing an and which
cauess bits that should be considered to interfere with the
result.

Reported-by: Chuck Ebbert <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>

diff --git a/crypto/api.c b/crypto/api.c
index 314dab9..fd2545d 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -221,7 +221,8 @@ struct crypto_alg *crypto_larval_lookup(const char *name, u32 type, u32 mask)

request_module(name);

- if (!((type ^ CRYPTO_ALG_NEED_FALLBACK) & mask) &&
+ if (!((type ^ CRYPTO_ALG_NEED_FALLBACK) & mask &
+ CRYPTO_ALG_NEED_FALLBACK) &&
snprintf(tmp, sizeof(tmp), "%s-all", name) < sizeof(tmp))
request_module(tmp);

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2009-04-21 05:56:26

by Herbert Xu

[permalink] [raw]
Subject: Re: VIA Padlock driver no longer loads automatically

On Tue, Apr 21, 2009 at 01:53:31PM +0800, Herbert Xu wrote:
>
> Thanks for the report. This patch should fix the problem.

In fact, padlock-aes shouldn't have been aes-all in the first
place so I'm going to add tihs patch too.

commit acd246b7494c629aa617da49716409566cf52149
Author: Herbert Xu <[email protected]>
Date: Tue Apr 21 13:55:20 2009 +0800

crypto: padlock - Revert aes-all alias to aes

Since the padlock-aes driver doesn't require a fallback (it's
only padlock-sha that does), it should use the aes alias rather
than aes-all so that ones that do need a fallback can use it.

Signed-off-by: Herbert Xu <[email protected]>

diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index 3f0fdd1..856b3cc 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -489,4 +489,4 @@ MODULE_DESCRIPTION("VIA PadLock AES algorithm support");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Michal Ludvig");

-MODULE_ALIAS("aes-all");
+MODULE_ALIAS("aes");

Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Subject: Re: VIA Padlock driver no longer loads automatically

* Herbert Xu | 2009-04-21 13:56:13 [+0800]:

>On Tue, Apr 21, 2009 at 01:53:31PM +0800, Herbert Xu wrote:
>>
>> Thanks for the report. This patch should fix the problem.
>
>In fact, padlock-aes shouldn't have been aes-all in the first
>place so I'm going to add tihs patch too.
You changed all algos which need fallback to *-all to get them
probed/loaded after the generic algorithm. The same load/fallback/test
pattern exist for the s390 aes for instance. Should it be renamed as
well?

>commit acd246b7494c629aa617da49716409566cf52149
>Author: Herbert Xu <[email protected]>
>Date: Tue Apr 21 13:55:20 2009 +0800
>
> crypto: padlock - Revert aes-all alias to aes
>
> Since the padlock-aes driver doesn't require a fallback (it's
> only padlock-sha that does), it should use the aes alias rather
> than aes-all so that ones that do need a fallback can use it.
>
> Signed-off-by: Herbert Xu <[email protected]>
>
>diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
>index 3f0fdd1..856b3cc 100644
>--- a/drivers/crypto/padlock-aes.c
>+++ b/drivers/crypto/padlock-aes.c
>@@ -489,4 +489,4 @@ MODULE_DESCRIPTION("VIA PadLock AES algorithm support");
> MODULE_LICENSE("GPL");
> MODULE_AUTHOR("Michal Ludvig");
>
>-MODULE_ALIAS("aes-all");
>+MODULE_ALIAS("aes");
>
>Thanks,
>--

Sebastian

2009-04-21 10:53:45

by Herbert Xu

[permalink] [raw]
Subject: Re: VIA Padlock driver no longer loads automatically

On Tue, Apr 21, 2009 at 10:26:45AM +0200, Sebastian Andrzej Siewior wrote:
>
> You changed all algos which need fallback to *-all to get them
> probed/loaded after the generic algorithm. The same load/fallback/test
> pattern exist for the s390 aes for instance. Should it be renamed as
> well?

It was already renamed in the original patch. The problem here
is that padlock-aes was incorrectly renamed as it doesn't require
a fallback.

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Subject: Re: VIA Padlock driver no longer loads automatically

* Herbert Xu | 2009-04-21 18:53:27 [+0800]:

>It was already renamed in the original patch. The problem here
>is that padlock-aes was incorrectly renamed as it doesn't require
>a fallback.

Right, just key computation which is not part of the crypto API.

>Cheers,
>--

Sebastian