diff mbox series

[5/9,D] efi: Restrict efivar_ssdt_load when the kernel is locked down

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

Commit Message

Seth Forshee June 18, 2020, 11:14 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)
Reported-by: Jason A. Donenfeld <Jason@zx2c4.com>
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 9d9089ce5dfa..4031138d8b65 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -244,6 +244,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