Remove unused support for crypto tfm cloning
Subsystems (3)
cover Remove unused support for crypto tfm cloning
This series is targeting net-next because it depends on "net/tcp: Remove tcp_sigpool". So far no commits in cryptodev conflict with this, so I suggest that this be taken through net-next for 7.2.
This series removes support for transformation cloning from the crypto API. Now that the TCP-AO and TCP-MD5 code no longer uses it, it no longer has a user. And it's unlikely that a new one will appear, as the library API solves the problem in a much simpler and more efficient way.
This feature also regressed performance for all crypto API users, since it changed crypto transformation objects into reference-counted objects. That added expensive atomic operations. The refcount is reverted by this series, thus fixing the performance regression.
A subset of this was previously sent in
https://lore.kernel.org/r/[email protected]
Compared to that version, this version is a bit more comprehensive.
Eric Biggers (6):
crypto: hash - Remove support for cloning hash tfms
crypto: cipher - Remove crypto_clone_cipher()
crypto: api - Remove crypto_clone_tfm()
crypto: api - Remove per-tfm refcount
crypto: api - Fold __crypto_alloc_tfmgfp() into __crypto_alloc_tfm()
crypto: api - Fold crypto_alloc_tfmmem() into crypto_create_tfm_node()
crypto/ahash.c | 70 ----------------------------- crypto/api.c | 76 +++++--------------------------- crypto/cipher.c | 28 ------------ crypto/cmac.c | 16 ------- crypto/cryptd.c | 16 ------- crypto/hmac.c | 31 ------------- crypto/internal.h | 10 ----- crypto/shash.c | 37 ---------------- include/crypto/hash.h | 8 ---- include/crypto/internal/cipher.h | 2 - include/linux/crypto.h | 1 - 11 files changed, 10 insertions(+), 285 deletions(-)
base-commit: 1a1f055318d82e64485a6ff8420e5f70b4267998
Signature · 1 line
2.54.0
PATCH 1/6 crypto: hash - Remove support for cloning hash tfms
Hash transformation cloning no longer has a user, and there's a good chance no new one will appear because the library API solves the problem in a much simpler and more efficient way. Remove support for it.
Note that no tests need to be removed, as this feature had no tests.
--- crypto/ahash.c | 70 ------------------------------------------- crypto/cmac.c | 16 ---------- crypto/cryptd.c | 16 ---------- crypto/hmac.c | 31 ------------------- crypto/shash.c | 37 ----------------------- include/crypto/hash.h | 8 ----- 6 files changed, 178 deletions(-)
crypto/ahash.c +0 -70
@@ -860,80 +860,10 @@ bool crypto_hash_alg_has_setkey(struct hash_alg_common *halg)return __crypto_ahash_alg (alg)->setkey != ahash_nosetkey; }EXPORT_SYMBOL_GPL (crypto_hash_alg_has_setkey); -struct crypto_ahash *crypto_clone_ahash (struct crypto_ahash *hash) -{ -struct hash_alg_common *halg =crypto_hash_alg_common (hash); -struct crypto_tfm *tfm =crypto_ahash_tfm (hash); -struct crypto_ahash *fb =NULL ; -struct crypto_ahash *nhash; -struct ahash_alg *alg; -int err; - -if (!crypto_hash_alg_has_setkey (halg)) { - tfm =crypto_tfm_get (tfm); -if (IS_ERR (tfm)) -return ERR_CAST (tfm); - -return hash; - } - - nhash =crypto_clone_tfm (&crypto_ahash_type, tfm); - -if (IS_ERR (nhash)) -return nhash; - - nhash->reqsize = hash->reqsize; - nhash->statesize = hash->statesize; - -if (likely (hash->using_shash)) { -struct crypto_shash **nctx =crypto_ahash_ctx (nhash); -struct crypto_shash *shash; - - shash =crypto_clone_shash (ahash_to_shash (hash)); -if (IS_ERR (shash)) { - err =PTR_ERR (shash); - goto out_free_nhash; - } -crypto_ahash_tfm (nhash)->exit = crypto_exit_ahash_using_shash; - nhash->using_shash = true; - *nctx = shash; -return nhash; - } - -if (crypto_ahash_need_fallback (hash)) { - fb =crypto_clone_ahash (crypto_ahash_fb (hash)); - err =PTR_ERR (fb); -if (IS_ERR (fb)) - goto out_free_nhash; - -crypto_ahash_tfm (nhash)->fb =crypto_ahash_tfm (fb); - } - - err = -ENOSYS ; - alg =crypto_ahash_alg (hash); -if (!alg->clone_tfm) - goto out_free_fb; - - err = alg->clone_tfm (nhash, hash); -if (err) - goto out_free_fb; - -crypto_ahash_tfm (nhash)->exit = crypto_ahash_exit_tfm; - -return nhash; - -out_free_fb: -crypto_free_ahash (fb); -out_free_nhash: -crypto_free_ahash (nhash); -return ERR_PTR (err); -} -EXPORT_SYMBOL_GPL (crypto_clone_ahash); -static int ahash_default_export_core (struct ahash_request *req,void *out) {return -ENOSYS ; }
crypto/cmac.c +0 -16
@@ -149,25 +149,10 @@ static int cmac_init_tfm(struct crypto_shash *tfm) ctx->child = cipher;return 0 ; } -static int cmac_clone_tfm (struct crypto_shash *tfm,struct crypto_shash *otfm) -{ -struct cmac_tfm_ctx *octx =crypto_shash_ctx (otfm); -struct cmac_tfm_ctx *ctx =crypto_shash_ctx (tfm); -struct crypto_cipher *cipher; - - cipher =crypto_clone_cipher (octx->child); -if (IS_ERR (cipher)) -return PTR_ERR (cipher); - - ctx->child = cipher; - -return 0 ; -} -static void cmac_exit_tfm (struct crypto_shash *tfm) {struct cmac_tfm_ctx *ctx =crypto_shash_ctx (tfm);crypto_free_cipher (ctx->child); }
@@ -220,11 +205,10 @@ static int cmac_create(struct crypto_template *tmpl, struct rtattr **tb) inst->alg.init = crypto_cmac_digest_init; inst->alg.update = crypto_cmac_digest_update; inst->alg.finup = crypto_cmac_digest_finup; inst->alg.setkey = crypto_cmac_digest_setkey; inst->alg.init_tfm = cmac_init_tfm; - inst->alg.clone_tfm = cmac_clone_tfm; inst->alg.exit_tfm = cmac_exit_tfm; inst->free = shash_free_singlespawn_instance; err =shash_register_instance (tmpl, inst);
crypto/cryptd.c +0 -16
@@ -450,25 +450,10 @@ static int cryptd_hash_init_tfm(struct crypto_ahash *tfm)sizeof (struct cryptd_hash_request_ctx ) + crypto_shash_descsize(hash));return 0 ; } -static int cryptd_hash_clone_tfm (struct crypto_ahash *ntfm, -struct crypto_ahash *tfm) -{ -struct cryptd_hash_ctx *nctx =crypto_ahash_ctx (ntfm); -struct cryptd_hash_ctx *ctx =crypto_ahash_ctx (tfm); -struct crypto_shash *hash; - - hash =crypto_clone_shash (ctx->child); -if (IS_ERR (hash)) -return PTR_ERR (hash); - - nctx->child = hash; -return 0 ; -} -static void cryptd_hash_exit_tfm (struct crypto_ahash *tfm) {struct cryptd_hash_ctx *ctx =crypto_ahash_ctx (tfm);crypto_free_shash (ctx->child);
@@ -698,11 +683,10 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb, inst->alg.halg.digestsize = alg->digestsize; inst->alg.halg.statesize = alg->statesize; inst->alg.halg.base.cra_ctxsize =sizeof (struct cryptd_hash_ctx ); inst->alg.init_tfm = cryptd_hash_init_tfm; - inst->alg.clone_tfm = cryptd_hash_clone_tfm; inst->alg.exit_tfm = cryptd_hash_exit_tfm; inst->alg.init = cryptd_hash_init_enqueue; inst->alg.update = cryptd_hash_update_enqueue; inst->alg.final = cryptd_hash_final_enqueue;
crypto/hmac.c +0 -31
@@ -156,24 +156,10 @@ static int hmac_init_tfm(struct crypto_shash *parent) tctx->hash = hash;return 0 ; } -static int hmac_clone_tfm (struct crypto_shash *dst,struct crypto_shash *src) -{ -struct hmac_ctx *sctx =crypto_shash_ctx (src); -struct hmac_ctx *dctx =crypto_shash_ctx (dst); -struct crypto_shash *hash; - - hash =crypto_clone_shash (sctx->hash); -if (IS_ERR (hash)) -return PTR_ERR (hash); - - dctx->hash = hash; -return 0 ; -} -static void hmac_exit_tfm (struct crypto_shash *parent) {struct hmac_ctx *tctx =crypto_shash_ctx (parent);crypto_free_shash (tctx->hash);
@@ -233,11 +219,10 @@ static int __hmac_create_shash(struct crypto_template *tmpl, inst->alg.import = hmac_import; inst->alg.export_core = hmac_export_core; inst->alg.import_core = hmac_import_core; inst->alg.setkey = hmac_setkey; inst->alg.init_tfm = hmac_init_tfm; - inst->alg.clone_tfm = hmac_clone_tfm; inst->alg.exit_tfm = hmac_exit_tfm; inst->free = shash_free_singlespawn_instance; err =shash_register_instance (tmpl, inst);
@@ -421,25 +406,10 @@ static int hmac_init_ahash_tfm(struct crypto_ahash *parent) tctx->hash = hash;return 0 ; } -static int hmac_clone_ahash_tfm (struct crypto_ahash *dst, -struct crypto_ahash *src) -{ -struct ahash_hmac_ctx *sctx =crypto_ahash_ctx (src); -struct ahash_hmac_ctx *dctx =crypto_ahash_ctx (dst); -struct crypto_ahash *hash; - - hash =crypto_clone_ahash (sctx->hash); -if (IS_ERR (hash)) -return PTR_ERR (hash); - - dctx->hash = hash; -return 0 ; -} -static void hmac_exit_ahash_tfm (struct crypto_ahash *parent) {struct ahash_hmac_ctx *tctx =crypto_ahash_ctx (parent);crypto_free_ahash (tctx->hash);
@@ -501,11 +471,10 @@ static int hmac_create_ahash(struct crypto_template *tmpl, struct rtattr **tb, inst->alg.import = hmac_import_ahash; inst->alg.export_core = hmac_export_core_ahash; inst->alg.import_core = hmac_import_core_ahash; inst->alg.setkey = hmac_setkey_ahash; inst->alg.init_tfm = hmac_init_ahash_tfm; - inst->alg.clone_tfm = hmac_clone_ahash_tfm; inst->alg.exit_tfm = hmac_exit_ahash_tfm; inst->free = ahash_free_singlespawn_instance; err =ahash_register_instance (tmpl, inst);
crypto/shash.c +0 -37
@@ -393,47 +393,10 @@ int crypto_has_shash(const char *alg_name, u32 type, u32 mask) {return crypto_type_has_alg (alg_name, &crypto_shash_type, type, mask); }EXPORT_SYMBOL_GPL (crypto_has_shash); -struct crypto_shash *crypto_clone_shash (struct crypto_shash *hash) -{ -struct crypto_tfm *tfm =crypto_shash_tfm (hash); -struct shash_alg *alg =crypto_shash_alg (hash); -struct crypto_shash *nhash; -int err; - -if (!crypto_shash_alg_has_setkey (alg)) { - tfm =crypto_tfm_get (tfm); -if (IS_ERR (tfm)) -return ERR_CAST (tfm); - -return hash; - } - -if (!alg->clone_tfm && (alg->init_tfm || alg->base.cra_init)) -return ERR_PTR (-ENOSYS ); - - nhash =crypto_clone_tfm (&crypto_shash_type, tfm); -if (IS_ERR (nhash)) -return nhash; - -if (alg->clone_tfm) { - err = alg->clone_tfm (nhash, hash); -if (err) { -crypto_free_shash (nhash); -return ERR_PTR (err); - } - } - -if (alg->exit_tfm) -crypto_shash_tfm (nhash)->exit = crypto_shash_exit_tfm; - -return nhash; -} -EXPORT_SYMBOL_GPL (crypto_clone_shash); -int hash_prepare_alg (struct hash_alg_common *alg) {struct crypto_alg *base = &alg->base;if (alg->digestsize >HASH_MAX_DIGESTSIZE )
include/crypto/hash.h +0 -8
@@ -146,11 +146,10 @@ struct ahash_request {* requirement of the transformation and put any software * fallbacks in place. * @exit_tfm: Deinitialize the cryptographic transformation object. * This is a counterpart to @init_tfm, used to remove * various changes set in @init_tfm. -* @clone_tfm: Copy transform into new object, may allocate memory. * @halg: see struct hash_alg_common */ struct ahash_alg {int (*init)(struct ahash_request *req);int (*update)(struct ahash_request *req);
@@ -163,11 +162,10 @@ struct ahash_alg {int (*import_core)(struct ahash_request *req,const void *in);int (*setkey)(struct crypto_ahash *tfm,const u8 *key,unsigned int keylen);int (*init_tfm)(struct crypto_ahash *tfm);void (*exit_tfm)(struct crypto_ahash *tfm); -int (*clone_tfm)(struct crypto_ahash *dst,struct crypto_ahash *src);struct hash_alg_common halg; };struct shash_desc {
@@ -237,11 +235,10 @@ struct shash_desc {* requirement of the transformation and put any software * fallbacks in place. * @exit_tfm: Deinitialize the cryptographic transformation object. * This is a counterpart to @init_tfm, used to remove * various changes set in @init_tfm. -* @clone_tfm: Copy transform into new object, may allocate memory. * @descsize: Size of the operational state for the message digest. This state * size is the memory size that needs to be allocated for * shash_desc.__ctx * @halg: see struct hash_alg_common * @HASH_ALG_COMMON: see struct hash_alg_common
@@ -261,11 +258,10 @@ struct shash_alg {int (*import_core)(struct shash_desc *desc,const void *in);int (*setkey)(struct crypto_shash *tfm,const u8 *key,unsigned int keylen);int (*init_tfm)(struct crypto_shash *tfm);void (*exit_tfm)(struct crypto_shash *tfm); -int (*clone_tfm)(struct crypto_shash *dst,struct crypto_shash *src);unsigned int descsize;union {struct HASH_ALG_COMMON ;
@@ -320,12 +316,10 @@ static inline struct crypto_ahash *__crypto_ahash_cast(struct crypto_tfm *tfm)* of an error, PTR_ERR() returns the error code. */ struct crypto_ahash *crypto_alloc_ahash (const char *alg_name,u32 type,u32 mask); -struct crypto_ahash *crypto_clone_ahash (struct crypto_ahash *tfm); -static inline struct crypto_tfm *crypto_ahash_tfm (struct crypto_ahash *tfm) {return &tfm->base; }
@@ -757,12 +751,10 @@ static inline void ahash_request_set_virt(struct ahash_request *req,* of an error, PTR_ERR() returns the error code. */ struct crypto_shash *crypto_alloc_shash (const char *alg_name,u32 type,u32 mask); -struct crypto_shash *crypto_clone_shash (struct crypto_shash *tfm); -int crypto_has_shash (const char *alg_name,u32 type,u32 mask);static inline struct crypto_tfm *crypto_shash_tfm (struct crypto_shash *tfm) {return &tfm->base;
Signature · 1 line
2.54.0
PATCH 2/6 crypto: cipher - Remove crypto_clone_cipher()
In reply to Eric BiggersSince the only caller of crypto_clone_cipher() was cmac_clone_tfm() which has been removed, remove crypto_clone_cipher() as well.
Note that no tests need to be removed, as this function had no tests.
--- crypto/cipher.c | 28 ---------------------------- include/crypto/internal/cipher.h | 2 -- 2 files changed, 30 deletions(-)
crypto/cipher.c +0 -28
@@ -87,33 +87,5 @@ void crypto_cipher_decrypt_one(struct crypto_cipher *tfm, u8 *dst, const u8 *src) {cipher_crypt_one (tfm ,dst ,src ,false ); }EXPORT_SYMBOL_NS_GPL (crypto_cipher_decrypt_one,"CRYPTO_INTERNAL" ); - -struct crypto_cipher *crypto_clone_cipher (struct crypto_cipher *cipher) -{ -struct crypto_tfm *tfm =crypto_cipher_tfm (cipher); -struct crypto_alg *alg = tfm->__crt_alg; -struct crypto_cipher *ncipher; -struct crypto_tfm *ntfm; - -if (alg->cra_init) -return ERR_PTR (-ENOSYS ); - -if (unlikely (!crypto_mod_get (alg))) -return ERR_PTR (-ESTALE ); - - ntfm =__crypto_alloc_tfmgfp (alg,CRYPTO_ALG_TYPE_CIPHER , -CRYPTO_ALG_TYPE_MASK ,GFP_ATOMIC ); -if (IS_ERR (ntfm)) { -crypto_mod_put (alg); -return ERR_CAST (ntfm); - } - - ntfm->crt_flags = tfm->crt_flags; - - ncipher =__crypto_cipher_cast (ntfm); - -return ncipher; -} -EXPORT_SYMBOL_GPL (crypto_clone_cipher);
include/crypto/internal/cipher.h +0 -2
@@ -174,12 +174,10 @@ void crypto_cipher_encrypt_one(struct crypto_cipher *tfm,* the plaintext and ciphertext buffers are at least one block in size. */ void crypto_cipher_decrypt_one (struct crypto_cipher *tfm,u8 *dst,const u8 *src); -struct crypto_cipher *crypto_clone_cipher (struct crypto_cipher *cipher); -struct crypto_cipher_spawn {struct crypto_spawn base; }; static inline int crypto_grab_cipher(struct crypto_cipher_spawn *spawn,
Signature · 1 line
2.54.0
PATCH 3/6 crypto: api - Remove crypto_clone_tfm()
In reply to Eric BiggersSince all callers of crypto_clone_tfm() have been removed, remove it.
Note that no tests need to be removed, as this function had no tests.
--- crypto/api.c | 26 -------------------------- crypto/internal.h | 2 -- 2 files changed, 28 deletions(-)
crypto/api.c +0 -26
@@ -558,36 +558,10 @@ void *crypto_create_tfm_node(struct crypto_alg *alg, out:return mem; }EXPORT_SYMBOL_GPL (crypto_create_tfm_node); -void *crypto_clone_tfm (const struct crypto_type *frontend, -struct crypto_tfm *otfm) -{ -struct crypto_alg *alg = otfm->__crt_alg; -struct crypto_tfm *tfm; -char *mem; - - mem =ERR_PTR (-ESTALE ); -if (unlikely (!crypto_mod_get (alg))) - goto out; - - mem =crypto_alloc_tfmmem (alg, frontend, otfm->node,GFP_ATOMIC ); -if (IS_ERR (mem)) { -crypto_mod_put (alg); - goto out; - } - - tfm = (struct crypto_tfm *)(mem + frontend->tfmsize); - tfm->crt_flags = otfm->crt_flags; - tfm->fb = tfm; - -out: -return mem; -} -EXPORT_SYMBOL_GPL (crypto_clone_tfm); -struct crypto_alg *crypto_find_alg (const char *alg_name,const struct crypto_type *frontend,u32 type,u32 mask) {if (frontend) {
crypto/internal.h +0 -2
@@ -124,12 +124,10 @@ struct crypto_tfm *__crypto_alloc_tfmgfp(struct crypto_alg *alg, u32 type, u32 mask, gfp_t gfp);struct crypto_tfm *__crypto_alloc_tfm (struct crypto_alg *alg,u32 type,u32 mask);void *crypto_create_tfm_node (struct crypto_alg *alg,const struct crypto_type *frontend,int node); -void *crypto_clone_tfm (const struct crypto_type *frontend, -struct crypto_tfm *otfm);static inline void *crypto_create_tfm (struct crypto_alg *alg,const struct crypto_type *frontend) {return crypto_create_tfm_node (alg, frontend,NUMA_NO_NODE );
Signature · 1 line
2.54.0
PATCH 4/6 crypto: api - Remove per-tfm refcount
In reply to Eric BiggersThis reverts commit ae131f4970f0 ("crypto: api - Add crypto_tfm_get").
The refcount in struct crypto_tfm was added solely to support crypto_clone_tfm(). Before then it was a simple non-refcounted object.
Since crypto_clone_tfm() has been removed, remove the refcount as well.
Note that this eliminates an expensive atomic operation from every tfm freeing operation. So this revert doesn't just remove unused code, but it also fixes a performance regression.
--- crypto/api.c | 4 ---- crypto/internal.h | 6 ------ include/linux/crypto.h | 1 - 3 files changed, 11 deletions(-)
crypto/api.c +0 -4
@@ -416,11 +416,10 @@ struct crypto_tfm *__crypto_alloc_tfmgfp(struct crypto_alg *alg, u32 type, tfm =kzalloc (tfm_size, gfp);if (tfm ==NULL ) goto out_err; tfm->__crt_alg = alg; -refcount_set (&tfm->refcnt,1 );if (!tfm->exit && alg->cra_init && (err = alg->cra_init (tfm))) goto cra_init_failed; goto out;
@@ -517,11 +516,10 @@ static void *crypto_alloc_tfmmem(struct crypto_alg *alg,return ERR_PTR (-ENOMEM ); tfm = (struct crypto_tfm *)(mem + tfmsize); tfm->__crt_alg = alg; tfm->node = node; -refcount_set (&tfm->refcnt,1 );return mem; } void *crypto_create_tfm_node(struct crypto_alg *alg,
@@ -647,12 +645,10 @@ void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm)struct crypto_alg *alg;if (IS_ERR_OR_NULL (mem))return ; -if (!refcount_dec_and_test (&tfm->refcnt)) -return ; alg = tfm->__crt_alg;if (!tfm->exit && alg->cra_exit) alg->cra_exit (tfm);crypto_exit_ops (tfm);
crypto/internal.h +0 -6
@@ -8,11 +8,10 @@#ifndef _CRYPTO_INTERNAL_H#define _CRYPTO_INTERNAL_H#include <crypto/algapi.h> #include <linux/completion.h> -#include <linux/err.h> #include <linux/jump_label.h> #include <linux/list.h> #include <linux/module.h> #include <linux/notifier.h> #include <linux/numa.h>
@@ -207,12 +206,7 @@ static inline void crypto_yield(u32 flags)static inline int crypto_is_test_larval (struct crypto_larval *larval) {return larval->alg.cra_driver_name[0 ]; } -static inline struct crypto_tfm *crypto_tfm_get (struct crypto_tfm *tfm) -{ -return refcount_inc_not_zero (&tfm->refcnt) ? tfm :ERR_PTR (-EOVERFLOW ); -} -#endif /* _CRYPTO_INTERNAL_H */
include/linux/crypto.h +0 -1
@@ -407,11 +407,10 @@ int crypto_has_alg(const char *name, u32 type, u32 mask);* and core processing logic. Managed via crypto_alloc_*() and * crypto_free_*(), as well as the various helpers below. */ struct crypto_tfm { -refcount_t refcnt;u32 crt_flags;int node;
Signature · 1 line
2.54.0
PATCH 5/6 crypto: api - Fold __crypto_alloc_tfmgfp() into __crypto_alloc_tfm()
In reply to Eric BiggersThis reverts commit fa3b3565f3ac ("crypto: api - Add __crypto_alloc_tfmgfp").
Fold __crypto_alloc_tfmgfp() into its only remaining caller, __crypto_alloc_tfm(). Previously __crypto_alloc_tfmgfp() was called by crypto_clone_cipher(), but crypto_clone_cipher() was removed.
--- crypto/api.c | 13 +++---------- crypto/internal.h | 2 -- 2 files changed, 3 insertions(+), 12 deletions(-)
crypto/api.c +3 -10
@@ -403,19 +403,19 @@ void crypto_shoot_alg(struct crypto_alg *alg) alg->cra_flags |=CRYPTO_ALG_DYING ;up_write (&crypto_alg_sem); }EXPORT_SYMBOL_GPL (crypto_shoot_alg); -struct crypto_tfm *__crypto_alloc_tfmgfp (struct crypto_alg *alg,u32 type, -u32 mask,gfp_t gfp) +struct crypto_tfm *__crypto_alloc_tfm (struct crypto_alg *alg,u32 type, +u32 mask) {struct crypto_tfm *tfm;unsigned int tfm_size;int err = -ENOMEM ; tfm_size =sizeof (*tfm) +crypto_ctxsize (alg, type, mask); - tfm =kzalloc (tfm_size, gfp); + tfm =kzalloc (tfm_size,GFP_KERNEL );if (tfm ==NULL ) goto out_err; tfm->__crt_alg = alg;
@@ -432,17 +432,10 @@ struct crypto_tfm *__crypto_alloc_tfmgfp(struct crypto_alg *alg, u32 type, out_err: tfm =ERR_PTR (err); out:return tfm; } -EXPORT_SYMBOL_GPL (__crypto_alloc_tfmgfp); - -struct crypto_tfm *__crypto_alloc_tfm (struct crypto_alg *alg,u32 type, -u32 mask) -{ -return __crypto_alloc_tfmgfp (alg, type, mask,GFP_KERNEL ); -}EXPORT_SYMBOL_GPL (__crypto_alloc_tfm);/* * crypto_alloc_base - Locate algorithm and allocate transform * @alg_name: Name of algorithm
crypto/internal.h +0 -2
@@ -117,12 +117,10 @@ void crypto_alg_tested(const char *name, int err);void crypto_remove_spawns (struct crypto_alg *alg,struct list_head *list,struct crypto_alg *nalg);void crypto_remove_final (struct list_head *list);void crypto_shoot_alg (struct crypto_alg *alg); -struct crypto_tfm *__crypto_alloc_tfmgfp (struct crypto_alg *alg,u32 type, -u32 mask,gfp_t gfp);struct crypto_tfm *__crypto_alloc_tfm (struct crypto_alg *alg,u32 type,u32 mask);void *crypto_create_tfm_node (struct crypto_alg *alg,const struct crypto_type *frontend,int node);
Signature · 1 line
2.54.0
PATCH 6/6 crypto: api - Fold crypto_alloc_tfmmem() into crypto_create_tfm_node()
In reply to Eric BiggersFold crypto_alloc_tfmmem() into its only remaining caller, crypto_create_tfm_node(). Previously crypto_alloc_tfmmem() was called by crypto_clone_tfm(), but crypto_clone_tfm() was removed.
This rolls back the refactoring that was done in commit 3c3a24cb0ae4 ("crypto: api - Add crypto_clone_tfm").
--- crypto/api.c | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-)
crypto/api.c +7 -26
@@ -490,46 +490,27 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)return ERR_PTR (err); }EXPORT_SYMBOL_GPL (crypto_alloc_base); -static void *crypto_alloc_tfmmem (struct crypto_alg *alg, -const struct crypto_type *frontend,int node, -gfp_t gfp) -{ -struct crypto_tfm *tfm; -unsigned int tfmsize; -unsigned int total; -char *mem; - - tfmsize = frontend->tfmsize; - total = tfmsize +sizeof (*tfm) + frontend->extsize (alg); - - mem =kzalloc_node (total, gfp, node); -if (mem ==NULL ) -return ERR_PTR (-ENOMEM ); - - tfm = (struct crypto_tfm *)(mem + tfmsize); - tfm->__crt_alg = alg; - tfm->node = node; - -return mem; -} -void *crypto_create_tfm_node (struct crypto_alg *alg,const struct crypto_type *frontend,int node) {struct crypto_tfm *tfm; +size_t size;char *mem;int err; - mem =crypto_alloc_tfmmem (alg, frontend, node,GFP_KERNEL ); -if (IS_ERR (mem)) - goto out; + size = frontend->tfmsize +sizeof (*tfm) + frontend->extsize (alg); + mem =kzalloc_node (size,GFP_KERNEL , node); +if (!mem) +return ERR_PTR (-ENOMEM ); tfm = (struct crypto_tfm *)(mem + frontend->tfmsize); + tfm->__crt_alg = alg; + tfm->node = node; tfm->fb = tfm; err = frontend->init_tfm (tfm);if (err) goto out_free_tfm;
Signature · 1 line
2.54.0
Paolo Abeni
maintainerQuoted 3 lines · Eric Biggers
This series is targeting net-next because it depends on "net/tcp: Remove
tcp_sigpool". So far no commits in cryptodev conflict with this, so I suggest that this be taken through net-next for 7.2.
Makes sense, and series LGTM, but waiting a bit for an explicit ack from Herbert.
/P
Quoted 40 lines · Eric Biggers
This series is targeting net-next because it depends on "net/tcp: Remove
tcp_sigpool". So far no commits in cryptodev conflict with this, so I suggest that this be taken through net-next for 7.2.This series removes support for transformation cloning from the crypto API. Now that the TCP-AO and TCP-MD5 code no longer uses it, it no longer has a user. And it's unlikely that a new one will appear, as the library API solves the problem in a much simpler and more efficient way.
This feature also regressed performance for all crypto API users, since it changed crypto transformation objects into reference-counted objects. That added expensive atomic operations. The refcount is reverted by this series, thus fixing the performance regression.
A subset of this was previously sent in
https://lore.kernel.org/r/[email protected]
Compared to that version, this version is a bit more comprehensive.Eric Biggers (6):
crypto: hash - Remove support for cloning hash tfms
crypto: cipher - Removecrypto_clone_cipher()
crypto: api - Removecrypto_clone_tfm()
crypto: api - Remove per-tfm refcount
crypto: api - Fold__crypto_alloc_tfmgfp()into__crypto_alloc_tfm()
crypto: api - Foldcrypto_alloc_tfmmem()intocrypto_create_tfm_node()crypto/ahash.c | 70 ----------------------------- crypto/api.c | 76 +++++--------------------------- crypto/cipher.c | 28 ------------ crypto/cmac.c | 16 ------- crypto/cryptd.c | 16 ------- crypto/hmac.c | 31 ------------- crypto/internal.h | 10 ----- crypto/shash.c | 37 ---------------- include/crypto/hash.h | 8 ---- include/crypto/internal/cipher.h | 2 - include/linux/crypto.h | 1 - 11 files changed, 10 insertions(+), 285 deletions(-)
Quoted 3 lines
base-commit:
1a1f055318d82e64485a6ff8420e5f70b4267998Signature · 1 line
2.54.0
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Fri, 22 May 2026 00:30:22 -0500 you wrote:
This series is targeting net-next because it depends on "net/tcp: Remove
tcp_sigpool". So far no commits in cryptodev conflict with this, so I suggest that this be taken through net-next for 7.2.This series removes support for transformation cloning from the crypto API. Now that the TCP-AO and TCP-MD5 code no longer uses it, it no longer has a user. And it's unlikely that a new one will appear, as the library API solves the problem in a much simpler and more efficient way.
[...]
Here is the summary with links:
- [net-next,1/6] crypto: hash - Remove support for cloning hash tfms
https://git.kernel.org/netdev/net-next/c/f331c7be97ce - [net-next,2/6] crypto: cipher - Remove crypto_clone_cipher() https://git.kernel.org/netdev/net-next/c/cb2e6e86ceb5 - [net-next,3/6] crypto: api - Remove crypto_clone_tfm() https://git.kernel.org/netdev/net-next/c/590a46c68a7b - [net-next,4/6] crypto: api - Remove per-tfm refcount https://git.kernel.org/netdev/net-next/c/3065170bfc7f - [net-next,5/6] crypto: api - Fold __crypto_alloc_tfmgfp() into __crypto_alloc_tfm() https://git.kernel.org/netdev/net-next/c/9d58d14e3a18 - [net-next,6/6] crypto: api - Fold crypto_alloc_tfmmem() into crypto_create_tfm_node() https://git.kernel.org/netdev/net-next/c/0200de9d75b1
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html