Skip to content

Commit 9e2413f

Browse files
pcercueigregkh
authored andcommitted
MIPS: boot: Fix unaligned access with CONFIG_MIPS_RAW_APPENDED_DTB
commit 4d4f9c1 upstream. The compressed payload is not necesarily 4-byte aligned, at least when compiling with Clang. In that case, the 4-byte value appended to the compressed payload that corresponds to the uncompressed kernel image size must be read using get_unaligned_le32(). This fixes Clang-built kernels not booting on MIPS (tested on a Ingenic JZ4770 board). Fixes: b8f54f2 ("MIPS: ZBOOT: copy appended dtb to the end of the kernel") Cc: <stable@vger.kernel.org> # v4.7 Signed-off-by: Paul Cercueil <paul@crapouillou.net> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 974f196 commit 9e2413f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎arch/mips/boot/compressed/decompress.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/libfdt.h>
1414

1515
#include <asm/addrspace.h>
16+
#include <asm/unaligned.h>
1617

1718
/*
1819
* These two variables specify the free mem region
@@ -117,7 +118,7 @@ void decompress_kernel(unsigned long boot_heap_start)
117118
dtb_size = fdt_totalsize((void *)&__appended_dtb);
118119

119120
/* last four bytes is always image size in little endian */
120-
image_size = le32_to_cpup((void *)&__image_end - 4);
121+
image_size = get_unaligned_le32((void *)&__image_end - 4);
121122

122123
/* copy dtb to where the booted kernel will expect it */
123124
memcpy((void *)VMLINUX_LOAD_ADDRESS_ULL + image_size,

0 commit comments

Comments
 (0)