efi/libstub: arm64: Double check image alignment at entry
authorArd Biesheuvel <ardb@kernel.org>
Mon, 26 Jul 2021 14:31:44 +0000 (16:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Aug 2021 06:59:17 +0000 (08:59 +0200)
commit4a948c579ed6a12e248da57b9422a69b1ca2261c
treeecca333e5c3781c9d67c3b4568f7d332213c3d8f
parentfc7da433fa16b7e9a9efa92b41f684670535d99e
efi/libstub: arm64: Double check image alignment at entry

commit c32ac11da3f83bb42b986702a9b92f0a14ed4182 upstream.

On arm64, the stub only moves the kernel image around in memory if
needed, which is typically only for KASLR, given that relocatable
kernels (which is the default) can run from any 64k aligned address,
which is also the minimum alignment communicated to EFI via the PE/COFF
header.

Unfortunately, some loaders appear to ignore this header, and load the
kernel at some arbitrary offset in memory. We can deal with this, but
let's check for this condition anyway, so non-compliant code can be
spotted and fixed.

Cc: <stable@vger.kernel.org> # v5.10+
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/firmware/efi/libstub/arm64-stub.c