Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964833AbcDTJ7b (ORCPT ); Wed, 20 Apr 2016 05:59:31 -0400 Received: from helcar.hengli.com.au ([209.40.204.226]:49895 "EHLO helcar.hengli.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933077AbcDTJ73 (ORCPT ); Wed, 20 Apr 2016 05:59:29 -0400 Date: Wed, 20 Apr 2016 17:59:02 +0800 From: Herbert Xu To: Krzysztof Kozlowski Cc: "David S. Miller" , Vladimir Zapolskiy , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, Bartlomiej Zolnierkiewicz Subject: Re: [PATCH 1/2] crypto: s5p-sss - Fix use after free of copied input buffer in error path Message-ID: <20160420095902.GD3003@gondor.apana.org.au> References: <1461073452-10426-1-git-send-email-k.kozlowski@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1461073452-10426-1-git-send-email-k.kozlowski@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: 1025 Lines: 22 On Tue, Apr 19, 2016 at 03:44:11PM +0200, Krzysztof Kozlowski wrote: > The driver makes copies of memory (input or output scatterlists) if they > are not aligned. In s5p_aes_crypt_start() error path (on unsuccessful > initialization of output scatterlist), if input scatterlist was not > aligned, the driver first freed copied input memory and then unmapped it > from the device, instead of doing otherwise (unmap and then free). > > This was wrong in two ways: > 1. Freed pages were still mapped to the device. > 2. The dma_unmap_sg() iterated over freed scatterlist structure. > > The call to s5p_free_sg_cpy() in this error path is not needed because > the copied scatterlists will be freed by s5p_aes_complete(). > > Fixes: 9e4a1100a445 ("crypto: s5p-sss - Handle unaligned buffers") > Signed-off-by: Krzysztof Kozlowski Both applied. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt