From nobody Sun May 24 20:33:02 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C32039DBC8; Fri, 22 May 2026 05:31:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779427864; cv=none; b=b/IOBxQFNsh/93eZGkDXxqnRpiC6P3JNnuWMwjkn9IZ6fhjkRVfD2fLCHvr21MoJnNrbVBF35zxrWRppQH3DFbvrsalS4vKwLE5C/41qm4hMJ3A0zZlZ6zcAa2lpgG9wiHU/XrJ1I7IWwioaZ9FRct5IGxPJZsZvpjEt/YaH5u4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779427864; c=relaxed/simple; bh=KXqntxdblFo1QoC+4PAZRvPt2HSNsPkaUAgwFGb5BeU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AGEC/vB312HfczAntaPJdJa+gQocHS+lIJsWtLaDR8iX7M2DFU5Za0zIZCqJLbQ6wOLwSj8O2xUcg7QuMMlrLK00uwK1j2dpjGTOFT/VtHbz6ofndHn+xf9i9icdZjJoUNUIBnox49Xu+J+fEp9dZuytJh4F7L5L3cUf9uyW5vI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WBgjct5a; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WBgjct5a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9B351F00A3D; Fri, 22 May 2026 05:31:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779427862; bh=AFPWjcrbLTtozuLOXzPHcpaKiNBzsbUi3H0JIEu8jHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WBgjct5adft3qVGpJSZk8XKxKeUk1DhkaHFEYmPWjn3ZvnO72va3qTOW2QMN9q4er bSUIBCDBK1yTujn7KR3Ndn6XM/ZvVnCh7GWJVHV74YXgqk0o5lXmJxuaDUEvFwcSTP zkPxN9c6ukNFVrA09Wxwtrn0YQ8Oc6e1jz5soEKnOEmgrfEs/eRZ4crUPyjkN2Hi/+ KxGRIfm9E/OCLDMGqyN3ozqPso3688sHTO57G22glVTRjudeE1rtRuSQFSjjmu4yRa yADJIq54BWmHvGIfKvo4zF5ANQODNrrzrrcU5kha8+zs7htuWYTGd4zSenMtszb9Sf ydhg2iRsRV/VA== From: Eric Biggers To: netdev@vger.kernel.org Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Dumazet , Neal Cardwell , Kuniyuki Iwashima , "David S . Miller" , David Ahern , Jakub Kicinski , Paolo Abeni , Simon Horman , Ard Biesheuvel , "Jason A . Donenfeld" , Herbert Xu , Dmitry Safonov <0x7f454c46@gmail.com>, Eric Biggers Subject: [PATCH net-next 1/6] crypto: hash - Remove support for cloning hash tfms Date: Fri, 22 May 2026 00:30:23 -0500 Message-ID: <20260522053028.91165-2-ebiggers@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260522053028.91165-1-ebiggers@kernel.org> References: <20260522053028.91165-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Reviewed-by: Ard Biesheuvel Signed-off-by: Eric Biggers --- 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(-) diff --git a/crypto/ahash.c b/crypto/ahash.c index 7a730324c50e..85dcd120de3e 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c @@ -860,80 +860,10 @@ bool crypto_hash_alg_has_setkey(struct hash_alg_commo= n *halg) =20 return __crypto_ahash_alg(alg)->setkey !=3D ahash_nosetkey; } EXPORT_SYMBOL_GPL(crypto_hash_alg_has_setkey); =20 -struct crypto_ahash *crypto_clone_ahash(struct crypto_ahash *hash) -{ - struct hash_alg_common *halg =3D crypto_hash_alg_common(hash); - struct crypto_tfm *tfm =3D crypto_ahash_tfm(hash); - struct crypto_ahash *fb =3D NULL; - struct crypto_ahash *nhash; - struct ahash_alg *alg; - int err; - - if (!crypto_hash_alg_has_setkey(halg)) { - tfm =3D crypto_tfm_get(tfm); - if (IS_ERR(tfm)) - return ERR_CAST(tfm); - - return hash; - } - - nhash =3D crypto_clone_tfm(&crypto_ahash_type, tfm); - - if (IS_ERR(nhash)) - return nhash; - - nhash->reqsize =3D hash->reqsize; - nhash->statesize =3D hash->statesize; - - if (likely(hash->using_shash)) { - struct crypto_shash **nctx =3D crypto_ahash_ctx(nhash); - struct crypto_shash *shash; - - shash =3D crypto_clone_shash(ahash_to_shash(hash)); - if (IS_ERR(shash)) { - err =3D PTR_ERR(shash); - goto out_free_nhash; - } - crypto_ahash_tfm(nhash)->exit =3D crypto_exit_ahash_using_shash; - nhash->using_shash =3D true; - *nctx =3D shash; - return nhash; - } - - if (crypto_ahash_need_fallback(hash)) { - fb =3D crypto_clone_ahash(crypto_ahash_fb(hash)); - err =3D PTR_ERR(fb); - if (IS_ERR(fb)) - goto out_free_nhash; - - crypto_ahash_tfm(nhash)->fb =3D crypto_ahash_tfm(fb); - } - - err =3D -ENOSYS; - alg =3D crypto_ahash_alg(hash); - if (!alg->clone_tfm) - goto out_free_fb; - - err =3D alg->clone_tfm(nhash, hash); - if (err) - goto out_free_fb; - - crypto_ahash_tfm(nhash)->exit =3D 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; } =20 diff --git a/crypto/cmac.c b/crypto/cmac.c index 1b03964abe00..83e58937f013 100644 --- a/crypto/cmac.c +++ b/crypto/cmac.c @@ -149,25 +149,10 @@ static int cmac_init_tfm(struct crypto_shash *tfm) ctx->child =3D cipher; =20 return 0; } =20 -static int cmac_clone_tfm(struct crypto_shash *tfm, struct crypto_shash *o= tfm) -{ - struct cmac_tfm_ctx *octx =3D crypto_shash_ctx(otfm); - struct cmac_tfm_ctx *ctx =3D crypto_shash_ctx(tfm); - struct crypto_cipher *cipher; - - cipher =3D crypto_clone_cipher(octx->child); - if (IS_ERR(cipher)) - return PTR_ERR(cipher); - - ctx->child =3D cipher; - - return 0; -} - static void cmac_exit_tfm(struct crypto_shash *tfm) { struct cmac_tfm_ctx *ctx =3D 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 =3D crypto_cmac_digest_init; inst->alg.update =3D crypto_cmac_digest_update; inst->alg.finup =3D crypto_cmac_digest_finup; inst->alg.setkey =3D crypto_cmac_digest_setkey; inst->alg.init_tfm =3D cmac_init_tfm; - inst->alg.clone_tfm =3D cmac_clone_tfm; inst->alg.exit_tfm =3D cmac_exit_tfm; =20 inst->free =3D shash_free_singlespawn_instance; =20 err =3D shash_register_instance(tmpl, inst); diff --git a/crypto/cryptd.c b/crypto/cryptd.c index aba9fe0f23b4..d8dbf07ab426 100644 --- a/crypto/cryptd.c +++ b/crypto/cryptd.c @@ -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; } =20 -static int cryptd_hash_clone_tfm(struct crypto_ahash *ntfm, - struct crypto_ahash *tfm) -{ - struct cryptd_hash_ctx *nctx =3D crypto_ahash_ctx(ntfm); - struct cryptd_hash_ctx *ctx =3D crypto_ahash_ctx(tfm); - struct crypto_shash *hash; - - hash =3D crypto_clone_shash(ctx->child); - if (IS_ERR(hash)) - return PTR_ERR(hash); - - nctx->child =3D hash; - return 0; -} - static void cryptd_hash_exit_tfm(struct crypto_ahash *tfm) { struct cryptd_hash_ctx *ctx =3D crypto_ahash_ctx(tfm); =20 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 =3D alg->digestsize; inst->alg.halg.statesize =3D alg->statesize; inst->alg.halg.base.cra_ctxsize =3D sizeof(struct cryptd_hash_ctx); =20 inst->alg.init_tfm =3D cryptd_hash_init_tfm; - inst->alg.clone_tfm =3D cryptd_hash_clone_tfm; inst->alg.exit_tfm =3D cryptd_hash_exit_tfm; =20 inst->alg.init =3D cryptd_hash_init_enqueue; inst->alg.update =3D cryptd_hash_update_enqueue; inst->alg.final =3D cryptd_hash_final_enqueue; diff --git a/crypto/hmac.c b/crypto/hmac.c index 148af460ae97..807e08b252c5 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c @@ -156,24 +156,10 @@ static int hmac_init_tfm(struct crypto_shash *parent) =20 tctx->hash =3D hash; return 0; } =20 -static int hmac_clone_tfm(struct crypto_shash *dst, struct crypto_shash *s= rc) -{ - struct hmac_ctx *sctx =3D crypto_shash_ctx(src); - struct hmac_ctx *dctx =3D crypto_shash_ctx(dst); - struct crypto_shash *hash; - - hash =3D crypto_clone_shash(sctx->hash); - if (IS_ERR(hash)) - return PTR_ERR(hash); - - dctx->hash =3D hash; - return 0; -} - static void hmac_exit_tfm(struct crypto_shash *parent) { struct hmac_ctx *tctx =3D crypto_shash_ctx(parent); =20 crypto_free_shash(tctx->hash); @@ -233,11 +219,10 @@ static int __hmac_create_shash(struct crypto_template= *tmpl, inst->alg.import =3D hmac_import; inst->alg.export_core =3D hmac_export_core; inst->alg.import_core =3D hmac_import_core; inst->alg.setkey =3D hmac_setkey; inst->alg.init_tfm =3D hmac_init_tfm; - inst->alg.clone_tfm =3D hmac_clone_tfm; inst->alg.exit_tfm =3D hmac_exit_tfm; =20 inst->free =3D shash_free_singlespawn_instance; =20 err =3D shash_register_instance(tmpl, inst); @@ -421,25 +406,10 @@ static int hmac_init_ahash_tfm(struct crypto_ahash *p= arent) =20 tctx->hash =3D hash; return 0; } =20 -static int hmac_clone_ahash_tfm(struct crypto_ahash *dst, - struct crypto_ahash *src) -{ - struct ahash_hmac_ctx *sctx =3D crypto_ahash_ctx(src); - struct ahash_hmac_ctx *dctx =3D crypto_ahash_ctx(dst); - struct crypto_ahash *hash; - - hash =3D crypto_clone_ahash(sctx->hash); - if (IS_ERR(hash)) - return PTR_ERR(hash); - - dctx->hash =3D hash; - return 0; -} - static void hmac_exit_ahash_tfm(struct crypto_ahash *parent) { struct ahash_hmac_ctx *tctx =3D crypto_ahash_ctx(parent); =20 crypto_free_ahash(tctx->hash); @@ -501,11 +471,10 @@ static int hmac_create_ahash(struct crypto_template *= tmpl, struct rtattr **tb, inst->alg.import =3D hmac_import_ahash; inst->alg.export_core =3D hmac_export_core_ahash; inst->alg.import_core =3D hmac_import_core_ahash; inst->alg.setkey =3D hmac_setkey_ahash; inst->alg.init_tfm =3D hmac_init_ahash_tfm; - inst->alg.clone_tfm =3D hmac_clone_ahash_tfm; inst->alg.exit_tfm =3D hmac_exit_ahash_tfm; =20 inst->free =3D ahash_free_singlespawn_instance; =20 err =3D ahash_register_instance(tmpl, inst); diff --git a/crypto/shash.c b/crypto/shash.c index 2f07d0bd1f61..351cba3c1107 100644 --- a/crypto/shash.c +++ b/crypto/shash.c @@ -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); =20 -struct crypto_shash *crypto_clone_shash(struct crypto_shash *hash) -{ - struct crypto_tfm *tfm =3D crypto_shash_tfm(hash); - struct shash_alg *alg =3D crypto_shash_alg(hash); - struct crypto_shash *nhash; - int err; - - if (!crypto_shash_alg_has_setkey(alg)) { - tfm =3D 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 =3D crypto_clone_tfm(&crypto_shash_type, tfm); - if (IS_ERR(nhash)) - return nhash; - - if (alg->clone_tfm) { - err =3D alg->clone_tfm(nhash, hash); - if (err) { - crypto_free_shash(nhash); - return ERR_PTR(err); - } - } - - if (alg->exit_tfm) - crypto_shash_tfm(nhash)->exit =3D 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 =3D &alg->base; =20 if (alg->digestsize > HASH_MAX_DIGESTSIZE) diff --git a/include/crypto/hash.h b/include/crypto/hash.h index 586700332c73..e474f8461ea1 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -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); =20 struct hash_alg_common halg; }; =20 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 s= tate * 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); =20 unsigned int descsize; =20 union { struct HASH_ALG_COMMON; @@ -320,12 +316,10 @@ static inline struct crypto_ahash *__crypto_ahash_cas= t(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); =20 -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; } =20 @@ -757,12 +751,10 @@ static inline void ahash_request_set_virt(struct ahas= h_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); =20 -struct crypto_shash *crypto_clone_shash(struct crypto_shash *tfm); - int crypto_has_shash(const char *alg_name, u32 type, u32 mask); =20 static inline struct crypto_tfm *crypto_shash_tfm(struct crypto_shash *tfm) { return &tfm->base; --=20 2.54.0 From nobody Sun May 24 20:33:02 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5825A39D6DF; Fri, 22 May 2026 05:31:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779427865; cv=none; b=VvEP6aSmaTLolq4C1MENpilnQztmC8xSLSgnC2lZFmIue/vnYB684AIuJmFphqzjug4IGY1/URcDaLdkUYvquSd7CbP+cy0W/xreK+YCmnH8caIxmleCY7zAKgk67RIyS0BBD5xCCk1u2AVplIi4uVhD8kTySG1SzvL2lZDzCIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779427865; c=relaxed/simple; bh=+Trog/DKdhmgYtXN6C0Fts331pgzew035r+29P3Lo4M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=agaIrpHm8K751i4BN0W8wLX7hNCE9+KBHARf+fvzmxfe5ncDVBgcLFBaXbuv96UDcXdtv3+rRsfryHMm6JRicffrriYF3KY+BOq1wYiiJ69X3nyYn2hA3CPR+vPUfus2AXBde5pnavd+VTN6c23LbKQYc95sZbIe/QUjBxA/Tkw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XXWodOLc; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XXWodOLc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BB7C1F00A3F; Fri, 22 May 2026 05:31:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779427864; bh=lyuadyceyVHMbEkzNYbCGqNjcN+CZzGorS75xcstP58=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XXWodOLcvfa1ECwHoMOsPozSdLobKtwmwcXhHI8tcprhY/CzxjGMODlBJDNQDhLUp s/5skVzSdv/MWyWWUEtkNqpJTyAU0TnYoG3EJn2imdCRWsop0uuXZ79ZB1XMfeGQii vpEoBC/k4Eo3hI4mnNXYND9ulL6zcGAhhdNIiv72hIFkl/lDZ4Of/irXeosFX/+KnU qPdYqdURzWuWMFRQMWa9hQ9LIG9uilULsRLdZHCpWBlLzWrAXDu0u0JOESJne5tRRy UbSywIi6jgaAYxl95hqcDEYUifHJelX/NbOv9idYpaExhyaSqGSlKoJgN5VfddqGiO ExJPxUmIpkUUQ== From: Eric Biggers To: netdev@vger.kernel.org Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Dumazet , Neal Cardwell , Kuniyuki Iwashima , "David S . Miller" , David Ahern , Jakub Kicinski , Paolo Abeni , Simon Horman , Ard Biesheuvel , "Jason A . Donenfeld" , Herbert Xu , Dmitry Safonov <0x7f454c46@gmail.com>, Eric Biggers Subject: [PATCH net-next 2/6] crypto: cipher - Remove crypto_clone_cipher() Date: Fri, 22 May 2026 00:30:24 -0500 Message-ID: <20260522053028.91165-3-ebiggers@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260522053028.91165-1-ebiggers@kernel.org> References: <20260522053028.91165-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since 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. Reviewed-by: Ard Biesheuvel Signed-off-by: Eric Biggers --- crypto/cipher.c | 28 ---------------------------- include/crypto/internal/cipher.h | 2 -- 2 files changed, 30 deletions(-) diff --git a/crypto/cipher.c b/crypto/cipher.c index 1fe62bf79656..c9dab656a622 100644 --- a/crypto/cipher.c +++ b/crypto/cipher.c @@ -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 =3D crypto_cipher_tfm(cipher); - struct crypto_alg *alg =3D 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 =3D __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 =3D tfm->crt_flags; - - ncipher =3D __crypto_cipher_cast(ntfm); - - return ncipher; -} -EXPORT_SYMBOL_GPL(crypto_clone_cipher); diff --git a/include/crypto/internal/cipher.h b/include/crypto/internal/cip= her.h index 5030f6d2df31..a9174ba90250 100644 --- a/include/crypto/internal/cipher.h +++ b/include/crypto/internal/cipher.h @@ -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); =20 -struct crypto_cipher *crypto_clone_cipher(struct crypto_cipher *cipher); - struct crypto_cipher_spawn { struct crypto_spawn base; }; =20 static inline int crypto_grab_cipher(struct crypto_cipher_spawn *spawn, --=20 2.54.0 From nobody Sun May 24 20:33:02 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91D6039EF1E; Fri, 22 May 2026 05:31:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779427868; cv=none; b=uvE/vgbJ1g6c4hc4y2dqV3+ZyxleXr6IzSHD7uC+uKx5lJ5a7SJUINNuHbzMQ5Inl/Pmkk7Kb1ZYLus/3vTLI+KAdJyUWPMMnn6v9BQBvrU1ERsgUKGRbX4V3a0RkMea4f6BigRcGJX4Pryqda549pcUL8tDuwhNkILSvtExYKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779427868; c=relaxed/simple; bh=3AAEZjaRK507ex3BYJ5Fuxt8FZkNq3ASxA/sK1xrsH8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i2MQfQ6QJlwk+at9sT1nB3rWSjJWuIvM3+Xta1b3FGUHFhedsegnPEln47Wm7tNGw1WxlspeAHs0LRvK8IWr1jemcbB5M7CpcWigbPVsmZZqjfBYGdpJ9UnCDflL0ffIfxXKhp0r41K4FAW31gRB+NHtr/l71Gk6Bji8RrED5tw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=csgCnv12; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="csgCnv12" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51C2C1F000E9; Fri, 22 May 2026 05:31:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779427865; bh=uWvNpb1256Gs/nAAgMw5xRh+0CIJM6zXjVMv2A02v+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=csgCnv121CG8Dji8w4I9UoXVsx1v/07a2KRvFBBooMerr4c1DUdIRkgYLgtqLnNGx DzfLXdYMRhYSlqne8i+E1phzz8JZjGoIYmpaOEdQ7/wr+85UcfUB2E6A4/Tptqb0da ze201qHRP3PptWFaZNNBpRW8aQ9Wzufpu5R6tVcRQmz6zcg0217jZj2TjAtT7msu47 VoCYErd0AeKa8K2WkQ9fIQ/kONRV1mdgM2dlLk9YNO3sMm+MKm9J0rbPRvy25m5iAR 93CZjHmM0vr+L5nP3e54ajnJEZ3tyql8VNG0FE5tWrZO7579smO50zjLqGWcb14HVx FePHenEY9Bmeg== From: Eric Biggers To: netdev@vger.kernel.org Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Dumazet , Neal Cardwell , Kuniyuki Iwashima , "David S . Miller" , David Ahern , Jakub Kicinski , Paolo Abeni , Simon Horman , Ard Biesheuvel , "Jason A . Donenfeld" , Herbert Xu , Dmitry Safonov <0x7f454c46@gmail.com>, Eric Biggers Subject: [PATCH net-next 3/6] crypto: api - Remove crypto_clone_tfm() Date: Fri, 22 May 2026 00:30:25 -0500 Message-ID: <20260522053028.91165-4-ebiggers@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260522053028.91165-1-ebiggers@kernel.org> References: <20260522053028.91165-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since 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. Reviewed-by: Ard Biesheuvel Signed-off-by: Eric Biggers --- crypto/api.c | 26 -------------------------- crypto/internal.h | 2 -- 2 files changed, 28 deletions(-) diff --git a/crypto/api.c b/crypto/api.c index 74e17d5049c9..d019d1979857 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -558,36 +558,10 @@ void *crypto_create_tfm_node(struct crypto_alg *alg, out: return mem; } EXPORT_SYMBOL_GPL(crypto_create_tfm_node); =20 -void *crypto_clone_tfm(const struct crypto_type *frontend, - struct crypto_tfm *otfm) -{ - struct crypto_alg *alg =3D otfm->__crt_alg; - struct crypto_tfm *tfm; - char *mem; - - mem =3D ERR_PTR(-ESTALE); - if (unlikely(!crypto_mod_get(alg))) - goto out; - - mem =3D crypto_alloc_tfmmem(alg, frontend, otfm->node, GFP_ATOMIC); - if (IS_ERR(mem)) { - crypto_mod_put(alg); - goto out; - } - - tfm =3D (struct crypto_tfm *)(mem + frontend->tfmsize); - tfm->crt_flags =3D otfm->crt_flags; - tfm->fb =3D 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) { diff --git a/crypto/internal.h b/crypto/internal.h index 8fbe0226d48e..96f84abfac91 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -124,12 +124,10 @@ struct crypto_tfm *__crypto_alloc_tfmgfp(struct crypt= o_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); =20 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); --=20 2.54.0 From nobody Sun May 24 20:33:02 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1499389DE3; Fri, 22 May 2026 05:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779427869; cv=none; b=pLFoCFTgtVp1t9n+Oha0VYkV0UgY8utoPNdLorcOzBP2/Fz0dCemq7b2VEJvwdt0NCTyEbQqeP36GR/cPOsVNgpADPf8bRi3v/SnCS7GMWxpNOKQ7dnOD7enVQz+Ur32yJSUtefccUXECJa6es4KPE/n/hnNJqXJunfLRTjqca0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779427869; c=relaxed/simple; bh=olYUFSu6SpRXYOxnbxyXzaK1+ZLTFwClbiEhOovDBwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rOqWLsY/C5C2LfSZH3A0tmuCwgeky2/S66cZ1Zz25WILoek8UyG85QnpdbuRP9cdSmkzSXtp4Qo9EtI6mKrk5IdJA4dB3Hlr8vAH9WMDVda72oDHPmnw8O+gL0BTwvQU0yoSpl3yZwrO/cTCQlozMVGUemLNN9+A3SMXENf2enc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IJsF2ZtY; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IJsF2ZtY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 859B51F00A3E; Fri, 22 May 2026 05:31:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779427866; bh=5cG91g8TflO4oqr+MQMSWsnVgz6/nNgqVLxInjxjlf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IJsF2ZtYdzNtzuQZg3Ic5EeSNAHTEHe7KoTfhnj6b+BGH71tXhhxbFymJ1GMvt0Zv Ia9qEFNZKpU8IVXsVwyh6aknACjMil9DGwC7t940CWiIVJdEqU+4V320DEu2Js58cW qpa1iDsn0NknrlDliTaQ0im+DxbAgjDjF9sGYD+461OuZ2BtqjMUlRI3FVJe0Aw9mP EsAWC4m6bIFbU1XpMLyBzBc2nMW+SIMtIPljwYJ9F2kB3P/V1EC7wFl/WMjrOP6n6b vPf6e5c6F/uwNf+oBpnt83bT/9jsjEo8qjrn527J4PfdXFaSRvcrvzarIO2mC6ITXB TJ/s/9N32lw3w== From: Eric Biggers To: netdev@vger.kernel.org Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Dumazet , Neal Cardwell , Kuniyuki Iwashima , "David S . Miller" , David Ahern , Jakub Kicinski , Paolo Abeni , Simon Horman , Ard Biesheuvel , "Jason A . Donenfeld" , Herbert Xu , Dmitry Safonov <0x7f454c46@gmail.com>, Eric Biggers Subject: [PATCH net-next 4/6] crypto: api - Remove per-tfm refcount Date: Fri, 22 May 2026 00:30:26 -0500 Message-ID: <20260522053028.91165-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260522053028.91165-1-ebiggers@kernel.org> References: <20260522053028.91165-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This 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. Signed-off-by: Eric Biggers --- crypto/api.c | 4 ---- crypto/internal.h | 6 ------ include/linux/crypto.h | 1 - 3 files changed, 11 deletions(-) diff --git a/crypto/api.c b/crypto/api.c index d019d1979857..be9ee104ffc2 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -416,11 +416,10 @@ struct crypto_tfm *__crypto_alloc_tfmgfp(struct crypt= o_alg *alg, u32 type, tfm =3D kzalloc(tfm_size, gfp); if (tfm =3D=3D NULL) goto out_err; =20 tfm->__crt_alg =3D alg; - refcount_set(&tfm->refcnt, 1); =20 if (!tfm->exit && alg->cra_init && (err =3D alg->cra_init(tfm))) goto cra_init_failed; =20 goto out; @@ -517,11 +516,10 @@ static void *crypto_alloc_tfmmem(struct crypto_alg *a= lg, return ERR_PTR(-ENOMEM); =20 tfm =3D (struct crypto_tfm *)(mem + tfmsize); tfm->__crt_alg =3D alg; tfm->node =3D node; - refcount_set(&tfm->refcnt, 1); =20 return mem; } =20 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; =20 if (IS_ERR_OR_NULL(mem)) return; =20 - if (!refcount_dec_and_test(&tfm->refcnt)) - return; alg =3D tfm->__crt_alg; =20 if (!tfm->exit && alg->cra_exit) alg->cra_exit(tfm); crypto_exit_ops(tfm); diff --git a/crypto/internal.h b/crypto/internal.h index 96f84abfac91..b6e437f463d4 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -8,11 +8,10 @@ #ifndef _CRYPTO_INTERNAL_H #define _CRYPTO_INTERNAL_H =20 #include #include -#include #include #include #include #include #include @@ -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]; } =20 -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 */ =20 diff --git a/include/linux/crypto.h b/include/linux/crypto.h index a2137e19be7d..b7c97f1c47c9 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -407,11 +407,10 @@ int crypto_has_alg(const char *name, u32 type, u32 ma= sk); * and core processing logic. Managed via crypto_alloc_*() and * crypto_free_*(), as well as the various helpers below. */ =20 struct crypto_tfm { - refcount_t refcnt; =20 u32 crt_flags; =20 int node; =20 --=20 2.54.0 From nobody Sun May 24 20:33:02 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A4C239D6E5; Fri, 22 May 2026 05:31:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779427871; cv=none; b=e7owNSqzVw8S02EJ9iFGpdg06NPf26rjn3f/ZFuBJfY49PSYZ7jtuStYhGmPxYf5pziUZkHM4l9PXIpRCj8YPRsflbPu180s4Sr4nCY+Of+dnLBYCTI0v2PZl3KXrbA1if0AKV6S3LOAGyH67TcJVMFf+EJfx+W80vwiNFf7AJo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779427871; c=relaxed/simple; bh=AR2nEb1BVonvAdMGkQZ1BqhRzgsbWMLcsp9YHHUC2O4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ch/efxii4hjRYMgVCDgJonYy4+bA3B+en7yU7o1ZqKkZBHEDPnyC8x0uvgMMMcPv0cESBKw3uxnWFKsCHCVJD0CAfq0IWmfNSxnnt5j8ISHf7ZJ0TMf173VRenR9aVCE/Vq/cy14hrPSsvqDEtPY69RxTY1dlI1LpbwgNwk7N7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lzSnbTOn; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lzSnbTOn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B798F1F0155C; Fri, 22 May 2026 05:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779427867; bh=4QQndDPWvh1YB8HkexAm4q1eabiEB73T4wQ84oA0onE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lzSnbTOn/XMNlD3+tQdExBgv0rIz2RsTJ1n3mmbofXN96ZKum/3ACo0ckijqWeXCm Xn/bBS8YCxV92B5V5HaGg5FqoOTOSZ41kyQFOG+ZaAuH6OuqhatSLOe2sBRp64uZJi Fvx9+ASKE8pJB144ytI3gDNnbX7GQAWEsd+UbBUeDQ4BzK5SkBfoRrgrnL1forjnLu GBHGRNgr80qDumtsM7cLdE2m/3zPVM+ntny/ot4AXn18Ab4538v4k637Izf9883w0V /YyQg9QWxXKUOyDwGf1pbbd/khpC5dfC8ZVl2anoXdNtTDzU6tk8/ee9rgIbVKN4u1 49sSrAmk/5Oeg== From: Eric Biggers To: netdev@vger.kernel.org Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Dumazet , Neal Cardwell , Kuniyuki Iwashima , "David S . Miller" , David Ahern , Jakub Kicinski , Paolo Abeni , Simon Horman , Ard Biesheuvel , "Jason A . Donenfeld" , Herbert Xu , Dmitry Safonov <0x7f454c46@gmail.com>, Eric Biggers Subject: [PATCH net-next 5/6] crypto: api - Fold __crypto_alloc_tfmgfp() into __crypto_alloc_tfm() Date: Fri, 22 May 2026 00:30:27 -0500 Message-ID: <20260522053028.91165-6-ebiggers@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260522053028.91165-1-ebiggers@kernel.org> References: <20260522053028.91165-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This 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. Signed-off-by: Eric Biggers --- crypto/api.c | 13 +++---------- crypto/internal.h | 2 -- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/crypto/api.c b/crypto/api.c index be9ee104ffc2..5bd0db7fa665 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -403,19 +403,19 @@ void crypto_shoot_alg(struct crypto_alg *alg) alg->cra_flags |=3D CRYPTO_ALG_DYING; up_write(&crypto_alg_sem); } EXPORT_SYMBOL_GPL(crypto_shoot_alg); =20 -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 =3D -ENOMEM; =20 tfm_size =3D sizeof(*tfm) + crypto_ctxsize(alg, type, mask); - tfm =3D kzalloc(tfm_size, gfp); + tfm =3D kzalloc(tfm_size, GFP_KERNEL); if (tfm =3D=3D NULL) goto out_err; =20 tfm->__crt_alg =3D alg; =20 @@ -432,17 +432,10 @@ struct crypto_tfm *__crypto_alloc_tfmgfp(struct crypt= o_alg *alg, u32 type, out_err: tfm =3D 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); =20 /* * crypto_alloc_base - Locate algorithm and allocate transform * @alg_name: Name of algorithm diff --git a/crypto/internal.h b/crypto/internal.h index b6e437f463d4..b0a10986f61e 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -117,12 +117,10 @@ void crypto_alg_tested(const char *name, int err); =20 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); =20 --=20 2.54.0 From nobody Sun May 24 20:33:02 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F0853A05CC; Fri, 22 May 2026 05:31:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779427870; cv=none; b=bcPwM1t5Cq1SUHudElbMJQrqU9wziJ9WI6UWkfW0X5qzWPQXtMrd44SlRO/vEy41OAJ2flnbdisyTlha60mGQO015Ve5/VXCRcVyPo9AaUf/E0P9y+vyK6pfPUXVwGjMb0NAlXNZOZtbNlMUo1TBxl1Q1mOPYneiiEv/MccLwdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779427870; c=relaxed/simple; bh=odCxtkvpCQLnlVzA4Uh1Dn8AMGZiHF408qHVpzDK3CU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jjzNBzvrVc6EVGa8J7U9fBD4Ly3LOttHR6f9r629weB5R+EFjuTOZtBKWgvAXTAe5y/RLBOwVVRJGeaoERx0Vwwph00vPXoumj2e1DGfwsRSMc4kWdUZG4WuMyxKqML1t+WwBsO/tcNwzTeAIAprILmFVVle/y39mRJYMMxoh5Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Nkns0oAT; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Nkns0oAT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9D7F1F00A3F; Fri, 22 May 2026 05:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779427869; bh=tFooZ+Qu8ZYwrwEty71u0yYcZtQRNdJkO8GXcz+8awE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Nkns0oAT7e1svaNqyDx7lyvB90g6mEkZW+TWiCYjll65mFuEVPrcDS49y5YMTKWH7 kSOXeZeTrVfCVfuLXyzcnh3NrwasgQEiz+QDpLFopI4hBpAL7aoZu//o6LKO4j6YhG NQY1RP0tmuip6Kgi1a5mMc7DrgAOwdxN8nFmnu6BZIq3iCdML0XyeTTrWPLbbaIBFW IpUtzX9brpZPaaYKTHFB7Ivh/qdeVwGshNK3ES0soqUe4Pftw4ybBQkMKGmJrfGIRu I0OejT2Q3CWq/KvCD1jwygFcF1Yygd+HA4ka3PDeXQUrHRvD6nwag1KxHR321Ojk01 n6HtoZJAL9aPg== From: Eric Biggers To: netdev@vger.kernel.org Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Dumazet , Neal Cardwell , Kuniyuki Iwashima , "David S . Miller" , David Ahern , Jakub Kicinski , Paolo Abeni , Simon Horman , Ard Biesheuvel , "Jason A . Donenfeld" , Herbert Xu , Dmitry Safonov <0x7f454c46@gmail.com>, Eric Biggers Subject: [PATCH net-next 6/6] crypto: api - Fold crypto_alloc_tfmmem() into crypto_create_tfm_node() Date: Fri, 22 May 2026 00:30:28 -0500 Message-ID: <20260522053028.91165-7-ebiggers@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260522053028.91165-1-ebiggers@kernel.org> References: <20260522053028.91165-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fold 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"). Signed-off-by: Eric Biggers --- crypto/api.c | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/crypto/api.c b/crypto/api.c index 5bd0db7fa665..4349c2caa23a 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -490,46 +490,27 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_= name, u32 type, u32 mask) =20 return ERR_PTR(err); } EXPORT_SYMBOL_GPL(crypto_alloc_base); =20 -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 =3D frontend->tfmsize; - total =3D tfmsize + sizeof(*tfm) + frontend->extsize(alg); - - mem =3D kzalloc_node(total, gfp, node); - if (mem =3D=3D NULL) - return ERR_PTR(-ENOMEM); - - tfm =3D (struct crypto_tfm *)(mem + tfmsize); - tfm->__crt_alg =3D alg; - tfm->node =3D 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; =20 - mem =3D crypto_alloc_tfmmem(alg, frontend, node, GFP_KERNEL); - if (IS_ERR(mem)) - goto out; + size =3D frontend->tfmsize + sizeof(*tfm) + frontend->extsize(alg); + mem =3D kzalloc_node(size, GFP_KERNEL, node); + if (!mem) + return ERR_PTR(-ENOMEM); =20 tfm =3D (struct crypto_tfm *)(mem + frontend->tfmsize); + tfm->__crt_alg =3D alg; + tfm->node =3D node; tfm->fb =3D tfm; =20 err =3D frontend->init_tfm(tfm); if (err) goto out_free_tfm; --=20 2.54.0