diff mbox series

crypto: inside-secure: safexcel - fix memory allocation

Message ID 20181008191712.GA12892@embeddedor.com (mailing list archive)
State Not Applicable
Delegated to: Herbert Xu
Headers show
Series crypto: inside-secure: safexcel - fix memory allocation | expand

Commit Message

Gustavo A. R. Silva Oct. 8, 2018, 7:17 p.m. UTC
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(-)

Comments

Kees Cook Oct. 8, 2018, 10:20 p.m. UTC | #1
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
>
Antoine Tenart Oct. 10, 2018, 1:55 p.m. UTC | #2
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
>
Gustavo A. R. Silva Oct. 16, 2018, 7:44 p.m. UTC | #3
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
Herbert Xu Oct. 17, 2018, 6:17 a.m. UTC | #4
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,
Antoine Tenart Oct. 17, 2018, 7:20 a.m. UTC | #5
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
Gustavo A. R. Silva Oct. 17, 2018, 2:41 p.m. UTC | #6
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
Kees Cook Oct. 17, 2018, 6:23 p.m. UTC | #7
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
Gustavo A. R. Silva Oct. 18, 2018, 6:24 a.m. UTC | #8
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
diff mbox series

Patch

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;