linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: inside-secure: safexcel - fix memory allocation
@ 2018-10-08 19:17 Gustavo A. R. Silva
  2018-10-08 22:20 ` Kees Cook
  2018-10-10 13:55 ` Antoine Tenart
  0 siblings, 2 replies; 9+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-08 19:17 UTC (permalink / raw)
  To: Antoine Tenart, Herbert Xu, David S. Miller, Kees Cook
  Cc: linux-crypto, linux-kernel, Gustavo A. R. Silva

The original intention is to allocate space for EIP197_DEFAULT_RING_SIZE
*pointers* to struct, so sizeof(priv->ring[i].rdr_req) should be
sizeof(*priv->ring[i].rdr_req).

Addresses-Coverity-ID: 1473962 ("Sizeof not portable")
Fixes: 9744fec95f06 ("crypto: inside-secure - remove request list to improve performance")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/crypto/inside-secure/safexcel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c
index 86c699c1..bc6c5cb 100644
--- a/drivers/crypto/inside-secure/safexcel.c
+++ b/drivers/crypto/inside-secure/safexcel.c
@@ -1066,7 +1066,7 @@ static int safexcel_probe(struct platform_device *pdev)
 
 		priv->ring[i].rdr_req = devm_kcalloc(dev,
 			EIP197_DEFAULT_RING_SIZE,
-			sizeof(priv->ring[i].rdr_req),
+			sizeof(*priv->ring[i].rdr_req),
 			GFP_KERNEL);
 		if (!priv->ring[i].rdr_req) {
 			ret = -ENOMEM;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] crypto: inside-secure: safexcel - fix memory allocation
  2018-10-08 19:17 [PATCH] crypto: inside-secure: safexcel - fix memory allocation Gustavo A. R. Silva
@ 2018-10-08 22:20 ` Kees Cook
  2018-10-16 19:44   ` Gustavo A. R. Silva
  2018-10-10 13:55 ` Antoine Tenart
  1 sibling, 1 reply; 9+ messages in thread
From: Kees Cook @ 2018-10-08 22:20 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Antoine Tenart, Herbert Xu, David S. Miller, linux-crypto, LKML

On Mon, Oct 8, 2018 at 12:17 PM, Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
> The original intention is to allocate space for EIP197_DEFAULT_RING_SIZE
> *pointers* to struct, so sizeof(priv->ring[i].rdr_req) should be
> sizeof(*priv->ring[i].rdr_req).
>
> Addresses-Coverity-ID: 1473962 ("Sizeof not portable")
> Fixes: 9744fec95f06 ("crypto: inside-secure - remove request list to improve performance")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

Luckily, this results in the same size, since it's still a pointer:

struct crypto_async_request **rdr_req;

But yes, it should be fixed.

-Kees

> ---
>  drivers/crypto/inside-secure/safexcel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c
> index 86c699c1..bc6c5cb 100644
> --- a/drivers/crypto/inside-secure/safexcel.c
> +++ b/drivers/crypto/inside-secure/safexcel.c
> @@ -1066,7 +1066,7 @@ static int safexcel_probe(struct platform_device *pdev)
>
>                 priv->ring[i].rdr_req = devm_kcalloc(dev,
>                         EIP197_DEFAULT_RING_SIZE,
> -                       sizeof(priv->ring[i].rdr_req),
> +                       sizeof(*priv->ring[i].rdr_req),
>                         GFP_KERNEL);
>                 if (!priv->ring[i].rdr_req) {
>                         ret = -ENOMEM;
> --
> 2.7.4
>



-- 
Kees Cook
Pixel Security

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] crypto: inside-secure: safexcel - fix memory allocation
  2018-10-08 19:17 [PATCH] crypto: inside-secure: safexcel - fix memory allocation Gustavo A. R. Silva
  2018-10-08 22:20 ` Kees Cook
