lkml.org 
[lkml]   [2015]   [Aug]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 09/31] crypto: use kmemdup rather than duplicating its implementation
On Fri, Aug 07, 2015 at 09:59:15AM +0200, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Actually I think you've identified a bug in the code.

> diff --git a/crypto/echainiv.c b/crypto/echainiv.c
> index d3896c7..d8968c0 100644
> --- a/crypto/echainiv.c
> +++ b/crypto/echainiv.c
> @@ -134,13 +134,10 @@ static int echainiv_encrypt(struct aead_request *req)
>
> if (unlikely(!IS_ALIGNED((unsigned long)info,
> crypto_aead_alignmask(geniv) + 1))) {
> - info = kmalloc(ivsize, req->base.flags &
> - CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL:
> - GFP_ATOMIC);
> + info = kmemdup(req->iv, ivsize,
> + req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : GFP_ATOMIC);
> if (!info)
> return -ENOMEM;
> -
> - memcpy(info, req->iv, ivsize);

This is meant to reallocate a buffer aligned to geniv but it isn't
actually doing that.

So we should be changing it to align the pointer rather than
converting it to memcpy.

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


\
 
 \ /
  Last update: 2015-08-07 10:21    [W:0.501 / U:0.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site