• Eric Biggers's avatar
    crypto: algapi - introduce the flag CRYPTO_ALG_ALLOCATES_MEMORY · fbb6cda4
    Eric Biggers authored
    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 <mpatocka@redhat.com>
    (https://lore.kernel.org/r/alpine.LRH.2.02.2006301414580.30526@file01.intranet.prod.int.rdu2.redhat.com).
    Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    fbb6cda4
algapi.h 8.17 KB