linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Mike Snitzer <snitzer@kernel.org>,
	linux-kernel@vger.kernel.org,
	Nathan Huckleberry <nhuck@google.com>,
	dm-devel@redhat.com, Sami Tolvanen <samitolvanen@google.com>,
	Alasdair Kergon <agk@redhat.com>
Subject: Re: [PATCH 3/3] dm-verity: Add try_verify_in_tasklet
Date: Tue, 26 Jul 2022 00:13:37 -0400	[thread overview]
Message-ID: <Yt9p8VupWC0ZlFv4@redhat.com> (raw)
In-Reply-To: <Yt9aGRXNNPGZFvld@sol.localdomain>

On Mon, Jul 25 2022 at 11:06P -0400,
Eric Biggers <ebiggers@kernel.org> wrote:

> On Mon, Jul 25, 2022 at 09:58:39PM -0400, Mike Snitzer wrote:
> > 
> > > @@ -1156,7 +1217,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
> > >  		goto bad;
> > >  	}
> > >  
> > > -	v->tfm = crypto_alloc_ahash(v->alg_name, 0, 0);
> > > +	v->tfm = crypto_alloc_ahash(v->alg_name, 0, CRYPTO_ALG_ASYNC);
> > >  	if (IS_ERR(v->tfm)) {
> > >  		ti->error = "Cannot initialize hash function";
> > >  		r = PTR_ERR(v->tfm);
> > 
> > This hunk that adds the CRYPTO_ALG_ASYNC flag _seems_ unrelated.
> 
> I believe it's needed to ensure that only a synchronous algorithm is allocated,
> so that verity_hash_update() doesn't have to sleep during the tasklet.  It
> should be conditional on v->use_tasklet, though.

Ah yes, it is a mask, that makes sense.

I can now see why it was being set unconditionally given dm-verity's
optional ctr args aren't processed until after the crypto_alloc_ahash() call. 
And of course verity_parse_opt_args() depends on non-optional args
related to the tfm.... gah!

Do you have a sense for what the implications are for always setting
CRYPTO_ALG_ASYNC like Nathan had? Will it disallow certain tfm that
may already be in use by some users?

> > @@ -321,14 +320,12 @@ static int verity_verify_level(struct dm_verity *v, struct dm_verity_io *io,
> >  		if (likely(memcmp(verity_io_real_digest(v, io), want_digest,
> >  				  v->digest_size) == 0))
> >  			aux->hash_verified = 1;
> > -		else if (io->in_tasklet) {
> > +		else if (io->in_tasklet)
> >  			/*
> >  			 * FEC code cannot be run in a tasklet since it may
> > -			 * sleep.  We need to resume execution in a work-queue
> > -			 * to handle FEC.
> > +			 * sleep, so fallback to using a work-queue.
> >  			 */
> >  			return -EAGAIN;
> > -		}
> 
> 
> Doesn't this need to be:
> 
> 			r = -EAGAIN;
> 			goto release_ret_r;

Yes, good catch.

Thanks,
Mike


  reply	other threads:[~2022-07-26  4:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-22  9:38 [PATCH 0/3] dm-verity: optionally use tasklets in dm-verity Nathan Huckleberry
2022-07-22  9:38 ` [PATCH 1/3] dm-bufio: Add flags for dm_bufio_client_create Nathan Huckleberry
2022-07-22  9:38 ` [PATCH 2/3] dm-bufio: Add DM_BUFIO_GET_CANT_SLEEP Nathan Huckleberry
2022-07-22  9:38 ` [PATCH 3/3] dm-verity: Add try_verify_in_tasklet Nathan Huckleberry
2022-07-26  1:58   ` Mike Snitzer
2022-07-26  3:06     ` Eric Biggers
2022-07-26  4:13       ` Mike Snitzer [this message]
2022-07-22 16:41 ` [PATCH 0/3] dm-verity: optionally use tasklets in dm-verity Christoph Hellwig
2022-07-22 17:12   ` Mike Snitzer
2022-08-15 11:35     ` Sebastian Andrzej Siewior
2022-07-22 18:12   ` [dm-devel] " Bart Van Assche
2022-07-22 18:33     ` Mike Snitzer

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=Yt9p8VupWC0ZlFv4@redhat.com \
    --to=snitzer@redhat.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=ebiggers@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nhuck@google.com \
    --cc=samitolvanen@google.com \
    --cc=snitzer@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).