lkml.org 
[lkml]   [2020]   [Jun]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [dm-devel] [PATCH 2/4] crypto: pass the flag CRYPTO_ALG_ALLOCATES_MEMORY
    On Tue, Jun 16, 2020 at 11:01:58AM -0400, Mikulas Patocka wrote:
    > Pass the flag CRYPTO_ALG_ALLOCATES_MEMORY down through the crypto API.
    >
    > Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    >
    > ---
    > crypto/adiantum.c | 3 ++-
    > crypto/authenc.c | 5 +++--
    > crypto/authencesn.c | 5 +++--
    > crypto/ccm.c | 7 ++++---
    > crypto/chacha20poly1305.c | 5 +++--
    > crypto/cryptd.c | 7 +++++--
    > crypto/ctr.c | 3 ++-
    > crypto/cts.c | 5 +++--
    > crypto/essiv.c | 5 +++--
    > crypto/gcm.c | 15 +++++++++------
    > crypto/geniv.c | 3 ++-
    > crypto/lrw.c | 5 +++--
    > crypto/rsa-pkcs1pad.c | 5 +++--
    > crypto/xts.c | 2 +-
    > include/crypto/algapi.h | 9 +++++++++
    > 15 files changed, 55 insertions(+), 29 deletions(-)
    >
    > Index: linux-2.6/crypto/authenc.c
    > ===================================================================
    > --- linux-2.6.orig/crypto/authenc.c
    > +++ linux-2.6/crypto/authenc.c
    > @@ -388,7 +388,8 @@ static int crypto_authenc_create(struct
    > if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask)
    > return -EINVAL;
    >
    > - mask = crypto_requires_sync(algt->type, algt->mask);
    > + mask = crypto_requires_sync(algt->type, algt->mask) |
    > + crypto_requires_nomem(algt->type, algt->mask);
    >
    > inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
    > if (!inst)
    > @@ -424,7 +425,7 @@ static int crypto_authenc_create(struct
    > goto err_free_inst;
    >
    > inst->alg.base.cra_flags = (auth_base->cra_flags |
    > - enc->base.cra_flags) & CRYPTO_ALG_ASYNC;
    > + enc->base.cra_flags) & (CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY);

    ASYNC and ALLOCATES_MEMORY are both handled the same way. They're both
    "inherited" from inner algorithms to the template instance. And if someone
    requests that one of these flags be clear when instantiating a template, then we
    have to honor the same for the inner algorithms too.

    So, shouldn't we define something like crypto_algt_mask() and
    CRYPTO_ALG_INHERITED_FLAGS and make them handle both ASYNC and ALLOCATES_MEMORY,
    rather than explicitly handling each of these flags everywhere again?

    - Eric

    \
     
     \ /
      Last update: 2020-06-16 19:43    [W:4.624 / U:0.032 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site