From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E701C433EF for ; Thu, 21 Jul 2022 09:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JEbPcnzdN5PArGu8XYy10r0LhYfQcmFXqPa+L4Byib4=; b=FVUzqstBc2CBGW s4cTzvRK0M7qUhH6LnS4J0kH0KAUv3NHWZ9vuCGeS9WKH+Od1aU/PPxvQ+0bWca1utksE3Cz2TQMT X+Vv+L7ZzL5UA7pSwOA7Zve3RqLGcjwyhpW8bq7y8OBwQkbkDKwijpc4Szlt9Yk992Y2ECoc6BhOG OxMpBHY3//glPRuFC8FFaAOU2dHHrCF7xUUTqv081EGo5s2A/do1X2aRgMOXY22UGULg2SWR7f6WN ci3D4D685b4BTTFibyFIblrd486YgJG9crivHGXbjytnacGxgUBjjZIihd9J5lpCVDA4g4zQ4PG1S r/5f+4SLCxeB8FE4b37A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oESUY-003JMZ-W7; Thu, 21 Jul 2022 09:29:11 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oESUV-003JIc-GB for linux-arm-kernel@lists.infradead.org; Thu, 21 Jul 2022 09:29:09 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E88CEB8224B; Thu, 21 Jul 2022 09:29:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09568C3411E; Thu, 21 Jul 2022 09:29:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658395744; bh=KEw8DJskb+PpDSC3YoCIg+9N695Dji/DNPBN8KYVkdc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eUaFp8AFW8YXdERoEetTOLC2u7uiXq+CUrIREd5VD4Nboma6aOESnnLdhd1VMD8+7 xEyfmrqCCHDadu+ZfzNwj5zT9BK6wGHkDm+/wymgvf1LTuBzJn6oXSWJSF/VQcax/z rsSqQrVIYroUuzub1cDHflSRnc52TpbB4A10b+E6cWM0L10rftBYegVqgWQdaRdziB tJKaJGX6Zepam4sCaU0lD+W4uKubmdkccYwnD8EumgdBbHg9qR/hxlYIhGmgGuSWQ+ 9ZhUn3svn5MT635ySRz44gUe3XfyvA72NXYtYdYApAHki24Gi3N7NlzDFhsumrhaWX 1Ouy/OC8thbLw== Date: Thu, 21 Jul 2022 10:28:58 +0100 From: Will Deacon To: Eric Biggers Cc: "Guozihua (Scott)" , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, herbert@gondor.apana.org.au, davem@davemloft.net, catalin.marinas@arm.com Subject: Re: [PATCH v2] arm64/crypto: poly1305 fix a read out-of-bound Message-ID: <20220721092858.GA17088@willie-the-truck> References: <20220712075031.29061-1-guozihua@huawei.com> <20220720094116.GC15752@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220721_022907_851986_361B70FD X-CRM114-Status: GOOD ( 38.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jul 20, 2022 at 07:37:17PM -0700, Eric Biggers wrote: > On Wed, Jul 20, 2022 at 05:57:30PM +0800, Guozihua (Scott) wrote: > > On 2022/7/20 17:41, Will Deacon wrote: > > > On Tue, Jul 12, 2022 at 03:50:31PM +0800, GUO Zihua wrote: > > > > A kasan error was reported during fuzzing: > > > > > > [...] > > > > > > > This patch fixes the issue by calling poly1305_init_arm64() instead of > > > > poly1305_init_arch(). This is also the implementation for the same > > > > algorithm on arm platform. > > > > > > > > Fixes: f569ca164751 ("crypto: arm64/poly1305 - incorporate OpenSSL/CRYPTOGAMS NEON implementation") > > > > Cc: stable@vger.kernel.org > > > > Signed-off-by: GUO Zihua > > > > --- > > > > arch/arm64/crypto/poly1305-glue.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > I'm not a crypto guy by any stretch of the imagination, but Ard is out > > > at the moment and this looks like an important fix so I had a crack at > > > reviewing it. > > > > > > > diff --git a/arch/arm64/crypto/poly1305-glue.c b/arch/arm64/crypto/poly1305-glue.c > > > > index 9c3d86e397bf..1fae18ba11ed 100644 > > > > --- a/arch/arm64/crypto/poly1305-glue.c > > > > +++ b/arch/arm64/crypto/poly1305-glue.c > > > > @@ -52,7 +52,7 @@ static void neon_poly1305_blocks(struct poly1305_desc_ctx *dctx, const u8 *src, > > > > { > > > > if (unlikely(!dctx->sset)) { > > > > if (!dctx->rset) { > > > > - poly1305_init_arch(dctx, src); > > > > + poly1305_init_arm64(&dctx->h, src); > > > > src += POLY1305_BLOCK_SIZE; > > > > len -= POLY1305_BLOCK_SIZE; > > > > dctx->rset = 1; > > > > > > With this change, we no longer initialise dctx->buflen to 0 as part of the > > > initialisation. Looking at neon_poly1305_do_update(), I'm a bit worried > > > that we could land in the 'if (likely(len >= POLY1305_BLOCK_SIZE))' block, > > > end up with len == 0 and fail to set dctx->buflen. Is this a problem, or is > > > my ignorance showing? > > > > > > Will > > > . > > > > Thanks Will. > > > > I noticed this as well, but I leaved it out so that the behavior is the same > > as the implementation for arm. The buflen here seems to be used for > > maintaining any excessive data after the last block, and is zeroed during > > init. I am not sure why it should be zeroed again during key initialization. > > Maybe the thought was that the very first block of the data is always used > > for initializing rset and that is also considered to be the "initialization" > > process for the algorithm, thus the zeroing of buflen. I could be completely > > wrong though. > > > > buflen is initialized by neon_poly1305_init(), so there's no issue here. Ah yes, thanks. I missed that. In which case, for the very little it's worth: Acked-by: Will Deacon Herbert, please can you pick this up? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel