]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
UBUNTU: SAUCE: (efi-lockdown) efi: Lock down the kernel if booted in secure boot...
authorDavid Howells <dhowells@redhat.com>
Mon, 21 Nov 2016 23:55:55 +0000 (23:55 +0000)
committerSeth Forshee <seth.forshee@canonical.com>
Tue, 5 Sep 2017 12:33:56 +0000 (07:33 -0500)
UEFI Secure Boot provides a mechanism for ensuring that the firmware will
only load signed bootloaders and kernels.  Certain use cases may also
require that all kernel modules also be signed.  Add a configuration option
that to lock down the kernel - which includes requiring validly signed
modules - if the kernel is secure-booted.

Signed-off-by: David Howells <dhowells@redhat.com>
(cherry picked from commit 37d1503ec080faf72878bf544a641767dc1515e9
 git://git.kernel.org/pub/scm/linux/kernel/git/jwboyer/fedora.git)
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
arch/x86/Kconfig
arch/x86/kernel/setup.c

index 0b9175cf3414ad01cf98b72832fb687fe5a27ddc..1856d37120a54e075c5c6b5c3b5b7675d7ef13b8 100644 (file)
@@ -1836,6 +1836,18 @@ config EFI_MIXED
 
           If unsure, say N.
 
+config EFI_SECURE_BOOT_LOCK_DOWN
+       def_bool n
+       depends on EFI
+       prompt "Lock down the kernel when UEFI Secure Boot is enabled"
+       ---help---
+         UEFI Secure Boot provides a mechanism for ensuring that the firmware
+         will only load signed bootloaders and kernels.  Certain use cases may
+         also require that all kernel modules also be signed and that
+         userspace is prevented from directly changing the running kernel
+         image.  Say Y here to automatically lock down the kernel when a
+         system boots with UEFI Secure Boot enabled.
+
 config SECCOMP
        def_bool y
        prompt "Enable seccomp to safely compute untrusted bytecode"
index 319995f5834562fcb3db766f473f981a4e88a8b9..d0128aef43ce84a2b7f997db3e456bd7a8d405f9 100644 (file)
@@ -69,6 +69,7 @@
 #include <linux/crash_dump.h>
 #include <linux/tboot.h>
 #include <linux/jiffies.h>
+#include <linux/security.h>
 
 #include <linux/usb/xhci-dbgp.h>
 #include <video/edid.h>
@@ -1191,7 +1192,12 @@ void __init setup_arch(char **cmdline_p)
                        break;
                case efi_secureboot_mode_enabled:
                        set_bit(EFI_SECURE_BOOT, &efi.flags);
-                       pr_info("Secure boot enabled\n");
+                       if (IS_ENABLED(CONFIG_EFI_SECURE_BOOT_LOCK_DOWN)) {
+                               lock_kernel_down();
+                               pr_info("Secure boot enabled and kernel locked down\n");
+                       } else {
+                               pr_info("Secure boot enabled\n");
+                       }
                        break;
                default:
                        pr_info("Secure boot could not be determined\n");