All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: linux-security-module@vger.kernel.org
Cc: gnomes@lxorguk.ukuu.org.uk, linux-efi@vger.kernel.org,
	dhowells@redhat.com, linux-kernel@vger.kernel.org,
	jforbes@redhat.com
Subject: [PATCH 30/30] efi: Lock down the kernel if booted in secure boot mode
Date: Thu,  9 Nov 2017 17:34:27 +0000	[thread overview]
Message-ID: <151024886689.28329.1546645765141944290.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <151024863544.28329.2436580122759221600.stgit@warthog.procyon.org.uk>

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>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
cc: linux-efi@vger.kernel.org
---

 arch/x86/kernel/setup.c |    6 ++++--
 security/Kconfig        |   14 ++++++++++++++
 security/lock_down.c    |    1 +
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 7c2162f9e769..4e38327efb2e 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -64,6 +64,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/ctype.h>
 #include <linux/uaccess.h>
+#include <linux/security.h>
 
 #include <linux/percpu.h>
 #include <linux/crash_dump.h>
@@ -1039,6 +1040,9 @@ void __init setup_arch(char **cmdline_p)
 	if (efi_enabled(EFI_BOOT))
 		efi_init();
 
+	efi_set_secure_boot(boot_params.secure_boot);
+	init_lockdown();
+
 	dmi_scan_machine();
 	dmi_memdev_walk();
 	dmi_set_dump_stack_arch_desc();
@@ -1197,8 +1201,6 @@ void __init setup_arch(char **cmdline_p)
 	/* Allocate bigger log buffer */
 	setup_log_buf(1);
 
-	efi_set_secure_boot(boot_params.secure_boot);
-
 	reserve_initrd();
 
 	acpi_table_upgrade();
diff --git a/security/Kconfig b/security/Kconfig
index 1e997be94ba2..a4fa8b826039 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -222,6 +222,20 @@ config ALLOW_LOCKDOWN_LIFT_BY_SYSRQ
 	  Allow the lockdown on a kernel to be lifted, by pressing a SysRq key
 	  combination on a wired keyboard.
 
+config LOCK_DOWN_IN_EFI_SECURE_BOOT
+	bool "Lock down the kernel in EFI Secure Boot mode"
+	default n
+	select LOCK_DOWN_KERNEL
+	depends on EFI
+	help
+	  UEFI Secure Boot provides a mechanism for ensuring that the firmware
+	  will only load signed bootloaders and kernels.  Secure boot mode may
+	  be determined from EFI variables provided by the system firmware if
+	  not indicated by the boot parameters.
+
+	  Enabling this option turns on results in kernel lockdown being
+	  triggered if EFI Secure Boot is set.
+
 
 source security/selinux/Kconfig
 source security/smack/Kconfig
diff --git a/security/lock_down.c b/security/lock_down.c
index 2c6b00f0c229..527f7e51dc8d 100644
--- a/security/lock_down.c
+++ b/security/lock_down.c
@@ -12,6 +12,7 @@
 #include <linux/security.h>
 #include <linux/export.h>
 #include <linux/sysrq.h>
+#include <linux/efi.h>
 #include <asm/setup.h>
 
 #ifdef CONFIG_ALLOW_LOCKDOWN_LIFT_BY_SYSRQ

WARNING: multiple messages have this Message-ID (diff)
From: David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: gnomes-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	jforbes-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Subject: [PATCH 30/30] efi: Lock down the kernel if booted in secure boot mode
Date: Thu,  9 Nov 2017 17:34:27 +0000	[thread overview]
Message-ID: <151024886689.28329.1546645765141944290.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <151024863544.28329.2436580122759221600.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>

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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Acked-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---

 arch/x86/kernel/setup.c |    6 ++++--
 security/Kconfig        |   14 ++++++++++++++
 security/lock_down.c    |    1 +
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 7c2162f9e769..4e38327efb2e 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -64,6 +64,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/ctype.h>
 #include <linux/uaccess.h>
+#include <linux/security.h>
 
 #include <linux/percpu.h>
 #include <linux/crash_dump.h>
@@ -1039,6 +1040,9 @@ void __init setup_arch(char **cmdline_p)
 	if (efi_enabled(EFI_BOOT))
 		efi_init();
 
+	efi_set_secure_boot(boot_params.secure_boot);
+	init_lockdown();
+
 	dmi_scan_machine();
 	dmi_memdev_walk();
 	dmi_set_dump_stack_arch_desc();
@@ -1197,8 +1201,6 @@ void __init setup_arch(char **cmdline_p)
 	/* Allocate bigger log buffer */
 	setup_log_buf(1);
 