@ 2018-10-10 13:55 ` Antoine Tenart
  1 sibling, 0 replies; 9+ messages in thread
From: Antoine Tenart @ 2018-10-10 13:55 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Antoine Tenart, Herbert Xu, David S. Miller, Kees Cook,
	linux-crypto, linux-kernel

Hi Gustavo,

On Mon, Oct 08, 2018 at 09:17:12PM +0200, Gustavo A. R. Silva wrote:
> The original intention is to allocate space for EIP197_DEFAULT_RING_SIZE
> *pointers* to struct, so sizeof(priv->ring[i].rdr_req) should be
> sizeof(*priv->ring[i].rdr_req).
> 
> Addresses-Coverity-ID: 1473962 ("Sizeof not portable")
> Fixes: 9744fec95f06 ("crypto: inside-secure - remove request list to improve performance")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Acked-by: Antoine Tenart <antoine.tenart@bootlin.com>

Good catch, thanks!
Antoine

> ---
>  drivers/crypto/inside-secure/safexcel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c
> index 86c699c1..bc6c5cb 100644
> --- a/drivers/crypto/inside-secure/safexcel.c
> +++ b/drivers/crypto/inside-secure/safexcel.c
> @@ -1066,7 +1066,7 @@ static int safexcel_probe(struct platform_device *pdev)
>  
>  		priv->ring[i].rdr_req = devm_kcalloc(dev,
>  			EIP197_DEFAULT_RING_SIZE,
> -			sizeof(priv->ring[i].rdr_req),
> +			sizeof(*priv->ring[i].rdr_req),
>  			GFP_KERNEL);
>  		if (!priv->ring[i].rdr_req) {
>  			ret = -ENOMEM;
> -- 
> 2.7.4
> 

-- 
Antoine Ténart, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] crypto: inside-secure: safexcel - fix memory allocation
  2018-10-08 22:20 ` Kees Cook
@ 2018-10-16 19:44   ` Gustavo A. R. Silva
  2018-10-17  6:17     ` Herbert Xu
  0 siblings, 1 reply; 9+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-16 19:44 UTC (permalink / raw)
  To: Kees Cook; +Cc: Antoine Tenart, Herbert Xu, David S. Miller, linux-crypto, LKML

Hi all,

On 10/9/18 12:20 AM, Kees Cook wrote:
> On Mon, Oct 8, 2018 at 12:17 PM, Gustavo A. R. Silva
> <gustavo@embeddedor.com> wrote:
>> The original intention is to allocate space for EIP197_DEFAULT_RING_SIZE
>> *pointers* to struct, so sizeof(priv->ring[i].rdr_req) should be
>> sizeof(*priv->ring[i].rdr_req).
>>
>> Addresses-Coverity-ID: 1473962 ("Sizeof not portable")
>> Fixes: 9744fec95f06 ("crypto: inside-secure - remove request list to improve performance")
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> 
> Reviewed-by: Kees Cook <keescook@chromium.org>
> 


Friendly ping. Who can take this?

Thanks!
--
Gustavo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] crypto: inside-secure: safexcel - fix memory allocation
  2018-10-16 19:44   ` Gustavo A. R. Silva
@ 2018-10-17  6:17     ` Herbert Xu
  2018-10-17  7:20       ` Antoine Tenart
  0 siblings, 1 reply; 9+ messages in thread
From: Herbert Xu @ 2018-10-17  6:17 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Kees Cook, Antoine Tenart, David S. Miller, linux-crypto, LKML

On Tue, Oct 16, 2018 at 09:44:02PM +0200, Gustavo A. R. Silva wrote:
> Hi all,
> 
> On 10/9/18 12:20 AM, Kees Cook wrote:
> > On Mon, Oct 8, 2018 at 12:17 PM, Gustavo A. R. Silva
> > <gustavo@embeddedor.com> wrote:
> >> The original intention is to allocate space for EIP197_DEFAULT_RING_SIZE
> >> *pointers* to struct, so sizeof(priv->ring[i].rdr_req) should be
> >> sizeof(*priv->ring[i].rdr_req).
> >>
> >> Addresses-Coverity-ID: 1473962 ("Sizeof not portable")
> >> Fixes: 9744fec95f06 ("crypto: inside-secure - remove request list to improve performance")
> >> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> > 
> > Reviewed-by: Kees Cook <keescook@chromium.org>
> > 
> 
> 
> Friendly ping. Who can take this?

Well I tried to take it but it doesn't apply against cryptodev.
So I presume this can go into the tree that carried the change
which it depended on?

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] 9+ messages in thread

* Re: [PATCH] crypto: inside-secure: safexcel - fix memory allocation
  2018-10-17  6:17     ` Herbert Xu
