mirror of
https://github.com/torvalds/linux.git
synced 2024-12-12 06:02:38 +00:00
b6f756726e
We should set the additional space to 0 in mpi_resize().
So use kcalloc() instead of kmalloc_array().
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() said, the additional space
need to be 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 bug may cause mpi api which use mpi_resize() get wrong result
under the condition of using the additional space without initiation.
If this condition is not met, the bug would not be triggered.
Currently in kernel, rsa, sm2 and dh use mpi lib, and they works well,
so the bug is not triggered in these cases.
add_points_edwards() use the additional space directly, so it will
get a wrong result.
Fixes:
|
||
---|---|---|
.. | ||
ec.c | ||
generic_mpih-add1.c | ||
generic_mpih-lshift.c | ||
generic_mpih-mul1.c | ||
generic_mpih-mul2.c | ||
generic_mpih-mul3.c | ||
generic_mpih-rshift.c | ||
generic_mpih-sub1.c | ||
longlong.h | ||
Makefile | ||
mpi-add.c | ||
mpi-bit.c | ||
mpi-cmp.c | ||
mpi-div.c | ||
mpi-inline.h | ||
mpi-internal.h | ||
mpi-inv.c | ||
mpi-mod.c | ||
mpi-mul.c | ||
mpi-pow.c | ||
mpi-sub-ui.c | ||
mpicoder.c | ||
mpih-cmp.c | ||
mpih-div.c | ||
mpih-mul.c | ||
mpiutil.c |