arm64: mm: avoid fdt_check_header() before the FDT is fully mapped
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 1 Aug 2016 11:29:31 +0000 (13:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Aug 2016 16:09:17 +0000 (18:09 +0200)
commitbe7acd281e5ab34c87f4cc930f42c3fdf49ee33d
tree0d7ef14c40d597a3790eac2def49e097317094ed
parent6d894c3f0f1cadd5649364556a9de30a9e8c0f74
arm64: mm: avoid fdt_check_header() before the FDT is fully mapped

commit 04a848106193b134741672f7e4e444b50c70b631 upstream.

As reported by Zijun, the fdt_check_header() call in __fixmap_remap_fdt()
is not safe since it is not guaranteed that the FDT header is mapped
completely. Due to the minimum alignment of 8 bytes, the only fields we
can assume to be mapped are 'magic' and 'totalsize'.

Since the OF layer is in charge of validating the FDT image, and we are
only interested in making reasonably sure that the size field contains
a meaningful value, replace the fdt_check_header() call with an explicit
comparison of the magic field's value against the expected value.

Reported-by: Zijun Hu <zijun_hu@htc.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/mm/mmu.c