From: Eric Biggers <ebiggers@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>, linux-crypto@vger.kernel.org
Cc: Danny Tsen <dtsen@linux.ibm.com>, Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH 4/5] crypto: cryptd - Remove unused CRYPTO_ALG_INTERNAL support
Date: Thu, 3 Dec 2026 00:03:32 -0800 [thread overview]
Message-ID: <20261203080333.145409-5-ebiggers@kernel.org> (raw)
In-Reply-To: <20261203080333.145409-1-ebiggers@kernel.org>
cryptd's support for wrapping CRYPTO_ALG_INTERNAL algorithms existed
only for crypto_simd, which registered CRYPTO_ALG_INTERNAL algorithms
and wrapped them via cryptd_alloc_*().
However, with crypto_simd and the cryptd_alloc_*() helpers now removed,
nothing uses cryptd to wrap CRYPTO_ALG_INTERNAL algorithms anymore.
Therefore, remove the CRYPTO_ALG_INTERNAL handling.
This makes cryptd behave like all the other crypto templates and reject
CRYPTO_ALG_INTERNAL algorithms.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
crypto/cryptd.c | 44 +++++++++++---------------------------------
1 file changed, 11 insertions(+), 33 deletions(-)
diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index 29dde50f93603..7e871715117aa 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -181,20 +181,10 @@ static inline struct cryptd_queue *cryptd_get_queue(struct crypto_tfm *tfm)
return ictx->queue;
}
-static void cryptd_type_and_mask(struct crypto_attr_type *algt,
- u32 *type, u32 *mask)
+static u32 cryptd_mask(struct crypto_attr_type *algt)
{
- /*
- * cryptd is allowed to wrap internal algorithms, but in that case the
- * resulting cryptd instance will be marked as internal as well.
- */
- *type = algt->type & CRYPTO_ALG_INTERNAL;
- *mask = algt->mask & CRYPTO_ALG_INTERNAL;
-
/* No point in cryptd wrapping an algorithm that's already async. */
- *mask |= CRYPTO_ALG_ASYNC;
-
- *mask |= crypto_algt_inherited_mask(algt);
+ return crypto_algt_inherited_mask(algt) | CRYPTO_ALG_ASYNC;
}
static int cryptd_init_instance(struct crypto_instance *inst,
@@ -364,12 +354,9 @@ static int cryptd_create_skcipher(struct crypto_template *tmpl,
struct skcipherd_instance_ctx *ctx;
struct skcipher_instance *inst;
struct skcipher_alg_common *alg;
- u32 type;
- u32 mask;
+ u32 mask = cryptd_mask(algt);
int err;
- cryptd_type_and_mask(algt, &type, &mask);
-
inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
if (!inst)
return -ENOMEM;
@@ -378,7 +365,7 @@ static int cryptd_create_skcipher(struct crypto_template *tmpl,
ctx->queue = queue;
err = crypto_grab_skcipher(&ctx->spawn, skcipher_crypto_instance(inst),
- crypto_attr_alg_name(tb[1]), type, mask);
+ crypto_attr_alg_name(tb[1]), 0, mask);
if (err)
goto err_free_inst;
@@ -387,8 +374,7 @@ static int cryptd_create_skcipher(struct crypto_template *tmpl,
if (err)
goto err_free_inst;
- inst->alg.base.cra_flags |= CRYPTO_ALG_ASYNC |
- (alg->base.cra_flags & CRYPTO_ALG_INTERNAL);
+ inst->alg.base.cra_flags |= CRYPTO_ALG_ASYNC;
inst->alg.ivsize = alg->ivsize;
inst->alg.chunksize = alg->chunksize;
inst->alg.min_keysize = alg->min_keysize;
@@ -629,12 +615,9 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
struct hashd_instance_ctx *ctx;
struct ahash_instance *inst;
struct shash_alg *alg;
- u32 type;
- u32 mask;
+ u32 mask = cryptd_mask(algt);
int err;
- cryptd_type_and_mask(algt, &type, &mask);
-
inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
if (!inst)
return -ENOMEM;
@@ -643,7 +626,7 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
ctx->queue = queue;
err = crypto_grab_shash(&ctx->spawn, ahash_crypto_instance(inst),
- crypto_attr_alg_name(tb[1]), type, mask);
+ crypto_attr_alg_name(tb[1]), 0, mask);
if (err)
goto err_free_inst;
alg = crypto_spawn_shash_alg(&ctx->spawn);
@@ -653,8 +636,7 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
goto err_free_inst;
inst->alg.halg.base.cra_flags |= CRYPTO_ALG_ASYNC |
- (alg->base.cra_flags & (CRYPTO_ALG_INTERNAL|
- CRYPTO_ALG_OPTIONAL_KEY));
+ (alg->base.cra_flags & CRYPTO_ALG_OPTIONAL_KEY);
inst->alg.halg.digestsize = alg->digestsize;
inst->alg.halg.statesize = alg->statesize;
inst->alg.halg.base.cra_ctxsize = sizeof(struct cryptd_hash_ctx);
@@ -828,12 +810,9 @@ static int cryptd_create_aead(struct crypto_template *tmpl,
struct aead_instance_ctx *ctx;
struct aead_instance *inst;
struct aead_alg *alg;
- u32 type;
- u32 mask;
+ u32 mask = cryptd_mask(algt);
int err;
- cryptd_type_and_mask(algt, &type, &mask);
-
inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
if (!inst)
return -ENOMEM;
@@ -842,7 +821,7 @@ static int cryptd_create_aead(struct crypto_template *tmpl,
ctx->queue = queue;
err = crypto_grab_aead(&ctx->aead_spawn, aead_crypto_instance(inst),
- crypto_attr_alg_name(tb[1]), type, mask);
+ crypto_attr_alg_name(tb[1]), 0, mask);
if (err)
goto err_free_inst;
@@ -851,8 +830,7 @@ static int cryptd_create_aead(struct crypto_template *tmpl,
if (err)
goto err_free_inst;
- inst->alg.base.cra_flags |= CRYPTO_ALG_ASYNC |
- (alg->base.cra_flags & CRYPTO_ALG_INTERNAL);
+ inst->alg.base.cra_flags |= CRYPTO_ALG_ASYNC;
inst->alg.base.cra_ctxsize = sizeof(struct cryptd_aead_ctx);
inst->alg.ivsize = crypto_aead_alg_ivsize(alg);
--
2.56.1
next prev parent reply other threads:[~2026-12-03 8:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 8:03 [PATCH 0/5] crypto: Remove crypto_simd and clean up cryptd Eric Biggers
2026-12-03 8:03 ` [PATCH 1/5] crypto: simd - Remove unused crypto_simd module Eric Biggers
2026-12-03 8:03 ` [PATCH 2/5] crypto: cryptd - Remove unused AEAD functions Eric Biggers
2026-12-03 8:03 ` [PATCH 3/5] crypto: cryptd - Remove pointless reference count Eric Biggers
2026-12-03 8:03 ` Eric Biggers [this message]
2026-12-03 8:03 ` [PATCH 5/5] crypto: cryptd - Remove pointless per-instance queue pointer Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203080333.145409-5-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=dtsen@linux.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.