linux-stable/arch/x86/platform/efi
Ard Biesheuvel 8319e9d5ad efi/x86: Handle by-ref arguments covering multiple pages in mixed mode
The mixed mode runtime wrappers are fragile when it comes to how the
memory referred to by its pointer arguments are laid out in memory, due
to the fact that it translates these addresses to physical addresses that
the runtime services can dereference when running in 1:1 mode. Since
vmalloc'ed pages (including the vmap'ed stack) are not contiguous in the
physical address space, this scheme only works if the referenced memory
objects do not cross page boundaries.

Currently, the mixed mode runtime service wrappers require that all by-ref
arguments that live in the vmalloc space have a size that is a power of 2,
and are aligned to that same value. While this is a sensible way to
construct an object that is guaranteed not to cross a page boundary, it is
overly strict when it comes to checking whether a given object violates
this requirement, as we can simply take the physical address of the first
and the last byte, and verify that they point into the same physical page.

When this check fails, we emit a WARN(), but then simply proceed with the
call, which could cause data corruption if the next physical page belongs
to a mapping that is entirely unrelated.

Given that with vmap'ed stacks, this condition is much more likely to
trigger, let's relax the condition a bit, but fail the runtime service
call if it does trigger.

Fixes: f6697df36b ("x86/efi: Prevent mixed mode boot corruption with CONFIG_VMAP_STACK=y")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: linux-efi@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20200221084849.26878-4-ardb@kernel.org
2020-02-26 15:31:42 +01:00
..
efi.c efi/x86: Fix boot regression on systems with invalid memmap entries 2020-02-02 10:25:43 +01:00
efi_32.c x86: mm+efi: convert ptdump_walk_pgd_level() to take a mm_struct 2020-02-04 03:05:25 +00:00
efi_64.c efi/x86: Handle by-ref arguments covering multiple pages in mixed mode 2020-02-26 15:31:42 +01:00
efi_stub_32.S efi/x86: Simplify i386 efi_call_phys() firmware call wrapper 2020-01-10 18:55:02 +01:00
efi_stub_64.S efi/x86: Check number of arguments to variadic functions 2020-01-10 18:55:04 +01:00
efi_thunk_64.S efi/x86: Check number of arguments to variadic functions 2020-01-10 18:55:04 +01:00
Makefile efi/x86: Disable instrumentation in the EFI runtime handling code 2020-01-25 10:14:37 +01:00
quirks.c Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-01-28 09:03:40 -08:00