Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Milan Broz <gmazyland@gmail.com>
To: Gilad Ben-Yossef <gilad@benyossef.com>,
	dm-devel@redhat.com, Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@redhat.com>
Cc: linux-crypto@vger.kernel.org, gilad.benyossef@arm.com,
	ofir.drang@arm.com, "Eric Biggers" <ebiggers3@gmail.com>,
	"Ondrej Mosnáček" <omosnacek+linux-crypto@gmail.com>
Subject: Re: [PATCH v2] dm: switch dm-verity to async hash crypto API
Date: Fri, 17 Feb 2017 14:00:18 +0100	[thread overview]
Message-ID: <74bc1a00-6fb4-4b2f-b57b-a7fea0969eeb@gmail.com> (raw)
In-Reply-To: <1486389482-26992-1-git-send-email-gilad@benyossef.com>

On 02/06/2017 02:58 PM, Gilad Ben-Yossef wrote:
> Use of the synchronous digest API limits dm-verity to using pure
> CPU based algorithm providers and rules out the use of off CPU
> algorithm providers which are normally asynchronous by nature,
> potentially freeing CPU cycles.
> 
> This can reduce performance per Watt in situations such as during
> boot time when a lot of concurrent file accesses are made to the
> protected volume.
> 
> Move DM_VERITY to the asynchronous hash API.

Did you test that async hash completion path?

I just tried to force async crypto by replacing "sha256"
in mapping table with "cryptd(sha256-generic)" and it kills
kernel immediately.
https://mbroz.fedorapeople.org/tmp/verity-fail.png

(I hope this trick should cause to use cryptd and use async processing.
In previous version the parameter is properly rejected, because unsupported
by shash api.)


Some more comments below.
...

> -static int verity_hash_update(struct dm_verity *v, struct shash_desc *desc,
> -			      const u8 *data, size_t len)
> +static int verity_hash_update(struct dm_verity *v, struct ahash_request *req,
> +				const u8 *data, size_t len,
> +				struct verity_result *res)
>  {
> -	int r = crypto_shash_update(desc, data, len);
> +	struct scatterlist sg;
>  
> -	if (unlikely(r < 0))
> -		DMERR("crypto_shash_update failed: %d", r);
> +	sg_init_table(&sg, 1);
> +	sg_set_buf(&sg, data, len);

why not use sg_init_one?

> +	ahash_request_set_crypt(req, &sg, NULL, len);
> +
> +	return verity_complete_op(res, crypto_ahash_update(req));
> +}

...

> -int verity_hash(struct dm_verity *v, struct shash_desc *desc,
> +int verity_hash(struct dm_verity *v, struct ahash_request *req,
>  		const u8 *data, size_t len, u8 *digest)
>  {
>  	int r;
> +	struct verity_result res;
>  
> -	r = verity_hash_init(v, desc);
> +	r = verity_hash_init(v, req, &res);
>  	if (unlikely(r < 0))
> -		return r;
> +		goto out;

why it is changed to goto? it doesn't simplify anything in this function

>  
> -	r = verity_hash_update(v, desc, data, len);
> +	r = verity_hash_update(v, req, data, len, &res);
>  	if (unlikely(r < 0))
> -		return r;
> +		goto out;
> +
> +	r = verity_hash_final(v, req, digest, &res);
>  
> -	return verity_hash_final(v, desc, digest);
> +out:
> +	return r;
>  }


Milan

  reply	other threads:[~2017-02-17 13:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-06 13:58 [PATCH v2] dm: switch dm-verity to async hash crypto API Gilad Ben-Yossef
2017-02-17 13:00 ` Milan Broz [this message]
2017-02-17 14:47   ` Gilad Ben-Yossef
2017-02-19 12:37     ` Gilad Ben-Yossef
2017-02-17 14:52   ` Gilad Ben-Yossef

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=74bc1a00-6fb4-4b2f-b57b-a7fea0969eeb@gmail.com \
    --to=gmazyland@gmail.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=ebiggers3@gmail.com \
    --cc=gilad.benyossef@arm.com \
    --cc=gilad@benyossef.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=ofir.drang@arm.com \
    --cc=omosnacek+linux-crypto@gmail.com \
    --cc=snitzer@redhat.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