-	efi_set_secure_boot(boot_params.secure_boot);
-
 	reserve_initrd();
 
 	acpi_table_upgrade();
diff --git a/security/Kconfig b/security/Kconfig
index 1e997be94ba2..a4fa8b826039 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -222,6 +222,20 @@ config ALLOW_LOCKDOWN_LIFT_BY_SYSRQ
 	  Allow the lockdown on a kernel to be lifted, by pressing a SysRq key
 	  combination on a wired keyboard.
 
+config LOCK_DOWN_IN_EFI_SECURE_BOOT
+	bool "Lock down the kernel in EFI Secure Boot mode"
+	default n
+	select LOCK_DOWN_KERNEL
+	depends on EFI
+	help
+	  UEFI Secure Boot provides a mechanism for ensuring that the firmware
+	  will only load signed bootloaders and kernels.  Secure boot mode may
+	  be determined from EFI variables provided by the system firmware if
+	  not indicated by the boot parameters.
+
+	  Enabling this option turns on results in kernel lockdown being
+	  triggered if EFI Secure Boot is set.
+
 
 source security/selinux/Kconfig
 source security/smack/Kconfig
diff --git a/security/lock_down.c b/security/lock_down.c
index 2c6b00f0c229..527f7e51dc8d 100644
--- a/security/lock_down.c
+++ b/security/lock_down.c
@@ -12,6 +12,7 @@
 #include <linux/security.h>
 #include <linux/export.h>
 #include <linux/sysrq.h>
+#include <linux/efi.h>
 #include <asm/setup.h>
 
 #ifdef CONFIG_ALLOW_LOCKDOWN_LIFT_BY_SYSRQ

WARNING: multiple messages have this Message-ID (diff)
From: dhowells@redhat.com (David Howells)
To: linux-security-module@vger.kernel.org
Subject: [PATCH 30/30] efi: Lock down the kernel if booted in secure boot mode
Date: Thu,  9 Nov 2017 17:34:27 +0000	[thread overview]
Message-ID: <151024886689.28329.1546645765141944290.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <151024863544.28329.2436580122759221600.stgit@warthog.procyon.org.uk>

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>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
cc: linux-efi at vger.kernel.org
---

 arch/x86/kernel/setup.c |    6 ++++--
 security/Kconfig        |   14 ++++++++++++++
 security/lock_down.c    |    1 +
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 7c2162f9e769..4e38327efb2e 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -64,6 +64,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/ctype.h>
 #include <linux/uaccess.h>
+#include <linux/security.h>
 
 #include <linux/percpu.h>
 #include <linux/crash_dump.h>
@@ -1039,6 +1040,9 @@ void __init setup_arch(char **cmdline_p)
 	if (efi_enabled(EFI_BOOT))
 		efi_init();
 
+	efi_set_secure_boot(boot_params.secure_boot);
+	init_lockdown();
+
 	dmi_scan_machine();
 	dmi_memdev_walk();
 	dmi_set_dump_stack_arch_desc();
@@ -1197,8 +1201,6 @@ void __init setup_arch(char **cmdline_p)
 	/* Allocate bigger log buffer */
 	setup_log_buf(1);
 
-	efi_set_secure_boot(boot_params.secure_boot);
-
 	reserve_initrd();
 
 	acpi_table_upgrade();
diff --git a/security/Kconfig b/security/Kconfig
index 1e997be94ba2..a4fa8b826039 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -222,6 +222,20 @@ config ALLOW_LOCKDOWN_LIFT_BY_SYSRQ
 	  Allow the lockdown on a kernel to be lifted, by pressing a SysRq key
 	  combination on a wired keyboard.
 
+config LOCK_DOWN_IN_EFI_SECURE_BOOT
+	bool "Lock down the kernel in EFI Secure Boot mode"
+	default n
+	select LOCK_DOWN_KERNEL
+	depends on EFI
+	help
+	  UEFI Secure Boot provides a mechanism for ensuring that the firmware
+	  will only load signed bootloaders and kernels.  Secure boot mode may
+	  be determined from EFI variables provided by the system firmware if
+	  not indicated by the boot parameters.
+
+	  Enabling this option turns on results in kernel lockdown being
+	  triggered if EFI Secure Boot is set.
+
 
 source security/selinux/Kconfig
 source security/smack/Kconfig
diff --git a/security/lock_down.c b/security/lock_down.c
index 2c6b00f0c229..527f7e51dc8d 100644
--- a/security/lock_down.c
+++ b/security/lock_down.c
@@ -12,6 +12,7 @@
 #include <linux/security.h>
 #include <linux/export.h>
 #include <linux/sysrq.h>
