diff mbox series

[2/6,B] efi: Restrict efivar_ssdt_load when the kernel is locked down

Message ID 20200619124833.633575-3-seth.forshee@canonical.com
State New
Headers show
Series Lockdown updates | expand

Commit Message

Seth Forshee June 19, 2020, 12:48 p.m. UTC
From: Matthew Garrett <matthewgarrett@google.com>

BugLink: https://bugs.launchpad.net/bugs/1884159

efivar_ssdt_load allows the kernel to import arbitrary ACPI code from an
EFI variable, which gives arbitrary code execution in ring 0. Prevent
that when the kernel is locked down.

Signed-off-by: Matthew Garrett <mjg59@google.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: linux-efi@vger.kernel.org
Signed-off-by: James Morris <jmorris@namei.org>
(backported from commit 1957a85b0032a81e6482ca4aab883643b8dae06e)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 drivers/firmware/efi/efi.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 4b4dd5532725..ed4f03dbecfd 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -228,6 +228,11 @@  static void generic_ops_unregister(void)
 static char efivar_ssdt[EFIVAR_SSDT_NAME_MAX] __initdata;
 static int __init efivar_ssdt_setup(char *str)
 {
+	bool locked_down = kernel_is_locked_down("modifying ACPI tables");
+
+	if (locked_down)
+		return -EPERM;
+
 	if (strlen(str) < sizeof(efivar_ssdt))
 		memcpy(efivar_ssdt, str, strlen(str));
 	else