Re: [PATCH-next 2/3] crypto: api - Provide gfp mask for tfm allocation

From: Eric Biggers
Date: Thu Jun 15 2023 - 19:38:57 EST


On Wed, Jun 14, 2023 at 06:46:42PM +0100, Dmitry Safonov wrote:
> diff --git a/crypto/cipher.c b/crypto/cipher.c
> index d39ef5f72ab8..184188339a4a 100644
> --- a/crypto/cipher.c
> +++ b/crypto/cipher.c
> @@ -102,7 +102,7 @@ struct crypto_cipher *crypto_clone_cipher(struct crypto_cipher *cipher)
> return ERR_PTR(-ENOSYS);
>
> ntfm = __crypto_alloc_tfm(alg, CRYPTO_ALG_TYPE_CIPHER,
> - CRYPTO_ALG_TYPE_MASK);
> + CRYPTO_ALG_TYPE_MASK, GFP_ATOMIC);
> if (IS_ERR(ntfm))
> return ERR_CAST(ntfm);
>

Should crypto_clone_cipher() not have a gfp_t argument itself?

I'm wondering if any users of the crypto_clone_*() functions will need anything
other than GFP_ATOMIC, such as GFP_NOFS or GFP_NOIO.

FWIW, btrfs's support for fscrypt is planned to use per-extent keys. It's
challenging to implement. I've been thinking it might need a
crypto_clone_skcipher() function that it can use during filesystem I/O. That
use case would want GFP_NOFS, I think.

- Eric