Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1138521pxj; Tue, 18 May 2021 22:42:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxALQmmf7rwx5Q7imdZ48UyUEE7ML1H7QaUtaVWASBAsWLhzeKKn4a+Y9T4F0GWZApobX9O X-Received: by 2002:a17:906:58cd:: with SMTP id e13mr10259543ejs.207.1621402957276; Tue, 18 May 2021 22:42:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621402957; cv=none; d=google.com; s=arc-20160816; b=NebZHZod9S3QWc9e0daw74lWOf1K7Ctwubo4fEqnIUCM9XIQfFxIEYgpc8x47fLIRu kO8utloVM3NtCOsOMi7NBX0MdFjSyjUCILf8Rd+VZi5ptUX9GiiwB+G9KS/KVR4uurb4 FwxXgByLjyWbQMNAfbNCrk+VBXoo+DZn5LBXYM1LGgDJPvBtKnV2eu7rt03W0aupEs8f VOztQSUl1sZQ94FXj7YdulabMbB1ar0+O5DsCBm2pPDIXjdsGtZXMsQnI24tmzfQ026P f6dogSJ/1D8foiw7hBu3bhFNQyOEFgCcgc3fsVpmhS+by/YsAwlltyMAud2p6ezQ/L5r Fh2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ey0hW2excqoZ+/n8BFRE9NGkbPcuH6OfQc1zwDavh6Y=; b=eejsbFnFZUrVdbMhwgtPWOWnOR25q9o+gRs9dHYIKbHmyDY3IpDe8LUzXye2eNZstn X7uVFCWIcYW2mA/8tnhhuofK614jvxIsfVIg5HpWtG0spiyju5KUSjUaglAft8KvJju9 J2uXxZTQODo36lgMRhZDF+9CxCYI7oNUBtD0QbA2GJn2SXevOmPvxauuJVyANkuJLEDd LoL++HYYttu0NDTyW6lfFzHXU6mdo6c/l1ZQ1jYMzC1yyf8W80EU4xN/cBUwlcj14RTr hvrhReq3QHKAaxMTbeNFtpkzZjRUIyJYRFaRcHdj+lOpGdkb1UZNhbH15ASBwRqix/YR XDSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=atLkbBVC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si4198230edr.15.2021.05.18.22.42.14; Tue, 18 May 2021 22:42:37 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=atLkbBVC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235792AbhEQVaY (ORCPT + 99 others); Mon, 17 May 2021 17:30:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:58882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232924AbhEQVaY (ORCPT ); Mon, 17 May 2021 17:30:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 52F2D61073; Mon, 17 May 2021 21:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621286947; bh=OU9/VfZMdMInAEGX3f/s3AgTaKgR+SF8dKtKFZ+4nas=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=atLkbBVCocEOaDYktiSuoIp4tf/VL/Gq73zcMgIlcVRBIN1ZJEXPh/KCaJlN1Gvld vxp7kBni32bRXnzOUvwb5J2TRTCW3ThanH09vx1vOdv26+n7RdytG9mjgS1XN9SAgd sE8P5lPFUlkBemhENFMN3z6VOXTr/yBR2iOf1S4bqjrVNkRD/itzZslRNZ6pRSiqFT 5+cx3C6Lq8aMRDmP6zfTuw8RlcS9M3ayJYuIusORjX/CJB6grX1KBQPc9WAeJ75VTj tMJEb1VWthc4VfiWkVvOMwquTwPE2bjQoZ4ZYwwVV16E+gbkuKyS8oPLFdkjUKzdtn bC4h6lOAjXzsw== Date: Mon, 17 May 2021 14:29:05 -0700 From: Eric Biggers To: =?utf-8?B?aGVyYmVydGhibGko5p2O5byY5Y2aKQ==?= Cc: Hongbo Li , "keyrings@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "herbert@gondor.apana.org.au" , "dhowells@redhat.com" , "jarkko@kernel.org" , "tianjia.zhang@linux.alibaba.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 2/7] lib/mpi: use kcalloc in mpi_resize(Internet mail) Message-ID: References: <1620828254-25545-1-git-send-email-herbert.tencent@gmail.com> <1620828254-25545-3-git-send-email-herbert.tencent@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, May 13, 2021 at 02:49:03PM +0000, herberthbli(李弘博) wrote: > 在 2021/5/13 3:08, Eric Biggers 写道: > > On Wed, May 12, 2021 at 10:04:09PM +0800, Hongbo Li wrote: > > > From: Hongbo Li > > We should set the additional space to 0 in mpi_resize(). > So use kcalloc() instead of kmalloc_array(). > > Signed-off-by: Hongbo Li > > > > Is this fixing something, and if so what? > > - Eric > > > > In lib/mpi/ec.c: > > /**************** > * Resize the array of A to NLIMBS. the additional space is cleared > * (set to 0) [done by m_realloc()] > */ > int mpi_resize(MPI a, unsigned nlimbs) > > Like the comment of kernel's mpi_resize(), the additional space need to set to 0, > but when a->d is not NULL, it does not set. > > The kernel's mpi lib is from libgcrypt, the mpi resize in libgcrypt is _gcry_mpi_resize() > which set the additional space to 0. > > This issue will cause add_points_edwards() get a wrong result, and lead to a failed > eddsa verification. > That sounds like it's fixing an existing bug, regardless of the ed25519 support. If that's indeed the case, what is the impact of that bug, and what commit is it fixing? Please explain in the commit message and not just email. - Eric