linux/arch/arm64
Mark Rutland eb3d8ea3e1 arm64: kexec: load from kimage prior to clobbering
In arm64_relocate_new_kernel() we load some fields out of the kimage
structure after relocation has occurred. As the kimage structure isn't
allocated to be relocation-safe, it may be clobbered during relocation,
and we may load junk values out of the structure.

Due to this, kexec may fail when the kimage allocation happens to fall
within a PA range that an object will be relocated to. This has been
observed to occur for regular kexec on a QEMU TCG 'virt' machine with
2GiB of RAM, where the PA range of the new kernel image overlaps the
kimage structure.

Avoid this by ensuring we load all values from the kimage structure
prior to relocation.

I've tested this atop v5.16 and v5.18-rc6.

Fixes: 878fdbd704 ("arm64: kexec: pass kimage as the only argument to relocation function")
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Will Deacon <will@kernel.org>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Link: https://lore.kernel.org/r/20220516160735.731404-1-mark.rutland@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
2022-05-17 14:25:35 +01:00
..
boot SoC: fixes for 5.18, part 1 2022-04-01 13:21:19 -07:00
configs ARM: DT updates for 5.18 2022-03-23 18:37:22 -07:00
crypto crypto: arm64 - cleanup comments 2022-03-09 15:12:32 +12:00
hyperv
include arm64: mm: fix p?d_leaf() 2022-04-22 11:28:36 +01:00
kernel arm64: kexec: load from kimage prior to clobbering 2022-05-17 14:25:35 +01:00
kvm ARM: 2022-03-24 11:58:57 -07:00
lib Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2022-03-21 16:02:36 -07:00
mm arm64: fix typos in comments 2022-04-04 10:32:50 +01:00
net kasan, arm64: don't tag executable vmalloc allocations 2022-03-24 19:06:48 -07:00
tools Merge branch 'for-next/spectre-bhb' into for-next/core 2022-03-14 19:08:31 +00:00
xen
Kbuild
Kconfig arm64: fix typos in comments 2022-04-14 10:52:53 +01:00
Kconfig.debug
Kconfig.platforms ARM: DT updates for 5.18 2022-03-23 18:37:22 -07:00
Makefile