Belated response on this - I was out last week.
On Mon, Apr 11, 2022 at 05:37:24PM +0000, Eric Biggers wrote:
On Sun, Apr 10, 2022 at 08:47:05PM +0100, Giovanni Cabiddu wrote:
If requests exceed 4 entries buffers, memory is allocated dynamically.
In addition, remove the CRYPTO_ALG_ALLOCATES_MEMORY flag from both aead and skcipher alg structures.
There is nothing that says that algorithms can ignore !CRYPTO_ALG_ALLOCATES_MEMORY if there are too many scatterlist entries. See the comment above the definition of CRYPTO_ALG_ALLOCATES_MEMORY.
From the conversation in [1], I assumed that a cap on the number of pre-allocated entries in the scatterlists was already agreed.
If you need to introduce this constraint, then you will need to audit the users of !CRYPTO_ALG_ALLOCATES_MEMORY to verify that none of them are issuing requests that violate this constraint, then add this to the documentation comment for CRYPTO_ALG_ALLOCATES_MEMORY.
Makes sense. I see that the only users of !CRYPTO_ALG_ALLOCATES_MEMORY are dm-crypt and dm-integrity but I haven't done an audit on those yet to understand if they use more than 4 entries.
Regards,
[1] https://lore.kernel.org/linux-crypto/20200722072932.GA27544@gondor.apana.org...