path: root/include/crypto
diff options
authorEric Biggers <>2020-07-09 23:20:40 -0700
committerHerbert Xu <>2020-07-16 21:49:09 +1000
commitfbb6cda44190d72aa5199d728797aabc6d2ed816 (patch)
treeb91929b45ab881f056a34e62c974c889bf2a74fc /include/crypto
parent2eb27c11937ee9984c04b75d213a737291c5f58c (diff)
crypto: algapi - introduce the flag CRYPTO_ALG_ALLOCATES_MEMORY
Introduce a new algorithm flag CRYPTO_ALG_ALLOCATES_MEMORY. If this flag is set, then the driver allocates memory in its request routine. Such drivers are not suitable for disk encryption because GFP_ATOMIC allocation can fail anytime (causing random I/O errors) and GFP_KERNEL allocation can recurse into the block layer, causing a deadlock. For now, this flag is only implemented for some algorithm types. We also assume some usage constraints for it to be meaningful, since there are lots of edge cases the crypto API allows (e.g., misaligned or fragmented scatterlists) that mean that nearly any crypto algorithm can allocate memory in some case. See the comment for details. Also add this flag to CRYPTO_ALG_INHERITED_FLAGS so that when a template is instantiated, this flag is set on the template instance if it is set on any algorithm the instance uses. Based on a patch by Mikulas Patocka <> ( Signed-off-by: Eric Biggers <> Signed-off-by: Herbert Xu <>
Diffstat (limited to 'include/crypto')
1 files changed, 2 insertions, 1 deletions
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index 22cf4d80959f..143d884d65c7 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -246,7 +246,8 @@ static inline u32 crypto_requires_off(struct crypto_attr_type *algt, u32 off)
* algorithm if any "inner" algorithm has them set.
* Given the type and mask that specify the flags restrictions on a template