* [PATCH] crypto/simd: correctly take reqsize of wrapped skcipher into account
@ 2018-11-08 22:55 Ard Biesheuvel
2018-11-08 23:33 ` Ard Biesheuvel
0 siblings, 1 reply; 11+ messages in thread
From: Ard Biesheuvel @ 2018-11-08 22:55 UTC (permalink / raw)
To: linux-crypto; +Cc: herbert, cai, Ard Biesheuvel
The simd wrapper's skcipher request context structure consists
of a single subrequest whose size is taken from the subordinate
skcipher. However, in simd_skcipher_init(), the reqsize that is
retrieved is not from the subordinate skcipher but from the
cryptd request structure, whose size is completely unrelated to
the actual wrapped skcipher.
Reported-by: Qian Cai <cai@gmx.us>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
crypto/simd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/crypto/simd.c b/crypto/simd.c
index ea7240be3001..2f3d6e897afc 100644
--- a/crypto/simd.c
+++ b/crypto/simd.c
@@ -125,7 +125,7 @@ static int simd_skcipher_init(struct crypto_skcipher *tfm)
ctx->cryptd_tfm = cryptd_tfm;
reqsize = sizeof(struct skcipher_request);
- reqsize += crypto_skcipher_reqsize(&cryptd_tfm->base);
+ reqsize += crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm));
crypto_skcipher_set_reqsize(tfm, reqsize);
--
2.19.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] crypto/simd: correctly take reqsize of wrapped skcipher into account
@ 2018-11-08 23:33 ` Ard Biesheuvel
0 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel @ 2018-11-08 23:33 UTC (permalink / raw)
To: open list:HARDWARE RANDOM NUMBER GENERATOR CORE
Cc: Herbert Xu, Qian Cai, Ard Biesheuvel
On 8 November 2018 at 23:55, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> The simd wrapper's skcipher request context structure consists
> of a single subrequest whose size is taken from the subordinate
> skcipher. However, in simd_skcipher_init(), the reqsize that is
> retrieved is not from the subordinate skcipher but from the
> cryptd request structure, whose size is completely unrelated to
> the actual wrapped skcipher.
>
> Reported-by: Qian Cai <cai@gmx.us>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> crypto/simd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/crypto/simd.c b/crypto/simd.c
> index ea7240be3001..2f3d6e897afc 100644
> --- a/crypto/simd.c
> +++ b/crypto/simd.c
> @@ -125,7 +125,7 @@ static int simd_skcipher_init(struct crypto_skcipher *tfm)
> ctx->cryptd_tfm = cryptd_tfm;
>
> reqsize = sizeof(struct skcipher_request);
> - reqsize += crypto_skcipher_reqsize(&cryptd_tfm->base);
> + reqsize += crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm));
>
This should be
reqsize += max(crypto_skcipher_reqsize(&cryptd_tfm->base);
crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm)));
since the cryptd path in simd still needs some space in the subreq for
the completion.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] crypto/simd: correctly take reqsize of wrapped skcipher into account
@ 2018-11-08 23:33 ` Ard Biesheuvel
0 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel @ 2018-11-08 23:33 UTC (permalink / raw)
To: open list:HARDWARE RANDOM NUMBER GENERATOR CORE
Cc: Herbert Xu, Qian Cai, Ard Biesheuvel
On 8 November 2018 at 23:55, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> The simd wrapper's skcipher request context structure consists
> of a single subrequest whose size is taken from the subordinate
> skcipher. However, in simd_skcipher_init(), the reqsize that is
> retrieved is not from the subordinate skcipher but from the
> cryptd request structure, whose size is completely unrelated to
> the actual wrapped skcipher.
>
> Reported-by: Qian Cai <cai@gmx.us>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> crypto/simd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/crypto/simd.c b/crypto/simd.c
> index ea7240be3001..2f3d6e897afc 100644
> --- a/crypto/simd.c
> +++ b/crypto/simd.c
> @@ -125,7 +125,7 @@ static int simd_skcipher_init(struct crypto_skcipher *tfm)
> ctx->cryptd_tfm = cryptd_tfm;
>
> reqsize = sizeof(struct skcipher_request);
> - reqsize += crypto_skcipher_reqsize(&cryptd_tfm->base);
> + reqsize += crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm));
>
This should be
reqsize += max(crypto_skcipher_reqsize(&cryptd_tfm->base);
crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm)));
since the cryptd path in simd still needs some space in the subreq for
the completion.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] crypto/simd: correctly take reqsize of wrapped skcipher into account
@ 2018-11-09 1:05 ` Qian Cai
0 siblings, 0 replies; 11+ messages in thread
From: Qian Cai @ 2018-11-09 1:05 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Herbert Xu
> On Nov 8, 2018, at 6:33 PM, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
> On 8 November 2018 at 23:55, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>> The simd wrapper's skcipher request context structure consists
>> of a single subrequest whose size is taken from the subordinate
>> skcipher. However, in simd_skcipher_init(), the reqsize that is
>> retrieved is not from the subordinate skcipher but from the
>> cryptd request structure, whose size is completely unrelated to
>> the actual wrapped skcipher.
>>
>> Reported-by: Qian Cai <cai@gmx.us>
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>> crypto/simd.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/crypto/simd.c b/crypto/simd.c
>> index ea7240be3001..2f3d6e897afc 100644
>> --- a/crypto/simd.c
>> +++ b/crypto/simd.c
>> @@ -125,7 +125,7 @@ static int simd_skcipher_init(struct crypto_skcipher *tfm)
>> ctx->cryptd_tfm = cryptd_tfm;
>>
>> reqsize = sizeof(struct skcipher_request);
>> - reqsize += crypto_skcipher_reqsize(&cryptd_tfm->base);
>> + reqsize += crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm));
>>
>
> This should be
>
> reqsize += max(crypto_skcipher_reqsize(&cryptd_tfm->base);
> crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm)));
>
> since the cryptd path in simd still needs some space in the subreq for
> the completion.
Tested-by: Qian Cai <cai@gmx.us>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] crypto/simd: correctly take reqsize of wrapped skcipher into account
@ 2018-11-09 1:05 ` Qian Cai
0 siblings, 0 replies; 11+ messages in thread
From: Qian Cai @ 2018-11-09 1:05 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Herbert Xu
> On Nov 8, 2018, at 6:33 PM, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
> On 8 November 2018 at 23:55, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>> The simd wrapper's skcipher request context structure consists
>> of a single subrequest whose size is taken from the subordinate
>> skcipher. However, in simd_skcipher_init(), the reqsize that is
>> retrieved is not from the subordinate skcipher but from the
>> cryptd request structure, whose size is completely unrelated to
>> the actual wrapped skcipher.
>>
>> Reported-by: Qian Cai <cai@gmx.us>
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>> crypto/simd.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/crypto/simd.c b/crypto/simd.c
>> index ea7240be3001..2f3d6e897afc 100644
>> --- a/crypto/simd.c
>> +++ b/crypto/simd.c
>> @@ -125,7 +125,7 @@ static int simd_skcipher_init(struct crypto_skcipher *tfm)
>> ctx->cryptd_tfm = cryptd_tfm;
>>
>> reqsize = sizeof(struct skcipher_request);
>> - reqsize += crypto_skcipher_reqsize(&cryptd_tfm->base);
>> + reqsize += crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm));
>>
>
> This should be
>
> reqsize += max(crypto_skcipher_reqsize(&cryptd_tfm->base);
> crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm)));
>
> since the cryptd path in simd still needs some space in the subreq for
> the completion.
Tested-by: Qian Cai <cai@gmx.us>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] crypto/simd: correctly take reqsize of wrapped skcipher into account
@ 2018-11-09 9:44 ` Herbert Xu
0 siblings, 0 replies; 11+ messages in thread
From: Herbert Xu @ 2018-11-09 9:44 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Qian Cai
On Fri, Nov 09, 2018 at 12:33:23AM +0100, Ard Biesheuvel wrote:
>
> This should be
>
> reqsize += max(crypto_skcipher_reqsize(&cryptd_tfm->base);
> crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm)));
>
> since the cryptd path in simd still needs some space in the subreq for
> the completion.
OK this is what I applied to the cryptodev tree, please double-check
to see if I did anything silly:
diff --git a/crypto/simd.c b/crypto/simd.c
index ea7240be3001..78e8d037ae2b 100644
--- a/crypto/simd.c
+++ b/crypto/simd.c
@@ -124,8 +124,9 @@ static int simd_skcipher_init(struct crypto_skcipher *tfm)
ctx->cryptd_tfm = cryptd_tfm;
- reqsize = sizeof(struct skcipher_request);
- reqsize += crypto_skcipher_reqsize(&cryptd_tfm->base);
+ reqsize = crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm));
+ reqsize = max(reqsize, crypto_skcipher_reqsize(&cryptd_tfm->base));
+ reqsize += sizeof(struct skcipher_request);
crypto_skcipher_set_reqsize(tfm, reqsize);
Thanks,
--
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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] crypto/simd: correctly take reqsize of wrapped skcipher into account
@ 2018-11-09 9:44 ` Herbert Xu
0 siblings, 0 replies; 11+ messages in thread
From: Herbert Xu @ 2018-11-09 9:44 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Qian Cai
On Fri, Nov 09, 2018 at 12:33:23AM +0100, Ard Biesheuvel wrote:
>
> This should be
>
> reqsize += max(crypto_skcipher_reqsize(&cryptd_tfm->base);
> crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm)));
>
> since the cryptd path in simd still needs some space in the subreq for
> the completion.
OK this is what I applied to the cryptodev tree, please double-check
to see if I did anything silly:
diff --git a/crypto/simd.c b/crypto/simd.c
index ea7240be3001..78e8d037ae2b 100644
--- a/crypto/simd.c
+++ b/crypto/simd.c
@@ -124,8 +124,9 @@ static int simd_skcipher_init(struct crypto_skcipher *tfm)
ctx->cryptd_tfm = cryptd_tfm;
- reqsize = sizeof(struct skcipher_request);
- reqsize += crypto_skcipher_reqsize(&cryptd_tfm->base);
+ reqsize = crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm));
+ reqsize = max(reqsize, crypto_skcipher_reqsize(&cryptd_tfm->base));
+ reqsize += sizeof(struct skcipher_request);
crypto_skcipher_set_reqsize(tfm, reqsize);
Thanks,
--
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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] crypto/simd: correctly take reqsize of wrapped skcipher into account
@ 2018-11-09 9:45 ` Herbert Xu
0 siblings, 0 replies; 11+ messages in thread
From: Herbert Xu @ 2018-11-09 9:45 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Qian Cai
On Fri, Nov 09, 2018 at 05:44:47PM +0800, Herbert Xu wrote:
> On Fri, Nov 09, 2018 at 12:33:23AM +0100, Ard Biesheuvel wrote:
> >
> > This should be
> >
> > reqsize += max(crypto_skcipher_reqsize(&cryptd_tfm->base);
> > crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm)));
> >
> > since the cryptd path in simd still needs some space in the subreq for
> > the completion.
>
> OK this is what I applied to the cryptodev tree, please double-check
> to see if I did anything silly:
I meant the crypto tree rather than cryptodev.
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] crypto/simd: correctly take reqsize of wrapped skcipher into account
@ 2018-11-09 9:45 ` Herbert Xu
0 siblings, 0 replies; 11+ messages in thread
From: Herbert Xu @ 2018-11-09 9:45 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Qian Cai
On Fri, Nov 09, 2018 at 05:44:47PM +0800, Herbert Xu wrote:
> On Fri, Nov 09, 2018 at 12:33:23AM +0100, Ard Biesheuvel wrote:
> >
> > This should be
> >
> > reqsize += max(crypto_skcipher_reqsize(&cryptd_tfm->base);
> > crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm)));
> >
> > since the cryptd path in simd still needs some space in the subreq for
> > the completion.
>
> OK this is what I applied to the cryptodev tree, please double-check
> to see if I did anything silly:
I meant the crypto tree rather than cryptodev.
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] crypto/simd: correctly take reqsize of wrapped skcipher into account
@ 2018-11-09 9:46 ` Ard Biesheuvel
0 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel @ 2018-11-09 9:46 UTC (permalink / raw)
To: Herbert Xu; +Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Qian Cai
On 9 November 2018 at 10:45, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> On Fri, Nov 09, 2018 at 05:44:47PM +0800, Herbert Xu wrote:
>> On Fri, Nov 09, 2018 at 12:33:23AM +0100, Ard Biesheuvel wrote:
>> >
>> > This should be
>> >
>> > reqsize += max(crypto_skcipher_reqsize(&cryptd_tfm->base);
>> > crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm)));
>> >
>> > since the cryptd path in simd still needs some space in the subreq for
>> > the completion.
>>
>> OK this is what I applied to the cryptodev tree, please double-check
>> to see if I did anything silly:
>
> I meant the crypto tree rather than cryptodev.
>
That looks fine. Thanks Herbert.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] crypto/simd: correctly take reqsize of wrapped skcipher into account
@ 2018-11-09 9:46 ` Ard Biesheuvel
0 siblings, 0 replies; 11+ messages in thread
From: Ard Biesheuvel @ 2018-11-09 9:46 UTC (permalink / raw)
To: Herbert Xu; +Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Qian Cai
On 9 November 2018 at 10:45, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> On Fri, Nov 09, 2018 at 05:44:47PM +0800, Herbert Xu wrote:
>> On Fri, Nov 09, 2018 at 12:33:23AM +0100, Ard Biesheuvel wrote:
>> >
>> > This should be
>> >
>> > reqsize += max(crypto_skcipher_reqsize(&cryptd_tfm->base);
>> > crypto_skcipher_reqsize(cryptd_skcipher_child(cryptd_tfm)));
>> >
>> > since the cryptd path in simd still needs some space in the subreq for
>> > the completion.
>>
>> OK this is what I applied to the cryptodev tree, please double-check
>> to see if I did anything silly:
>
> I meant the crypto tree rather than cryptodev.
>
That looks fine. Thanks Herbert.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2018-11-09 19:26 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-08 22:55 [PATCH] crypto/simd: correctly take reqsize of wrapped skcipher into account Ard Biesheuvel
2018-11-08 23:33 ` Ard Biesheuvel
2018-11-08 23:33 ` Ard Biesheuvel
2018-11-09 1:05 ` Qian Cai
2018-11-09 1:05 ` Qian Cai
2018-11-09 9:44 ` Herbert Xu
2018-11-09 9:44 ` Herbert Xu
2018-11-09 9:45 ` Herbert Xu
2018-11-09 9:45 ` Herbert Xu
2018-11-09 9:46 ` Ard Biesheuvel
2018-11-09 9:46 ` Ard Biesheuvel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.