diff options
author | Eric Biggers <ebiggers@google.com> | 2019-06-03 01:40:58 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-06-13 02:31:40 -0400 |
commit | 177f87d063ebc7a11a38bdafaca8fec4a9dae13e (patch) | |
tree | c9a8a882acbe5b95e57768e89a643053b3b824b8 | |
parent | d6ebf5286f8f94a254a8c90d4b9f2a8b076a8634 (diff) |
crypto: algapi - require cra_name and cra_driver_name
Now that all algorithms explicitly set cra_driver_name, make it required
for algorithm registration and remove the code that generated a default
cra_driver_name.
Also add an explicit check that cra_name is set too, since that's
obviously required too, yet it didn't seem to be checked anywhere.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | crypto/algapi.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c index 7c51f45d1cf1..5278e139a161 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c | |||
@@ -26,23 +26,6 @@ | |||
26 | 26 | ||
27 | static LIST_HEAD(crypto_template_list); | 27 | static LIST_HEAD(crypto_template_list); |
28 | 28 | ||
29 | static inline int crypto_set_driver_name(struct crypto_alg *alg) | ||
30 | { | ||
31 | static const char suffix[] = "-generic"; | ||
32 | char *driver_name = alg->cra_driver_name; | ||
33 | int len; | ||
34 | |||
35 | if (*driver_name) | ||
36 | return 0; | ||
37 | |||
38 | len = strlcpy(driver_name, alg->cra_name, CRYPTO_MAX_ALG_NAME); | ||
39 | if (len + sizeof(suffix) > CRYPTO_MAX_ALG_NAME) | ||
40 | return -ENAMETOOLONG; | ||
41 | |||
42 | memcpy(driver_name + len, suffix, sizeof(suffix)); | ||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | static inline void crypto_check_module_sig(struct module *mod) | 29 | static inline void crypto_check_module_sig(struct module *mod) |
47 | { | 30 | { |
48 | if (fips_enabled && mod && !module_sig_ok(mod)) | 31 | if (fips_enabled && mod && !module_sig_ok(mod)) |
@@ -54,6 +37,9 @@ static int crypto_check_alg(struct crypto_alg *alg) | |||
54 | { | 37 | { |
55 | crypto_check_module_sig(alg->cra_module); | 38 | crypto_check_module_sig(alg->cra_module); |
56 | 39 | ||
40 | if (!alg->cra_name[0] || !alg->cra_driver_name[0]) | ||
41 | return -EINVAL; | ||
42 | |||
57 | if (alg->cra_alignmask & (alg->cra_alignmask + 1)) | 43 | if (alg->cra_alignmask & (alg->cra_alignmask + 1)) |
58 | return -EINVAL; | 44 | return -EINVAL; |
59 | 45 | ||
@@ -79,7 +65,7 @@ static int crypto_check_alg(struct crypto_alg *alg) | |||
79 | 65 | ||
80 | refcount_set(&alg->cra_refcnt, 1); | 66 | refcount_set(&alg->cra_refcnt, 1); |
81 | 67 | ||
82 | return crypto_set_driver_name(alg); | 68 | return 0; |
83 | } | 69 | } |
84 | 70 | ||
85 | static void crypto_free_instance(struct crypto_instance *inst) | 71 | static void crypto_free_instance(struct crypto_instance *inst) |