Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp974150ybz; Wed, 15 Apr 2020 23:52:39 -0700 (PDT) X-Google-Smtp-Source: APiQypKVqbBzfUP/rWqs9Kks2Zov5k9OfVQIItM3oyvjrhGof59ZGcvbSVZqykaBQ7OT2jh0TJ1l X-Received: by 2002:aa7:d14e:: with SMTP id r14mr25378834edo.200.1587019959179; Wed, 15 Apr 2020 23:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587019959; cv=none; d=google.com; s=arc-20160816; b=fRbrHbHVM84kHBtrwWDIMY/8wkBvPFXx/noNHaf5yYPmyUAuxFVilFAzU9w8dGSIR6 b19M/fqzFIZMS8/+UvE+ITC/6dPCg3Bwk2DMKhp9849TrduNe+O7mAeo7K3NA0S3+V7b 5RuA/p7fPTy4NEGIIHdesmuEZo8tjfNlykS4gqg/6FW6bYS8U1VuTzOce1EXymM6lVVZ QaXYxR81pxUqXeGF9fp/4O8kZTb9G/jpoOpTsWgAqsdRU1KtZiDzArwULnKvdkHh3ExD fKj0+xv2p1D1qybcb7z2xL/JNHPwks/QeeJLZPVS54d7N/BVk6KKuNDwU71AyiWZr4XX DfAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=7PDAGV8dluUQETN+s5b9w+tZCv7yOgUD2R9Yqv1xj9U=; b=zU38/lDaoD2IKnjfBxsXlvRq2YC9hQxDEs2VjP+7ha8fth9QLi7lg5+oLUE54IyuNY 7osD6c2qvhMR1r9QJIsgWrFKafGoHC4XsVdIc2dYG65Aw3YG62f8i03TBmMwucYUadar tlW1AykfffCqIiowa6DBGh36FvsM4Q7vpk+NP6Kako9b3QrFo6Qi8wHBuC+8RceCfsKl dL3n5ZnqCc0QcyThqd21+W6jxwXaB5tcqNWSNJzNOfTxblCUqf0IXgRIj9oon7RDrjY9 tIvGacMgbP7T4QmW+jew016+87xvfeR2FqAkN5QlfufGP/CAWCBaipJZzvEHCUneYeIV kvnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k12si7818427edn.425.2020.04.15.23.52.15; Wed, 15 Apr 2020 23:52:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408163AbgDPGu7 (ORCPT + 99 others); Thu, 16 Apr 2020 02:50:59 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:41376 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408551AbgDPGu4 (ORCPT ); Thu, 16 Apr 2020 02:50:56 -0400 Received: from gwarestrin.me.apana.org.au ([192.168.0.7] helo=gwarestrin.arnor.me.apana.org.au) by fornost.hmeau.com with smtp (Exim 4.89 #2 (Debian)) id 1jOyMK-0005H0-Cw; Thu, 16 Apr 2020 16:50:49 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Thu, 16 Apr 2020 16:50:48 +1000 Date: Thu, 16 Apr 2020 16:50:48 +1000 From: Herbert Xu To: Iuliana Prodan Cc: Horia Geanta , Aymen Sghaier , "David S. Miller" , Silvano Di Ninno , Franck Lenormand , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx Subject: Re: [PATCH] crypto: caam - fix the address of the last entry of S/G Message-ID: <20200416065048.GB7901@gondor.apana.org.au> References: <1586275125-20571-1-git-send-email-iuliana.prodan@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1586275125-20571-1-git-send-email-iuliana.prodan@nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, Apr 07, 2020 at 06:58:45PM +0300, Iuliana Prodan wrote: > For skcipher algorithms, the input, output HW S/G tables > look like this: [IV, src][dst, IV] > Now, we can have 2 conditions here: > - there is no IV; > - src and dst are equal (in-place encryption) and scattered > and the error is an "off-by-one" in the HW S/G table. > > This issue was seen with KASAN: > BUG: KASAN: slab-out-of-bounds in skcipher_edesc_alloc+0x95c/0x1018 > > Read of size 4 at addr ffff000022a02958 by task cryptomgr_test/321 > > CPU: 2 PID: 321 Comm: cryptomgr_test Not tainted > 5.6.0-rc1-00165-ge4ef8383-dirty #4 > Hardware name: LS1046A RDB Board (DT) > Call trace: > dump_backtrace+0x0/0x260 > show_stack+0x14/0x20 > dump_stack+0xe8/0x144 > print_address_description.isra.11+0x64/0x348 > __kasan_report+0x11c/0x230 > kasan_report+0xc/0x18 > __asan_load4+0x90/0xb0 > skcipher_edesc_alloc+0x95c/0x1018 > skcipher_encrypt+0x84/0x150 > crypto_skcipher_encrypt+0x50/0x68 > test_skcipher_vec_cfg+0x4d4/0xc10 > test_skcipher_vec+0x178/0x1d8 > alg_test_skcipher+0xec/0x230 > alg_test.part.44+0x114/0x4a0 > alg_test+0x1c/0x60 > cryptomgr_test+0x34/0x58 > kthread+0x1b8/0x1c0 > ret_from_fork+0x10/0x18 > > Allocated by task 321: > save_stack+0x24/0xb0 > __kasan_kmalloc.isra.10+0xc4/0xe0 > kasan_kmalloc+0xc/0x18 > __kmalloc+0x178/0x2b8 > skcipher_edesc_alloc+0x21c/0x1018 > skcipher_encrypt+0x84/0x150 > crypto_skcipher_encrypt+0x50/0x68 > test_skcipher_vec_cfg+0x4d4/0xc10 > test_skcipher_vec+0x178/0x1d8 > alg_test_skcipher+0xec/0x230 > alg_test.part.44+0x114/0x4a0 > alg_test+0x1c/0x60 > cryptomgr_test+0x34/0x58 > kthread+0x1b8/0x1c0 > ret_from_fork+0x10/0x18 > > Freed by task 0: > (stack is not available) > > The buggy address belongs to the object at ffff000022a02800 > which belongs to the cache dma-kmalloc-512 of size 512 > The buggy address is located 344 bytes inside of > 512-byte region [ffff000022a02800, ffff000022a02a00) > The buggy address belongs to the page: > page:fffffe00006a8000 refcount:1 mapcount:0 mapping:ffff00093200c400 > index:0x0 compound_mapcount: 0 > flags: 0xffff00000010200(slab|head) > raw: 0ffff00000010200 dead000000000100 dead000000000122 ffff00093200c400 > raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000 > page dumped because: kasan: bad access detected > > Memory state around the buggy address: > ffff000022a02800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > ffff000022a02880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > >ffff000022a02900: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc > ^ > ffff000022a02980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc > ffff000022a02a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc > > Fixes: 334d37c9e263 ("crypto: caam - update IV using HW support") > Cc: # v5.3+ > Signed-off-by: Iuliana Prodan > --- > drivers/crypto/caam/caamalg.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt