acrn-kernel/arch/mips/boot/compressed
Kees Cook 4d409ca3e5 MIPS: boot/compressed: Use array reference for image bounds
As done with other image addresses in other architectures, use an
explicit flexible array instead of "address of char", which can trip
bounds checking done by the compiler. Found when building with
-Warray-bounds:

In file included from ./include/linux/byteorder/little_endian.h:5,
                 from ./arch/mips/include/uapi/asm/byteorder.h:15,
                 from ./arch/mips/include/asm/bitops.h:21,
                 from ./include/linux/bitops.h:33,
                 from ./include/linux/kernel.h:22,
                 from arch/mips/boot/compressed/decompress.c:13:
arch/mips/boot/compressed/decompress.c: In function 'decompress_kernel':
./include/asm-generic/unaligned.h:14:8: warning: array subscript -1 is outside array bounds of 'unsigned char[1]' [-Warray-bounds]
   14 |  __pptr->x;        \
      |  ~~~~~~^~~
./include/uapi/linux/byteorder/little_endian.h:35:51: note: in definition of macro '__le32_to_cpu'
   35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
      |                                                   ^
./include/asm-generic/unaligned.h:32:21: note: in expansion of macro '__get_unaligned_t'
   32 |  return le32_to_cpu(__get_unaligned_t(__le32, p));
      |                     ^~~~~~~~~~~~~~~~~
arch/mips/boot/compressed/decompress.c:29:37: note: while referencing '__image_end'
   29 | extern unsigned char __image_begin, __image_end;
      |                                     ^~~~~~~~~~~

Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: linux-mips@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
2022-03-14 15:02:26 +01:00
..
Makefile mips: Enable KCSAN 2022-02-22 09:45:05 +01:00
ashldi3.c mips: decompressor: do not copy source files while building 2021-11-10 19:45:06 +01:00
bswapdi.c mips: decompressor: do not copy source files while building 2021-11-10 19:45:06 +01:00
bswapsi.c mips: decompressor: do not copy source files while building 2021-11-10 19:45:06 +01:00
calc_vmlinuz_load_addr.c
clz_ctz.c MIPS: compressed: Fix build with ZSTD compression 2022-01-09 15:43:07 +01:00
dbg.c
decompress.c MIPS: boot/compressed: Use array reference for image bounds 2022-03-14 15:02:26 +01:00
dummy.c
head.S MIPS: zboot: Avoid endless loop in clear BSS. 2021-01-07 17:12:14 +01:00
ld.script
string.c
uart-16550.c MIPS: Remove NETLOGIC support 2021-10-24 17:24:47 +02:00
uart-alchemy.c
uart-ath79.c mips: decompressor: do not copy source files while building 2021-11-10 19:45:06 +01:00
uart-prom.c