public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	Mike Snitzer <msnitzer@redhat.com>,
	linux-kernel@vger.kernel.org, dm-devel@redhat.com,
	linux-crypto@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Milan Broz <mbroz@redhat.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	George Cherian <gcherian@marvell.com>,
	Wei Xu <xuwei5@hisilicon.com>, Zaibo Xu <xuzaibo@huawei.com>
Subject: Re: [PATCH 1/3 v2] crypto: introduce the flag CRYPTO_ALG_ALLOCATES_MEMORY
Date: Sun, 28 Jun 2020 12:46:39 -0700	[thread overview]
Message-ID: <20200628194639.GC11197@sol.localdomain> (raw)
In-Reply-To: <alpine.LRH.2.02.2006281501230.347@file01.intranet.prod.int.rdu2.redhat.com>

On Sun, Jun 28, 2020 at 03:04:22PM -0400, Mikulas Patocka wrote:
> > > Index: linux-2.6/crypto/authenc.c
> > > ===================================================================
> > > --- linux-2.6.orig/crypto/authenc.c	2020-06-26 17:24:03.566417000 +0200
> > > +++ linux-2.6/crypto/authenc.c	2020-06-26 17:24:03.566417000 +0200
> > > @@ -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);
> > 
> > As I suggested earlier, shouldn't there be a function that returns the mask for
> > all inherited flags, rather than handling each flag individually?
> 
> Yes - I've created crypto_requires_inherited for this purpose.

Since all callers pass in 'struct crypto_attr_type', a better helper might be:

static inline int crypto_algt_inherited_mask(struct crypto_attr_type *algt)
{
	return crypto_requires_off(algt->type, algt->mask,
				   CRYPTO_ALG_INHERITED_FLAGS);
}

> > > @@ -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_INHERITED_FLAGS;
> > 
> > Strange indentation here.  Likewise in most of the other files.
> 
> I was told that the code should be 80-characters wide.

You could use:

	inst->alg.base.cra_flags =
		(auth_base->cra_flags | enc->base.cra_flags) &
		CRYPTO_ALG_INHERITED_FLAGS;

Just a suggestion, it's not a big deal...  Your indentation of the continuation
line just seems weird.

> > > --- linux-2.6.orig/crypto/xts.c	2020-06-26 17:24:03.566417000 +0200
> > > +++ linux-2.6/crypto/xts.c	2020-06-26 17:24:03.566417000 +0200
> > > @@ -415,7 +415,7 @@ static int create(struct crypto_template
> > >  	} else
> > >  		goto err_free_inst;
> > >  
> > > -	inst->alg.base.cra_flags = alg->base.cra_flags & CRYPTO_ALG_ASYNC;
> > > +	inst->alg.base.cra_flags = alg->base.cra_flags & CRYPTO_ALG_INHERITED_FLAGS;
> > >  	inst->alg.base.cra_priority = alg->base.cra_priority;
> > >  	inst->alg.base.cra_blocksize = XTS_BLOCK_SIZE;
> > >  	inst->alg.base.cra_alignmask = alg->base.cra_alignmask |
> > 
> > Need to set the mask correctly in this file.
> 
> I don't know what do you mean.

I mean that the CRYPTO_ALG_ALLOCATES_MEMORY flag is not handled when the 'mask'
variable is assigned to earlier in this function.

It should use your new helper function, like all the other places in this patch.

- Eric

  reply	other threads:[~2020-06-28 19:46 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-09 17:11 crypto API and GFP_ATOMIC Mikulas Patocka
2020-06-10  1:04 ` Herbert Xu
2020-06-10 12:02   ` Mikulas Patocka
2020-06-10 12:11     ` Herbert Xu
2020-06-16 15:01       ` Mikulas Patocka
2020-06-16 15:01         ` [PATCH 1/4] crypto: introduce CRYPTO_ALG_ALLOCATES_MEMORY Mikulas Patocka
2020-06-16 17:36           ` [dm-devel] " Eric Biggers
2020-06-17 15:08             ` Mikulas Patocka
2020-06-17 15:09               ` [PATCH 1/3] crypto: pass the flag CRYPTO_ALG_ALLOCATES_MEMORY Mikulas Patocka
2020-06-26  4:45                 ` Herbert Xu
2020-06-26 15:17                   ` Mikulas Patocka
2020-06-26 16:16                     ` [PATCH 1/3 v2] crypto: introduce " Mikulas Patocka
2020-06-26 16:46                       ` Eric Biggers
2020-06-26 17:00                         ` [dm-devel] " Eric Biggers
2020-06-28 19:07                           ` Mikulas Patocka
2020-06-28 19:50                             ` Eric Biggers
2020-06-30 13:57                               ` Mikulas Patocka
2020-06-28 20:00                             ` Eric Biggers
2020-06-29 13:17                               ` Mikulas Patocka
2020-06-30 13:45                                 ` Mikulas Patocka
2020-06-28 19:04                         ` Mikulas Patocka
2020-06-28 19:46                           ` Eric Biggers [this message]
2020-06-28 19:05                         ` [PATCH 1/3 v3] " Mikulas Patocka
2020-06-30 13:56                           ` [PATCH 1/3 v4] " Mikulas Patocka
2020-06-30 16:35                             ` [dm-devel] " Eric Biggers
2020-06-30 17:01                               ` Mikulas Patocka
2020-06-30 17:02                                 ` [PATCH 1/3 v5] " Mikulas Patocka
2020-06-30 17:57                                 ` [dm-devel] [PATCH 1/3 v4] " Eric Biggers
2020-06-30 18:14                                   ` Mikulas Patocka
2020-06-30 18:15                                     ` [PATCH 1/3 v6] " Mikulas Patocka
2020-07-01  1:49                                       ` Herbert Xu
2020-06-17 15:10               ` [PATCH 2/3] crypto: set " Mikulas Patocka
2020-06-17 15:11               ` [PATCH 3/3] dm-crypt: don't use drivers that have CRYPTO_ALG_ALLOCATES_MEMORY Mikulas Patocka
2020-06-16 15:01         ` [PATCH 2/4] crypto: pass the flag CRYPTO_ALG_ALLOCATES_MEMORY Mikulas Patocka
2020-06-16 17:42           ` [dm-devel] " Eric Biggers
2020-06-16 15:02         ` [PATCH 3/4] crypto: set " Mikulas Patocka
2020-06-16 17:43           ` [dm-devel] " Eric Biggers
2020-06-16 15:02         ` [PATCH 4/4] crypto: fix the drivers that don't respect CRYPTO_TFM_REQ_MAY_SLEEP Mikulas Patocka
2020-06-16 17:50           ` [dm-devel] " Eric Biggers
2020-06-16 18:18             ` Mikulas Patocka
2020-06-16 18:23               ` Eric Biggers
2020-06-17 13:46                 ` Mikulas Patocka
2020-06-17 13:48                   ` [PATCH 1/2] cpt-crypto: don't sleep of CRYPTO_TFM_REQ_MAY_SLEEP was not specified Mikulas Patocka
2020-06-26  6:07                     ` Herbert Xu
2020-06-17 13:49                   ` [PATCH 2/2] hisilicon-crypto: " Mikulas Patocka
2020-06-17 14:11                     ` [dm-devel] " Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200628194639.GC11197@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=davem@davemloft.net \
    --cc=dm-devel@redhat.com \
    --cc=gcherian@marvell.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbroz@redhat.com \
    --cc=mpatocka@redhat.com \
    --cc=msnitzer@redhat.com \
    --cc=xuwei5@hisilicon.com \
    --cc=xuzaibo@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox