Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Eric Biggers and committed by
Herbert Xu
177f87d0 d6ebf528

+4 -18
+4 -18
crypto/algapi.c
··· 26 26 27 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 29 static inline void crypto_check_module_sig(struct module *mod) 47 30 { 48 31 if (fips_enabled && mod && !module_sig_ok(mod)) ··· 36 53 static int crypto_check_alg(struct crypto_alg *alg) 37 54 { 38 55 crypto_check_module_sig(alg->cra_module); 56 + 57 + if (!alg->cra_name[0] || !alg->cra_driver_name[0]) 58 + return -EINVAL; 39 59 40 60 if (alg->cra_alignmask & (alg->cra_alignmask + 1)) 41 61 return -EINVAL; ··· 65 79 66 80 refcount_set(&alg->cra_refcnt, 1); 67 81 68 - return crypto_set_driver_name(alg); 82 + return 0; 69 83 } 70 84 71 85 static void crypto_free_instance(struct crypto_instance *inst)