Re: [PATCH 2/7] lib/mpi: use kcalloc in mpi_resize(Internet mail)

From: hongbo li
Date: Tue May 18 2021 - 09:53:20 EST


Ok, I'll explain it in the next version of patches.
Regards,
Hongbo

Eric Biggers <ebiggers@xxxxxxxxxx> 于2021年5月18日周二 上午5:29写道:
>
> 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 <herberthbli@xxxxxxxxxxx><mailto:herberthbli@xxxxxxxxxxx>
> >
> > We should set the additional space to 0 in mpi_resize().
> > So use kcalloc() instead of kmalloc_array().
> >
> > Signed-off-by: Hongbo Li <herberthbli@xxxxxxxxxxx><mailto:herberthbli@xxxxxxxxxxx>
> >
> >
> >
> > 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