Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755982AbbHGIFr (ORCPT ); Fri, 7 Aug 2015 04:05:47 -0400 Received: from helcar.hengli.com.au ([209.40.204.226]:33077 "EHLO helcar.hengli.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753158AbbHGIFk (ORCPT ); Fri, 7 Aug 2015 04:05:40 -0400 Date: Fri, 7 Aug 2015 16:05:33 +0800 From: Herbert Xu To: Andrzej Hajda Cc: "David S. Miller" , Bartlomiej Zolnierkiewicz , Marek Szyprowski , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Subject: Re: [PATCH 09/31] crypto: use kmemdup rather than duplicating its implementation Message-ID: <20150807080533.GA26121@gondor.apana.org.au> References: <1438934377-4922-1-git-send-email-a.hajda@samsung.com> <1438934377-4922-10-git-send-email-a.hajda@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1438934377-4922-10-git-send-email-a.hajda@samsung.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1572 Lines: 44 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 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 Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/