+#include <linux/efi.h>
 #include <asm/setup.h>
 
 #ifdef CONFIG_ALLOW_LOCKDOWN_LIFT_BY_SYSRQ

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-11-09 17:34 UTC|newest]

Thread overview: 130+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-09 17:30 [PATCH 00/30] security, efi: Add kernel lockdown David Howells
2017-11-09 17:30 ` David Howells
2017-11-09 17:30 ` [PATCH 01/30] Add the ability to lock down access to the running kernel image David Howells
2017-11-09 17:30   ` David Howells
2017-11-09 17:30 ` [PATCH 02/30] Add a SysRq option to lift kernel lockdown David Howells
2017-11-09 17:30   ` David Howells
2017-11-09 17:30   ` David Howells
2017-11-09 17:31 ` [PATCH 03/30] ima: require secure_boot rules in lockdown mode David Howells
2017-11-09 17:31   ` David Howells
2017-11-09 17:31 ` [PATCH 04/30] Enforce module signatures if the kernel is locked down David Howells
2017-11-09 17:31   ` David Howells
2017-11-09 17:31   ` David Howells
2017-11-09 17:31 ` [PATCH 05/30] Restrict /dev/{mem, kmem, port} when " David Howells
2017-11-09 17:31   ` David Howells
2017-11-09 17:31 ` [PATCH 06/30] kexec: Disable at runtime if " David Howells
2017-11-09 17:31   ` David Howells
2017-11-09 17:31 ` [PATCH 07/30] Copy secure_boot flag in boot params across kexec reboot David Howells
2017-11-09 17:31   ` David Howells
2017-11-09 17:31 ` [PATCH 08/30] kexec_file: Restrict at runtime if the kernel is locked down David Howells
2017-11-09 17:31   ` David Howells
2018-01-11 11:59   ` Jiri Bohac
2018-01-11 11:59     ` Jiri Bohac
2018-01-11 11:59     ` Jiri Bohac
2018-01-11 12:01     ` [PATCH 08a/30] kexec_file: split KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE Jiri Bohac
2018-01-11 12:01       ` Jiri Bohac
2018-01-11 12:01       ` Jiri Bohac
2018-01-11 12:02     ` [PATCH 08b/30] kexec_file: Restrict at runtime if the kernel is locked down Jiri Bohac
2018-01-11 12:02       ` Jiri Bohac
2018-01-16 16:31     ` [PATCH 08a/30] kexec_file: split KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE David Howells
2018-01-16 16:31       ` David Howells
2018-01-16 16:31       ` David Howells
2018-01-16 19:39       ` Jiri Bohac
2018-01-16 19:39         ` Jiri Bohac
2018-01-17 16:34       ` David Howells
2018-01-17 16:34         ` David Howells
2018-01-19 12:54         ` Jiri Bohac
2018-01-19 12:54           ` Jiri Bohac
2018-01-19 12:54           ` Jiri Bohac
2018-02-21 16:20         ` David Howells
2018-02-21 16:20           ` David Howells
2018-01-11 12:43   ` [PATCH 08/30] kexec_file: Restrict at runtime if the kernel is locked down David Howells
2018-01-11 12:43     ` David Howells
2018-01-11 12:43     ` David Howells
2018-01-11 12:47   ` David Howells
2018-01-11 12:47     ` David Howells
2018-01-11 15:44     ` Jiri Bohac
2018-01-11 15:44       ` Jiri Bohac
2018-01-11 15:44       ` Jiri Bohac
2018-01-17 16:16     ` David Howells
2018-01-17 16:16       ` David Howells
2018-01-17 16:16       ` David Howells
2017-11-09 17:31 ` [PATCH 09/30] hibernate: Disable when " David Howells
2017-11-09 17:31   ` David Howells
2017-11-09 17:31   ` David Howells
2017-11-09 17:31 ` [PATCH 10/30] uswsusp: " David Howells
2017-11-09 17:31   ` David Howells
2017-11-09 17:32 ` [PATCH 11/30] PCI: Lock down BAR access " David Howells
2017-11-09 17:32   ` David Howells
2017-11-09 17:32 ` [PATCH 12/30] x86: Lock down IO port " David Howells
2017-11-09 17:32   ` David Howells
2017-11-09 17:32 ` [PATCH 13/30] x86/msr: Restrict MSR " David Howells
2017-11-09 17:32   ` David Howells
2017-11-09 17:32 ` [PATCH 14/30] asus-wmi: Restrict debugfs interface " David Howells
2017-11-09 17:32   ` David Howells
2017-11-09 17:32 ` [PATCH 15/30] ACPI: Limit access to custom_method " David Howells
2017-11-09 17:32   ` David Howells
2017-11-09 17:32 ` [PATCH 16/30] acpi: Ignore acpi_rsdp kernel param when the kernel has been " David Howells
2017-11-09 17:32   ` David Howells
2017-11-09 17:32 ` [PATCH 17/30] acpi: Disable ACPI table override if the kernel is " David Howells
2017-11-09 17:32   ` David Howells
2017-11-09 17:32 ` [PATCH 18/30] acpi: Disable APEI error injection " David Howells
2017-11-09 17:32   ` David Howells
2019-11-07  8:21   ` Joey Lee
2022-05-28  0:11     ` joeyli
2017-11-09 17:33 ` [PATCH 19/30] scsi: Lock down the eata driver David Howells
2017-11-09 17:33   ` David Howells
2017-11-09 17:33 ` [PATCH 20/30] Prohibit PCMCIA CIS storage when the kernel is locked down David Howells
2017-11-09 17:33   ` David Howells
2017-11-09 17:33 ` [PATCH 21/30] Lock down TIOCSSERIAL David Howells
2017-11-09 17:33   ` David Howells
2017-11-09 17:33 ` [PATCH 22/30] Lock down module params that specify hardware parameters (eg. ioport) David Howells
2017-11-09 17:33   ` David Howells
2017-11-09 17:33 ` [PATCH 23/30] x86/mmiotrace: Lock down the testmmiotrace module David Howells
2017-11-09 17:33   ` David Howells
2017-11-09 17:33 ` [PATCH 24/30] debugfs: Disallow use of debugfs files when the kernel is locked down David Howells
2017-11-09 17:33   ` David Howells
2017-11-09 17:33 ` [PATCH 25/30] Lock down /proc/kcore David Howells
2017-11-09 17:33   ` David Howells
2017-11-09 17:33 ` [PATCH 26/30] Lock down ftrace David Howells
2017-11-09 17:33   ` David Howells
2017-11-10  9:23   ` Jiri Kosina
2017-11-10  9:23     ` Jiri Kosina
2017-11-10  9:23     ` Jiri Kosina
2017-11-10 10:07   ` David Howells
2017-11-10 10:07     ` David Howells
2017-11-10 10:07     ` David Howells
2017-11-10 10:15     ` Jiri Kosina
2017-11-10 10:15       ` Jiri Kosina
2017-11-10 10:15       ` Jiri Kosina
2017-11-10 10:21     ` David Howells
2017-11-10 10:21       ` David Howells
2017-11-10 10:21       ` David Howells
2017-11-10 10:23       ` Jiri Kosina
2017-11-10 10:23         ` Jiri Kosina
2017-11-10 11:06       ` David Howells
2017-11-10 11:06         ` David Howells
2017-11-10 11:06         ` David Howells
2017-11-09 17:34 ` [PATCH 27/30] Lock down kprobes David Howells
2017-11-09 17:34   ` David Howells
2017-11-09 17:34 ` [PATCH 28/30] bpf: Restrict kernel image access functions when the kernel is locked down David Howells
2017-11-09 17:34   ` David Howells
2017-11-09 17:34 ` [PATCH 29/30] efi: Add an EFI_SECURE_BOOT flag to indicate secure boot mode David Howells
2017-11-09 17:34   ` David Howells
2017-11-09 17:34 ` David Howells [this message]
2017-11-09 17:34   ` [PATCH 30/30] efi: Lock down the kernel if booted in " David Howells
2017-11-09 17:34   ` David Howells
2018-02-22 13:07 ` [PATCH 04/30] Enforce module signatures if the kernel is locked down David Howells
2018-02-22 13:07   ` David Howells
2018-02-22 18:44   ` Jiri Bohac
2018-02-22 18:44     ` Jiri Bohac
2018-02-22 14:20 ` [PATCH 08/30] kexec_file: Restrict at runtime " David Howells
2018-02-22 14:20   ` David Howells
2018-02-22 19:08   ` Jiri Bohac
2018-02-22 19:08     ` Jiri Bohac
2018-02-22 14:21 ` David Howells
2018-02-22 14:21   ` David Howells
2018-02-22 19:14   ` Jiri Bohac
2018-02-22 19:14     ` Jiri Bohac
2018-03-03  1:18 ` [PATCH 00/30] security, efi: Add kernel lockdown Andrew Morton
2018-03-03  1:18   ` Andrew Morton

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=151024886689.28329.1546645765141944290.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=jforbes@redhat.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.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.