Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1690856 > unrolled thread
| Started by | Tim Chen <tim.c.chen@linux.intel.com> |
|---|---|
| First post | 2017-07-19 03:00 +0200 |
| Last post | 2017-07-19 09:10 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH V6 5/7] crypto: AES CBC multi-buffer glue code Tim Chen <tim.c.chen@linux.intel.com> - 2017-07-19 03:00 +0200
Re: [PATCH V6 5/7] crypto: AES CBC multi-buffer glue code Megha Dey <megha.dey@intel.com> - 2017-07-19 03:10 +0200
Re: [PATCH V6 5/7] crypto: AES CBC multi-buffer glue code Herbert Xu <herbert@gondor.apana.org.au> - 2017-07-19 09:10 +0200
| From | Tim Chen <tim.c.chen@linux.intel.com> |
|---|---|
| Date | 2017-07-19 03:00 +0200 |
| Subject | Re: [PATCH V6 5/7] crypto: AES CBC multi-buffer glue code |
| Message-ID | <u4Lvk-15W-9@gated-at.bofh.it> |
On 07/17/2017 10:41 PM, Herbert Xu wrote:
> On Tue, Jun 27, 2017 at 05:26:13PM -0700, Megha Dey wrote:
>>
>> +static void completion_callback(struct mcryptd_skcipher_request_ctx *rctx,
>> + struct mcryptd_alg_cstate *cstate,
>> + int err)
>> +{
>> + struct skcipher_request *req = cast_mcryptd_ctx_to_req(rctx);
>> +
>> + /* remove from work list and invoke completion callback */
>> + spin_lock(&cstate->work_lock);
>> + list_del(&rctx->waiter);
>> + spin_unlock(&cstate->work_lock);
>> +
>> + if (irqs_disabled())
>> + rctx->complete(&req->base, err);
>> + else {
>> + local_bh_disable();
>> + rctx->complete(&req->base, err);
>> + local_bh_enable();
>> + }
>> +}
>
> The fact that you need to do this check means that this design is
> wrong. You should always know what context you are in.
>
I think you are right. The irqs_disabled check is not necessary
as we only call this function in the context of the mcryptd thread.
When I wrote the original mb algorithms I was probably unsure
and put this check in as a precaution in other mb algorithms and
Megha did the same.
>> +/*
>> + * CRYPTO_ALG_ASYNC flag is passed to indicate we have an ablk
>> + * scatter-gather walk.
>> + */
>> +static struct skcipher_alg aes_cbc_mb_alg = {
>> + .base = {
>> + .cra_name = "cbc(aes)",
>> + .cra_driver_name = "cbc-aes-aesni-mb",
>> + .cra_priority = 500,
>> + .cra_flags = CRYPTO_ALG_INTERNAL,
>> + .cra_blocksize = AES_BLOCK_SIZE,
>> + .cra_ctxsize = CRYPTO_AES_CTX_SIZE,
>> + .cra_module = THIS_MODULE,
>> + },
>> + .min_keysize = AES_MIN_KEY_SIZE,
>> + .max_keysize = AES_MAX_KEY_SIZE,
>> + .ivsize = AES_BLOCK_SIZE,
>> + .setkey = aes_set_key,
>> + .encrypt = mb_aes_cbc_encrypt,
>> + .decrypt = mb_aes_cbc_decrypt
>> +};
>
> So this claims to be a sync algorithm. Is this really the case?
>
> Cheers,
>
[toc] | [next] | [standalone]
| From | Megha Dey <megha.dey@intel.com> |
|---|---|
| Date | 2017-07-19 03:10 +0200 |
| Message-ID | <u4LEZ-1qm-5@gated-at.bofh.it> |
| In reply to | #1690856 |
On Tue, 2017-07-18 at 17:52 -0700, Tim Chen wrote:
> On 07/17/2017 10:41 PM, Herbert Xu wrote:
> > On Tue, Jun 27, 2017 at 05:26:13PM -0700, Megha Dey wrote:
> >>
> >> +static void completion_callback(struct mcryptd_skcipher_request_ctx *rctx,
> >> + struct mcryptd_alg_cstate *cstate,
> >> + int err)
> >> +{
> >> + struct skcipher_request *req = cast_mcryptd_ctx_to_req(rctx);
> >> +
> >> + /* remove from work list and invoke completion callback */
> >> + spin_lock(&cstate->work_lock);
> >> + list_del(&rctx->waiter);
> >> + spin_unlock(&cstate->work_lock);
> >> +
> >> + if (irqs_disabled())
> >> + rctx->complete(&req->base, err);
> >> + else {
> >> + local_bh_disable();
> >> + rctx->complete(&req->base, err);
> >> + local_bh_enable();
> >> + }
> >> +}
> >
> > The fact that you need to do this check means that this design is
> > wrong. You should always know what context you are in.
> >
>
> I think you are right. The irqs_disabled check is not necessary
> as we only call this function in the context of the mcryptd thread.
> When I wrote the original mb algorithms I was probably unsure
> and put this check in as a precaution in other mb algorithms and
> Megha did the same.
I will make this change.
>
> >> +/*
> >> + * CRYPTO_ALG_ASYNC flag is passed to indicate we have an ablk
> >> + * scatter-gather walk.
> >> + */
> >> +static struct skcipher_alg aes_cbc_mb_alg = {
> >> + .base = {
> >> + .cra_name = "cbc(aes)",
> >> + .cra_driver_name = "cbc-aes-aesni-mb",
> >> + .cra_priority = 500,
> >> + .cra_flags = CRYPTO_ALG_INTERNAL,
> >> + .cra_blocksize = AES_BLOCK_SIZE,
> >> + .cra_ctxsize = CRYPTO_AES_CTX_SIZE,
> >> + .cra_module = THIS_MODULE,
> >> + },
> >> + .min_keysize = AES_MIN_KEY_SIZE,
> >> + .max_keysize = AES_MAX_KEY_SIZE,
> >> + .ivsize = AES_BLOCK_SIZE,
> >> + .setkey = aes_set_key,
> >> + .encrypt = mb_aes_cbc_encrypt,
> >> + .decrypt = mb_aes_cbc_decrypt
> >> +};
> >
> > So this claims to be a sync algorithm. Is this really the case?
yes, the inner algorithm is sync whereas the outer algorithm is async.
> >
> > Cheers,
> >
>
[toc] | [prev] | [next] | [standalone]
| From | Herbert Xu <herbert@gondor.apana.org.au> |
|---|---|
| Date | 2017-07-19 09:10 +0200 |
| Message-ID | <u4Rhp-5as-51@gated-at.bofh.it> |
| In reply to | #1690861 |
On Tue, Jul 18, 2017 at 06:18:59PM -0700, Megha Dey wrote:
>
> > >> +/*
> > >> + * CRYPTO_ALG_ASYNC flag is passed to indicate we have an ablk
> > >> + * scatter-gather walk.
> > >> + */
> > >> +static struct skcipher_alg aes_cbc_mb_alg = {
> > >> + .base = {
> > >> + .cra_name = "cbc(aes)",
> > >> + .cra_driver_name = "cbc-aes-aesni-mb",
> > >> + .cra_priority = 500,
> > >> + .cra_flags = CRYPTO_ALG_INTERNAL,
> > >> + .cra_blocksize = AES_BLOCK_SIZE,
> > >> + .cra_ctxsize = CRYPTO_AES_CTX_SIZE,
> > >> + .cra_module = THIS_MODULE,
> > >> + },
> > >> + .min_keysize = AES_MIN_KEY_SIZE,
> > >> + .max_keysize = AES_MAX_KEY_SIZE,
> > >> + .ivsize = AES_BLOCK_SIZE,
> > >> + .setkey = aes_set_key,
> > >> + .encrypt = mb_aes_cbc_encrypt,
> > >> + .decrypt = mb_aes_cbc_decrypt
> > >> +};
> > >
> > > So this claims to be a sync algorithm. Is this really the case?
>
> yes, the inner algorithm is sync whereas the outer algorithm is async.
Are you saying that once mb_aes_cbc_encrypt returns it will never
touch the input/output again? This doesn't seem to agree with the
actual code:
+ if (!ret_rctx) {
+ /* we submitted a job, but none completed */
+ /* just notify the caller */
+ notify_callback(rctx, cstate, -EINPROGRESS);
+ return 0;
+ }
Just because an algorithm is internal doesn't mean that it can
arbitrarily violate the crypto API requirements.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web