@ 2018-10-17  7:20       ` Antoine Tenart
  2018-10-17 14:41         ` Gustavo A. R. Silva
  0 siblings, 1 reply; 9+ messages in thread
From: Antoine Tenart @ 2018-10-17  7:20 UTC (permalink / raw)
  To: Herbert Xu
  Cc: Gustavo A. R. Silva, Kees Cook, Antoine Tenart, David S. Miller,
	linux-crypto, LKML

Hi,

On Wed, Oct 17, 2018 at 02:17:41PM +0800, Herbert Xu wrote:
> On Tue, Oct 16, 2018 at 09:44:02PM +0200, Gustavo A. R. Silva wrote:
> > On 10/9/18 12:20 AM, Kees Cook wrote:
> > > On Mon, Oct 8, 2018 at 12:17 PM, Gustavo A. R. Silva
> > > <gustavo@embeddedor.com> wrote:
> > >> The original intention is to allocate space for EIP197_DEFAULT_RING_SIZE
> > >> *pointers* to struct, so sizeof(priv->ring[i].rdr_req) should be
> > >> sizeof(*priv->ring[i].rdr_req).
> > >>
> > >> Addresses-Coverity-ID: 1473962 ("Sizeof not portable")
> > >> Fixes: 9744fec95f06 ("crypto: inside-secure - remove request list to improve performance")
> > >> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> > > 
> > > Reviewed-by: Kees Cook <keescook@chromium.org>
> > > 
> > 
> > 
> > Friendly ping. Who can take this?
> 
> Well I tried to take it but it doesn't apply against cryptodev.
> So I presume this can go into the tree that carried the change
> which it depended on?

I would say this should go in cryptodev. The issue is probably because
of other changes that got applied in the meantime. Gustavo can probably
rebase his patch on top of cryptodev, and re-send it.

Thanks!
Antoine

-- 
Antoine Ténart, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] crypto: inside-secure: safexcel - fix memory allocation
  2018-10-17  7:20       ` Antoine Tenart
@ 2018-10-17 14:41         ` Gustavo A. R. Silva
  2018-10-17 18:23           ` Kees Cook
  0 siblings, 1 reply; 9+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-17 14:41 UTC (permalink / raw)
  To: Antoine Tenart, Herbert Xu; +Cc: Kees Cook, David S. Miller, linux-crypto, LKML



On 10/17/18 9:20 AM, Antoine Tenart wrote:
> Hi,
> 
> On Wed, Oct 17, 2018 at 02:17:41PM +0800, Herbert Xu wrote:
>> On Tue, Oct 16, 2018 at 09:44:02PM +0200, Gustavo A. R. Silva wrote:
>>> On 10/9/18 12:20 AM, Kees Cook wrote:
>>>> On Mon, Oct 8, 2018 at 12:17 PM, Gustavo A. R. Silva
>>>> <gustavo@embeddedor.com> wrote:
>>>>> The original intention is to allocate space for EIP197_DEFAULT_RING_SIZE
>>>>> *pointers* to struct, so sizeof(priv->ring[i].rdr_req) should be
>>>>> sizeof(*priv->ring[i].rdr_req).
>>>>>
>>>>> Addresses-Coverity-ID: 1473962 ("Sizeof not portable")
>>>>> Fixes: 9744fec95f06 ("crypto: inside-secure - remove request list to improve performance")
>>>>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>>>>
>>>> Reviewed-by: Kees Cook <keescook@chromium.org>
>>>>
>>>
>>>
>>> Friendly ping. Who can take this?
>>
>> Well I tried to take it but it doesn't apply against cryptodev.
>> So I presume this can go into the tree that carried the change
>> which it depended on?
> 
> I would say this should go in cryptodev. The issue is probably because
> of other changes that got applied in the meantime. Gustavo can probably
> rebase his patch on top of cryptodev, and re-send it.
> 

cryptodev is missing the previous commit 329e09893909d409039f6a79757d9b80b67efe39
to which this patch applies.

Kees, did you apply the commit above to your tree?

If so, could you take this patch?

Thanks
--
Gustavo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] crypto: inside-secure: safexcel - fix memory allocation
  2018-10-17 14:41         ` Gustavo A. R. Silva
