[PATCH 0/8] lib/mpi: bug fixes and cleanup

From: Nicolai Stange
Date: Thu Mar 17 2016 - 14:00:38 EST


With linux-next-20160317, KASAN splats for both, mpi_write_sgl()
and mpi_read_buffer().

While the first isn't dramatic on x86 (as long as it doesn't fault),
the latter potentially overwrites unrelated memory.

These two issues are fixed by

[4/8] ("lib/mpi: mpi_write_sgl(): fix out-of-bounds stack access")

and

[8/8] ("lib/mpi: mpi_read_buffer(): fix buffer overflow")


While reviewing the code, I found another bug, c.f.

[1/8] ("lib/mpi: mpi_write_sgl(): fix skipping of leading zero limbs")


The rest are cleanup/style patches I couldn't hold back ;)

There is still room for improvement in that the leading zero handling
could get easily moved out of the loop, but that's not the business of
this series.


Specifically. this patchset fixes

2d4d1eea540b ("lib/mpi: Add mpi sgl helpers")

and

9cbe21d8f89d ("lib/mpi: only require buffers as big as needed for
the integer")



This series is applicable to linux-next-20160317.


Nicolai Stange (8):
lib/mpi: mpi_write_sgl(): fix skipping of leading zero limbs
lib/mpi: mpi_write_sgl(): fix style issue with lzero decrement
lib/mpi: mpi_write_sgl(): purge redundant pointer arithmetic
lib/mpi: mpi_write_sgl(): fix out-of-bounds stack access
lib/mpi: mpi_write_sgl(): replace open coded endian conversion
lib/mpi: mpi_read_buffer(): optimize skipping of leading zero limbs
lib/mpi: mpi_read_buffer(): replace open coded endian conversion
lib/mpi: mpi_read_buffer(): fix buffer overflow

lib/mpi/mpicoder.c | 91 ++++++++++++++++++++----------------------------------
1 file changed, 33 insertions(+), 58 deletions(-)

--
2.7.2