From: Ard Biesheuvel <ardb@kernel.org>
To: linux-efi@vger.kernel.org
Cc: xen-devel@lists.xenproject.org,
"Ard Biesheuvel" <ardb@kernel.org>,
"Demi Marie Obenour" <demi@invisiblethingslab.com>,
"Peter Jones" <pjones@redhat.com>,
"Juergen Gross" <jgross@suse.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Oleksandr Tyshchenko" <oleksandr_tyshchenko@epam.com>,
"Kees Cook" <keescook@chromium.org>,
"Anton Vorontsov" <anton@enomsg.org>,
"Colin Cross" <ccross@android.com>,
"Tony Luck" <tony.luck@intel.com>,
"Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
Subject: [PATCH v2 0/6] efi/x86: Avoid corrupted config tables under Xen
Date: Mon, 3 Oct 2022 13:26:19 +0200 [thread overview]
Message-ID: <20221003112625.972646-1-ardb@kernel.org> (raw)
This is an alternate approach to addressing the issue that Demi Marie is
attempting to fix in [0] (i.e., ESRT config table exposed to a x86 dom0
is corrupted because it resides in boot services memory as per the EFI
spec, where it gets corrupted by Xen). My main objection to that approach
is that it needs Xen-specific fixes in multiple different places, but we
still end up only fixing the ESRT case specifically.
So instead, I am proposing this series as a more generic way to handle
configuration tables that reside in boot services memory, and confining
the Xen specific logic to the Xen EFI glue code.
Given that EFI boot without a memory map is only permitted on x86 and
only when doing Xen boot, let's clear up some inconsistencies there
first so we can set the EFI_PARAVIRT flag on all architectures that do
pseudo-EFI boot straight into the core kernel (i.e., without going
through the stub). This moves a good chunk of EFI memory map
manipulation code into the x86 arch tree, where it arguably belongs as
no other architectures rely on it. This is implemented in patches 1 - 3.
Patch #4 refactors the ESRT sanity checks on the memory descriptor, by
moving them into the efi_mem_desc_lookup() helper, which should not
return corrupted descriptors in the first place.
Patch #5 adds a Xen hypercall fallback to efi_mem_desc_lookup() when
running under Xen without a EFI memory map, so that, e.g., the existing
ESRT code will perform its validation against the Xen provided
descriptor if no memory map is available.
Patch #6 updates the config table traversal code so that the Xen glue
code can force them to be disregarded, which happens when the table in
question points into a memory region that is not of a type that Xen
automatically reserves. Future changes can refine this logic if needed.
Changes since v1:
- add patch #4
- move Xen descriptor lookup into efi_mem_desc_lookup()
- drop allowlist for ACPI and SMBIOS tables
[0] https://lore.kernel.org/all/cover.1664298147.git.demi@invisiblethingslab.com/
Cc: Demi Marie Obenour <demi@invisiblethingslab.com>
Cc: Peter Jones <pjones@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Anton Vorontsov <anton@enomsg.org>
Cc: Colin Cross <ccross@android.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Ard Biesheuvel (6):
efi: Move EFI fake memmap support into x86 arch tree
efi: memmap: Move manipulation routines into x86 arch tree
efi: xen: Set EFI_PARAVIRT for Xen dom0 boot on all architectures
efi: memmap: Disregard bogus entries instead of returning them
efi: xen: Implement memory descriptor lookup based on hypercall
efi: Apply allowlist to EFI configuration tables when running under
Xen
arch/x86/Kconfig | 20 ++
arch/x86/include/asm/efi.h | 16 ++
arch/x86/kernel/setup.c | 1 +
arch/x86/platform/efi/Makefile | 4 +-
arch/x86/platform/efi/efi.c | 8 +-
{drivers/firmware => arch/x86/platform}/efi/fake_mem.c | 79 ++++++-
arch/x86/platform/efi/memmap.c | 238 ++++++++++++++++++++
drivers/firmware/efi/Kconfig | 22 --
drivers/firmware/efi/Makefile | 4 -
drivers/firmware/efi/efi.c | 25 +-
drivers/firmware/efi/esrt.c | 18 +-
drivers/firmware/efi/fake_mem.h | 10 -
drivers/firmware/efi/fdtparams.c | 4 +
drivers/firmware/efi/memmap.c | 224 +-----------------
drivers/firmware/efi/x86_fake_mem.c | 75 ------
drivers/xen/efi.c | 58 +++++
include/linux/efi.h | 19 +-
17 files changed, 446 insertions(+), 379 deletions(-)
rename {drivers/firmware => arch/x86/platform}/efi/fake_mem.c (58%)
create mode 100644 arch/x86/platform/efi/memmap.c
delete mode 100644 drivers/firmware/efi/fake_mem.h
delete mode 100644 drivers/firmware/efi/x86_fake_mem.c
--
2.35.1
next reply other threads:[~2022-10-03 11:26 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-03 11:26 Ard Biesheuvel [this message]
2022-10-03 11:26 ` [PATCH v2 1/6] efi: Move EFI fake memmap support into x86 arch tree Ard Biesheuvel
2022-10-03 11:26 ` [PATCH v2 2/6] efi: memmap: Move manipulation routines " Ard Biesheuvel
2022-10-03 11:26 ` [PATCH v2 3/6] efi: xen: Set EFI_PARAVIRT for Xen dom0 boot on all architectures Ard Biesheuvel
2022-10-03 11:26 ` [PATCH v2 4/6] efi: memmap: Disregard bogus entries instead of returning them Ard Biesheuvel
2022-10-03 15:18 ` Demi Marie Obenour
2022-10-03 15:57 ` Ard Biesheuvel
2022-10-03 11:26 ` [PATCH v2 5/6] efi: xen: Implement memory descriptor lookup based on hypercall Ard Biesheuvel
2022-10-03 15:29 ` Demi Marie Obenour
2022-10-03 15:59 ` Ard Biesheuvel
2022-10-03 16:04 ` Marek Marczykowski-Górecki
2022-10-03 16:22 ` Demi Marie Obenour
2022-10-03 16:37 ` Ard Biesheuvel
2022-10-03 17:04 ` Marek Marczykowski-Górecki
2022-10-03 17:04 ` Marek Marczykowski-Górecki
2022-10-03 17:57 ` Demi Marie Obenour
2022-10-03 18:01 ` Marek Marczykowski-Górecki
2023-01-15 13:31 ` Marek Marczykowski-Górecki
2022-11-19 1:10 ` Demi Marie Obenour
2022-10-03 11:26 ` [PATCH v2 6/6] efi: Apply allowlist to EFI configuration tables when running under Xen Ard Biesheuvel
2022-12-06 23:19 ` Demi Marie Obenour
2023-01-19 19:03 ` [PATCH v3 0/5] efi: Support ESRT " Demi Marie Obenour
2023-01-19 19:03 ` [PATCH v3 1/5] efi: memmap: Disregard bogus entries instead of returning them Demi Marie Obenour
2023-01-19 19:03 ` [PATCH v3 2/5] efi: xen: Implement memory descriptor lookup based on hypercall Demi Marie Obenour
2023-01-19 19:03 ` [PATCH v3 3/5] efi: Apply allowlist to EFI configuration tables when running under Xen Demi Marie Obenour
2023-01-19 19:03 ` [PATCH v3 4/5] efi: Actually enable the ESRT " Demi Marie Obenour
2023-01-19 19:04 ` [PATCH v3 5/5] efi: Warn if trying to reserve memory " Demi Marie Obenour
2023-01-23 7:30 ` [PATCH v3 0/5] efi: Support ESRT " Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221003112625.972646-1-ardb@kernel.org \
--to=ardb@kernel.org \
--cc=anton@enomsg.org \
--cc=ccross@android.com \
--cc=demi@invisiblethingslab.com \
--cc=jgross@suse.com \
--cc=keescook@chromium.org \
--cc=linux-efi@vger.kernel.org \
--cc=marmarek@invisiblethingslab.com \
--cc=oleksandr_tyshchenko@epam.com \
--cc=pjones@redhat.com \
--cc=sstabellini@kernel.org \
--cc=tony.luck@intel.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.