@ 2018-10-17 18:23           ` Kees Cook
  2018-10-18  6:24             ` Gustavo A. R. Silva
  0 siblings, 1 reply; 9+ messages in thread
From: Kees Cook @ 2018-10-17 18:23 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Antoine Tenart, Herbert Xu, David S. Miller, linux-crypto, LKML

On Wed, Oct 17, 2018 at 7:41 AM, Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
>
>
> On 10/17/18 9:20 AM, Antoine Tenart wrote:
>> Hi,
>>
>> On Wed, Oct 17, 2018 at 02:17:41PM +0800, Herbert Xu wrote:
>>> On Tue, Oct 16, 2018 at 09:44:02PM +0200, Gustavo A. R. Silva wrote:
>>>> On 10/9/18 12:20 AM, Kees Cook wrote:
>>>>> On Mon, Oct 8, 2018 at 12:17 PM, Gustavo A. R. Silva
>>>>> <gustavo@embeddedor.com> wrote:
>>>>>> The original intention is to allocate space for EIP197_DEFAULT_RING_SIZE
>>>>>> *pointers* to struct, so sizeof(priv->ring[i].rdr_req) should be
>>>>>> sizeof(*priv->ring[i].rdr_req).
>>>>>>
>>>>>> Addresses-Coverity-ID: 1473962 ("Sizeof not portable")
>>>>>> Fixes: 9744fec95f06 ("crypto: inside-secure - remove request list to improve performance")
>>>>>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>>>>>
>>>>> Reviewed-by: Kees Cook <keescook@chromium.org>
>>>>>
>>>>
>>>>
>>>> Friendly ping. Who can take this?
>>>
>>> Well I tried to take it but it doesn't apply against cryptodev.
>>> So I presume this can go into the tree that carried the change
>>> which it depended on?
>>
>> I would say this should go in cryptodev. The issue is probably because
>> of other changes that got applied in the meantime. Gustavo can probably
>> rebase his patch on top of cryptodev, and re-send it.
>>
>
> cryptodev is missing the previous commit 329e09893909d409039f6a79757d9b80b67efe39
> to which this patch applies.
>
> Kees, did you apply the commit above to your tree?
>
> If so, could you take this patch?

Since this has no functional exposure (the sizes are the same), let's
just wait until after the merge window to get this into crypto-next.

-Kees

-- 
Kees Cook
Pixel Security

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] crypto: inside-secure: safexcel - fix memory allocation
  2018-10-17 18:23           ` Kees Cook
@ 2018-10-18  6:24             ` Gustavo A. R. Silva
  0 siblings, 0 replies; 9+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-18  6:24 UTC (permalink / raw)
  To: Kees Cook; +Cc: Antoine Tenart, Herbert Xu, David S. Miller, linux-crypto, LKML


On 10/17/18 8:23 PM, Kees Cook wrote:

>>
>> If so, could you take this patch?
> 
> Since this has no functional exposure (the sizes are the same), let's
> just wait until after the merge window to get this into crypto-next.
> 

Okay. I agree.

Thanks!
--
Gustavo

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-10-18  6:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-08 19:17 [PATCH] crypto: inside-secure: safexcel - fix memory allocation Gustavo A. R. Silva
2018-10-08 22:20 ` Kees Cook
2018-10-16 19:44   ` Gustavo A. R. Silva
2018-10-17  6:17     ` Herbert Xu
2018-10-17  7:20       ` Antoine Tenart
2018-10-17 14:41         ` Gustavo A. R. Silva
2018-10-17 18:23           ` Kees Cook
2018-10-18  6:24             ` Gustavo A. R. Silva
2018-10-10 13:55 ` Antoine Tenart

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).