crypto: Fix algorithm and driver duplicate registered
PATCH 1/1 crypto: Fix algorithm and driver duplicate registered
Current kernel, All the algorithms with same algorithm name and driver name are registered.
But the proper behaviour should be only one algorithm be registered when algorithm and driver name duplicate.
---
crypto/algapi.c +2 -2
@@ -207,8 +207,8 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)continue ; } -if (!strcmp (q->cra_driver_name, alg->cra_name) || - !strcmp (q->cra_name, alg->cra_driver_name)) +if (!strcmp (q->cra_driver_name, alg->cra_driver_name) && + !strcmp (q->cra_name, alg->cra_name)) goto err; }
Herbert Xu
maintainerQuoted 6 lines · Youquan,Song
Current kernel, All the algorithms with same algorithm name and driver name are registered.
But the proper behaviour should be only one algorithm be registered when algorithm and driver name duplicate.Signed-off-by Youquan, Song <[email protected]>
This is intentional, in order to allow older implementations to be replaced on the fly.
Is this causing any issues for you?
Cheers,
Signature · 4 lines
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.txtQuoted 6 lines · Herbert Xu
Quoted 5 lines · Youquan,Song
Current kernel, All the algorithms with same algorithm name and driver name are registered.
But the proper behaviour should be only one algorithm be registered when algorithm and driver name duplicate.
Quoted 6 lines
Quoted 1 line
Signed-off-by Youquan, Song <[email protected]>This is intentional, in order to allow older implementations to be replaced on the fly.
Is this causing any issues for you?
I have watched crypto_alg_list includes several duplicate algorithms with same algorithm name and driver name.
Since they are the same algorithms, one is only needed. otherwise,it will make some confusion.
Thanks.
Herbert Xu
maintainerQuoted 5 lines · Youquan,Song
I have watched
crypto_alg_listincludes several duplicate algorithms with same algorithm name and driver name.
Since they are the same algorithms, one is only needed. otherwise,it will make some confusion.
Can you show me a sample /proc/crypto showing this problem and how you created it?
Thanks,
Signature · 4 lines
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.txtQuoted 3 lines
Can you show me a sample
/proc/cryptoshowing this problem and how you created it?
Sorry for late. I use the cryptodev-2.6 tree, enable AESNI and PCLMULQDQ NI.
Step: like this.
A. modprobe tcrypt mode=35
B. modprobe aesni-intel
C. modprobe tcrypt mode=35
After I do A. Because it do not load aesni-intel, so I do B, then repeat C.
cat /proc/crypto.
there is two identical gcm:
name : gcm(aes)
driver : gcm_base(ctr-aes-aesni,ghash-clmulni)
module : gcm
priority : 400
refcnt : 1
selftest : unknown
type : aead
async : yes
blocksize : 1
ivsize : 16
maxauthsize : 16
geniv : <built-in>
name : gcm(aes)
driver : gcm_base(ctr-aes-aesni,ghash-clmulni)
module : gcm
priority : 400
refcnt : 1
selftest : unknown
type : aead
async : yes
blocksize : 1
ivsize : 16
maxauthsize : 16
geniv : <built-in>
name : fpu(ctr(__aes-aesni))
driver : cryptd(fpu(ctr(__driver-aes-aesni)))
module : cryptd
priority : 50
refcnt : 1
selftest : passed
type : ablkcipher
async : yes
blocksize : 1
min keysize : 16
max keysize : 32
ivsize : 16
geniv : <default>
name : fpu(ctr(__aes-aesni))
driver : fpu(ctr(__driver-aes-aesni))
module : fpu
priority : 0
refcnt : 1
selftest : passed
type : blkcipher
blocksize : 1
min keysize : 16
max keysize : 32
ivsize : 16
Herbert Xu
maintainerQuoted 12 lines · Youquan,Song
Sorry for late. I use the cryptodev-2.6 tree, enable AESNI and PCLMULQDQ NI.
Step: like this.
A. modprobe tcrypt mode=35
B. modprobe aesni-intel
C. modprobe tcrypt mode=35After I do A. Because it do not load aesni-intel, so I do B, then repeat C.
cat
/proc/crypto.
Quoted 8 lines
there is two identical gcm:
name : gcm(aes)
driver :gcm_base(ctr-aes-aesni,ghash-clmulni)
module : gcm
priority : 400
refcnt : 1
selftest : unknown
It's creating a second copy because the first one failed the self-test.
So you should try to identify the reason for the failed self-test.
Cheers,
Signature · 4 lines
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.txtQuoted 7 lines · Herbert Xu
Quoted 5 lines · Youquan,Song
I have watched
crypto_alg_listincludes several duplicate algorithms with same algorithm name and driver name.
Since they are the same algorithms, one is only needed. otherwise,it will make some confusion.
Hi Herbert,
The alg->cra_name and alg->cra_driver_name, from the description, cra_name is the algorithm name and cra_driver_name is the driver name. But when I read the code, I often get confuse about these two names. They often mix each other.
Can you give me some instruction about them? or Can we make them more clear? Thanks.
-Youquan
Herbert Xu
maintainerQuoted 3 lines · Youquan,Song
The
alg->cra_nameandalg->cra_driver_name, from the description,cra_nameis the algorithm name andcra_driver_nameis the driver name.
For each algorithm you may have an arbitrary number of drivers implementing it. The driver name must be unique. However, duplicates are allowed so that a new version of a driver may be loaded while the older instances of it are still in use.
Quoted 4 lines
But when I read the code, I often get confuse about these two names. They often mix each other.
Can you give me some instruction about them? or Can we make them more clear? Thanks.
Well can you tell me what exactly confuses you?
Cheers,
Signature · 4 lines
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.txtQuoted 10 lines · Youquan,Song
Quoted 3 lines
The
alg->cra_nameandalg->cra_driver_name, from the description,cra_nameis the algorithm name andcra_driver_nameis the driver name.For each algorithm you may have an arbitrary number of drivers implementing it. The driver name must be unique. However, duplicates are allowed so that a new version of a driver may be loaded while the older instances of it are still in use.
Quoted 6 lines
Quoted 4 lines
But when I read the code, I often get confuse about these two names. They often mix each other.
Can you give me some instruction about them? or Can we make them more clear? Thanks.
Well can you tell me what exactly confuses you?
Thanks.
For example:
struct crypto_alg *crypto_larval_lookup(const char *name, u32 type, u32 mask)
The parameter "name", sometime it is "alg->cra_name" while sometime it become "alg->cra_driver_name". What's to lookup, algorithm or driver, depends on the context of parameter, So it need confirm no duplicate name exists between cra_driver_name and cra_name. Therefore, there are some werid checking needed, such as following:
if (!strcmp(q->cra_driver_name, alg->cra_name) ||
!strcmp(q->cra_name, alg->cra_driver_name))I wonder, Can we define two functions: one lookup algorithm other lookup driver? It will be more clear.
Thanks.
Herbert Xu
maintainerQuoted 12 lines · Youquan,Song
For example:
struct
crypto_alg*crypto_larval_lookup(const char *name, u32 type, u32 mask)The parameter "name", sometime it is "
alg->cra_name" while sometime it become "alg->cra_driver_name". What's to lookup, algorithm or driver, depends on the context of parameter, So it need confirm no duplicate name exists betweencra_driver_nameandcra_name. Therefore, there are some werid checking needed, such as following:
Quoted 6 lines
if (!strcmp(q->cra_driver_name, alg->cra_name) || !strcmp(q->cra_name, alg->cra_driver_name))I wonder, Can we define two functions: one lookup algorithm other lookup driver? It will be more clear.
No that would defeat the whole point of having algorithm names vs. driver names. When you perform a lookup, we will look for both algorithm matches AND driver matches. Exactly which one takes precedence when two matches are present is determined by the priority.
Anyway, none of this matters to you if you're just working with driver implementations so don't even worry about this.
Cheers,
Signature · 4 lines
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