Geert Uytterhoeven ce989f1472
RISC-V: Fix out-of-bounds accesses in init_resources()
init_resources() allocates an array of resources, based on the current
total number of memory regions and reserved memory regions.  However,
allocating this array using memblock_alloc() might increase the number
of reserved memory regions.  If that happens, populating the array later
based on the new number of regions will cause out-of-bounds writes
beyond the end of the allocated array.

Fix this by allocating one more entry, which may or may not be used.

Fixes: 797f0375dd2ef5cd ("RISC-V: Do not allocate memblock while iterating reserved memblocks")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
2021-03-16 21:55:11 -07:00
..
2020-03-31 11:28:30 -07:00
2020-03-31 11:28:30 -07:00
2020-10-02 14:31:28 -07:00
2020-10-02 14:30:57 -07:00
2020-06-09 19:11:24 -07:00
2021-01-14 15:09:08 -08:00
2021-01-07 19:00:50 -08:00