Re: [PATCH 17/27] acpi: Disable APEI error injection if the kernel is locked down

2017-10-19 Thread joeyli
On Thu, Oct 19, 2017 at 03:52:41PM +0100, David Howells wrote: > From: Linn Crosetto > > ACPI provides an error injection mechanism, EINJ, for debugging and testing > the ACPI Platform Error Interface (APEI) and other RAS features. If > supported by the firmware, ACPI specification 5.0 and later

Re: [PATCH 16/27] acpi: Disable ACPI table override if the kernel is locked down

2017-10-19 Thread joeyli
On Thu, Oct 19, 2017 at 03:52:34PM +0100, David Howells wrote: > From: Linn Crosetto > > >From the kernel documentation (initrd_table_override.txt): > > If the ACPI_INITRD_TABLE_OVERRIDE compile option is true, it is possible > to override nearly any ACPI table provided by the BIOS with an >

Re: [PATCH 15/27] acpi: Ignore acpi_rsdp kernel param when the kernel has been locked down

2017-10-19 Thread joeyli
On Thu, Oct 19, 2017 at 03:52:27PM +0100, David Howells wrote: > From: Josh Boyer > > This option allows userspace to pass the RSDP address to the kernel, which > makes it possible for a user to modify the workings of hardware . Reject > the option when the kernel is locked down. > > Signed-off

Re: [PATCH 14/27] ACPI: Limit access to custom_method when the kernel is locked down

2017-10-19 Thread joeyli
On Thu, Oct 19, 2017 at 03:52:19PM +0100, David Howells wrote: > From: Matthew Garrett > > custom_method effectively allows arbitrary access to system memory, making > it possible for an attacker to circumvent restrictions on module loading. > Disable it if the kernel is locked down. > > Signed-

Re: [PATCH 13/27] asus-wmi: Restrict debugfs interface when the kernel is locked down

2017-10-19 Thread joeyli
On Thu, Oct 19, 2017 at 03:52:11PM +0100, David Howells wrote: > From: Matthew Garrett > > We have no way of validating what all of the Asus WMI methods do on a given > machine - and there's a risk that some will allow hardware state to be > manipulated in such a way that arbitrary code can be ex

Re: [PATCH 12/27] x86/msr: Restrict MSR access when the kernel is locked down

2017-10-19 Thread joeyli
On Thu, Oct 19, 2017 at 03:52:04PM +0100, David Howells wrote: > From: Matthew Garrett > > Writing to MSRs should not be allowed if the kernel is locked down, since > it could lead to execution of arbitrary code in kernel mode. Based on a > patch by Kees Cook. > > Signed-off-by: Matthew Garrett

Re: [PATCH 11/27] x86: Lock down IO port access when the kernel is locked down

2017-10-19 Thread joeyli
On Thu, Oct 19, 2017 at 03:51:56PM +0100, David Howells wrote: > From: Matthew Garrett > > IO port access would permit users to gain access to PCI configuration > registers, which in turn (on a lot of hardware) give access to MMIO > register space. This would potentially permit root to trigger ar

Re: [PATCH 10/27] PCI: Lock down BAR access when the kernel is locked down

2017-10-19 Thread joeyli
On Thu, Oct 19, 2017 at 03:51:49PM +0100, David Howells wrote: > From: Matthew Garrett > > Any hardware that can potentially generate DMA has to be locked down in > order to avoid it being possible for an attacker to modify kernel code, > allowing them to circumvent disabled module loading or mod

Re: [PATCH 09/27] uswsusp: Disable when the kernel is locked down

2017-10-19 Thread joeyli
On Thu, Oct 19, 2017 at 03:51:42PM +0100, David Howells wrote: > From: Matthew Garrett > > uswsusp allows a user process to dump and then restore kernel state, which > makes it possible to modify the running kernel. Disable this if the kernel > is locked down. > > Signed-off-by: Matthew Garrett

Re: [PATCH 08/27] hibernate: Disable when the kernel is locked down

2017-10-19 Thread joeyli
On Thu, Oct 19, 2017 at 03:51:34PM +0100, David Howells wrote: > From: Josh Boyer > > There is currently no way to verify the resume image when returning > from hibernate. This might compromise the signed modules trust model, > so until we can work with signed hibernate images we disable it when

Re: [PATCH 06/27] Copy secure_boot flag in boot params across kexec reboot

2017-10-19 Thread joeyli
On Thu, Oct 19, 2017 at 03:51:20PM +0100, David Howells wrote: > From: Dave Young > > Kexec reboot in case secure boot being enabled does not keep the secure > boot mode in new kernel, so later one can load unsigned kernel via legacy > kexec_load. In this state, the system is missing the protect

Re: [PATCH 05/27] kexec: Disable at runtime if the kernel is locked down

2017-10-19 Thread joeyli
On Thu, Oct 19, 2017 at 03:51:09PM +0100, David Howells wrote: > From: Matthew Garrett > > kexec permits the loading and execution of arbitrary code in ring 0, which > is something that lock-down is meant to prevent. It makes sense to disable > kexec in this situation. > > This does not affect k

Re: [PATCH 04/27] Restrict /dev/mem and /dev/kmem when the kernel is locked down

2017-10-19 Thread joeyli
Hi David, Thanks for you send out this series. On Thu, Oct 19, 2017 at 03:51:02PM +0100, David Howells wrote: > From: Matthew Garrett > > Allowing users to write to address space makes it possible for the kernel to > be subverted, avoiding module loading restrictions. Prevent this when the > k

Re: [PATCH 03/27] Enforce module signatures if the kernel is locked down

2017-10-19 Thread joeyli
Hi David, Thanks for you send our this series. On Thu, Oct 19, 2017 at 03:50:55PM +0100, David Howells wrote: > If the kernel is locked down, require that all modules have valid > signatures that we can verify. > > Signed-off-by: David Howells I have reviewed and tested this patch. Please feel

Re: [PATCH 18/27] bpf: Restrict kernel image access functions when the kernel is locked down

2017-10-19 Thread joeyli
Hi Alexei, Thanks for your review! On Thu, Oct 19, 2017 at 03:18:30PM -0700, Alexei Starovoitov wrote: > On Thu, Oct 19, 2017 at 03:52:49PM +0100, David Howells wrote: > > From: Chun-Yi Lee > > > > There are some bpf functions can be used to read kernel memory: > > bpf_probe_read, bpf_probe_wr

Re: [PATCH 18/27] bpf: Restrict kernel image access functions when the kernel is locked down

2017-10-19 Thread Alexei Starovoitov
On Thu, Oct 19, 2017 at 11:48:34PM +0100, David Howells wrote: > Alexei Starovoitov wrote: > > > > @@ -65,6 +65,11 @@ BPF_CALL_3(bpf_probe_read, void *, dst, u32, size, > > > const void *, unsafe_ptr) > > > { > > > int ret; > > > > > > + if (kernel_is_locked_down("BPF")) { > > > + m

Re: [PATCH 18/27] bpf: Restrict kernel image access functions when the kernel is locked down

2017-10-19 Thread David Howells
Alexei Starovoitov wrote: > > @@ -65,6 +65,11 @@ BPF_CALL_3(bpf_probe_read, void *, dst, u32, size, const > > void *, unsafe_ptr) > > { > > int ret; > > > > + if (kernel_is_locked_down("BPF")) { > > + memset(dst, 0, size); > > + return -EPERM; > > + } > > That does

Re: [PATCH 00/27] security, efi: Add kernel lockdown

2017-10-19 Thread David Howells
I've pushed a new version to git that fixes bugs in patches 1 and 2. David -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH 18/27] bpf: Restrict kernel image access functions when the kernel is locked down

2017-10-19 Thread Alexei Starovoitov
On Thu, Oct 19, 2017 at 03:52:49PM +0100, David Howells wrote: > From: Chun-Yi Lee > > There are some bpf functions can be used to read kernel memory: > bpf_probe_read, bpf_probe_write_user and bpf_trace_printk. These allow > private keys in kernel memory (e.g. the hibernation image signing key)

Re: [PATCH 02/27] Add a SysRq option to lift kernel lockdown

2017-10-19 Thread David Howells
Randy Dunlap wrote: > > +config ALLOW_LOCKDOWN_LIFT > > + bool > > + help > > + Allow the lockdown on a kernel to be lifted, thereby restoring the > > + ability of userspace to access the kernel image (eg. by SysRq+x under > > how about:

Re: [PATCH 02/27] Add a SysRq option to lift kernel lockdown

2017-10-19 Thread Randy Dunlap
On 10/19/17 07:50, David Howells wrote: > From: Kyle McMartin > > Make an option to provide a sysrq key that will lift the kernel lockdown, > thereby allowing the running kernel image to be accessed and modified. > > On x86_64 this is triggered with SysRq+x, but this key may not be available > o

[PATCH 01/27] Add the ability to lock down access to the running kernel image

2017-10-19 Thread David Howells
Provide a single call to allow kernel code to determine whether the system should be locked down, thereby disallowing various accesses that might allow the running kernel image to be changed including the loading of modules that aren't validly signed with a key we recognise, fiddling with MSR regis

[PATCH 02/27] Add a SysRq option to lift kernel lockdown

2017-10-19 Thread David Howells
From: Kyle McMartin Make an option to provide a sysrq key that will lift the kernel lockdown, thereby allowing the running kernel image to be accessed and modified. On x86_64 this is triggered with SysRq+x, but this key may not be available on all arches, so it is set by setting LOCKDOWN_LIFT_KE

[PATCH 03/27] Enforce module signatures if the kernel is locked down

2017-10-19 Thread David Howells
If the kernel is locked down, require that all modules have valid signatures that we can verify. Signed-off-by: David Howells --- kernel/module.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/module.c b/kernel/module.c index de66ec825992..3d9a3270c179 100644 --

[PATCH 04/27] Restrict /dev/mem and /dev/kmem when the kernel is locked down

2017-10-19 Thread David Howells
From: Matthew Garrett Allowing users to write to address space makes it possible for the kernel to be subverted, avoiding module loading restrictions. Prevent this when the kernel has been locked down. Signed-off-by: Matthew Garrett Signed-off-by: David Howells --- drivers/char/mem.c |6

[PATCH 05/27] kexec: Disable at runtime if the kernel is locked down

2017-10-19 Thread David Howells
From: Matthew Garrett kexec permits the loading and execution of arbitrary code in ring 0, which is something that lock-down is meant to prevent. It makes sense to disable kexec in this situation. This does not affect kexec_file_load() which can check for a signature on the image to be booted.

[PATCH 06/27] Copy secure_boot flag in boot params across kexec reboot

2017-10-19 Thread David Howells
From: Dave Young Kexec reboot in case secure boot being enabled does not keep the secure boot mode in new kernel, so later one can load unsigned kernel via legacy kexec_load. In this state, the system is missing the protections provided by secure boot. Adding a patch to fix this by retain the s

[PATCH 07/27] kexec_file: Disable at runtime if securelevel has been set

2017-10-19 Thread David Howells
From: Chun-Yi Lee When KEXEC_VERIFY_SIG is not enabled, kernel should not loads image through kexec_file systemcall if securelevel has been set. This code was showed in Matthew's patch but not in git: https://lkml.org/lkml/2015/3/13/778 Cc: Matthew Garrett Signed-off-by: Chun-Yi Lee Signed-of

[PATCH 09/27] uswsusp: Disable when the kernel is locked down

2017-10-19 Thread David Howells
From: Matthew Garrett uswsusp allows a user process to dump and then restore kernel state, which makes it possible to modify the running kernel. Disable this if the kernel is locked down. Signed-off-by: Matthew Garrett Signed-off-by: David Howells cc: linux...@vger.kernel.org --- kernel/pow

[PATCH 10/27] PCI: Lock down BAR access when the kernel is locked down

2017-10-19 Thread David Howells
From: Matthew Garrett Any hardware that can potentially generate DMA has to be locked down in order to avoid it being possible for an attacker to modify kernel code, allowing them to circumvent disabled module loading or module signing. Default to paranoid - in future we can potentially relax thi

[PATCH 12/27] x86/msr: Restrict MSR access when the kernel is locked down

2017-10-19 Thread David Howells
From: Matthew Garrett Writing to MSRs should not be allowed if the kernel is locked down, since it could lead to execution of arbitrary code in kernel mode. Based on a patch by Kees Cook. Signed-off-by: Matthew Garrett Signed-off-by: David Howells Acked-by: Kees Cook Reviewed-by: Thomas Glei

[PATCH 08/27] hibernate: Disable when the kernel is locked down

2017-10-19 Thread David Howells
From: Josh Boyer There is currently no way to verify the resume image when returning from hibernate. This might compromise the signed modules trust model, so until we can work with signed hibernate images we disable it when the kernel is locked down. Signed-off-by: Josh Boyer Signed-off-by: Da

[PATCH 11/27] x86: Lock down IO port access when the kernel is locked down

2017-10-19 Thread David Howells
From: Matthew Garrett IO port access would permit users to gain access to PCI configuration registers, which in turn (on a lot of hardware) give access to MMIO register space. This would potentially permit root to trigger arbitrary DMA, so lock it down by default. This also implicitly locks down

[PATCH 13/27] asus-wmi: Restrict debugfs interface when the kernel is locked down

2017-10-19 Thread David Howells
From: Matthew Garrett We have no way of validating what all of the Asus WMI methods do on a given machine - and there's a risk that some will allow hardware state to be manipulated in such a way that arbitrary code can be executed in the kernel, circumventing module loading restrictions. Prevent

[PATCH 15/27] acpi: Ignore acpi_rsdp kernel param when the kernel has been locked down

2017-10-19 Thread David Howells
From: Josh Boyer This option allows userspace to pass the RSDP address to the kernel, which makes it possible for a user to modify the workings of hardware . Reject the option when the kernel is locked down. Signed-off-by: Josh Boyer Signed-off-by: David Howells cc: Dave Young cc: linux-a...

[PATCH 16/27] acpi: Disable ACPI table override if the kernel is locked down

2017-10-19 Thread David Howells
From: Linn Crosetto >From the kernel documentation (initrd_table_override.txt): If the ACPI_INITRD_TABLE_OVERRIDE compile option is true, it is possible to override nearly any ACPI table provided by the BIOS with an instrumented, modified one. When securelevel is set, the kernel should di

[PATCH 17/27] acpi: Disable APEI error injection if the kernel is locked down

2017-10-19 Thread David Howells
From: Linn Crosetto ACPI provides an error injection mechanism, EINJ, for debugging and testing the ACPI Platform Error Interface (APEI) and other RAS features. If supported by the firmware, ACPI specification 5.0 and later provide for a way to specify a physical memory address to which to injec

[PATCH 18/27] bpf: Restrict kernel image access functions when the kernel is locked down

2017-10-19 Thread David Howells
From: Chun-Yi Lee There are some bpf functions can be used to read kernel memory: bpf_probe_read, bpf_probe_write_user and bpf_trace_printk. These allow private keys in kernel memory (e.g. the hibernation image signing key) to be read by an eBPF program. Prohibit those functions when the kernel

[PATCH 19/27] scsi: Lock down the eata driver

2017-10-19 Thread David Howells
When the kernel is running in secure boot mode, we lock down the kernel to prevent userspace from modifying the running kernel image. Whilst this includes prohibiting access to things like /dev/mem, it must also prevent access by means of configuring driver modules in such a way as to cause a devi

[PATCH 21/27] Lock down TIOCSSERIAL

2017-10-19 Thread David Howells
Lock down TIOCSSERIAL as that can be used to change the ioport and irq settings on a serial port. This only appears to be an issue for the serial drivers that use the core serial code. All other drivers seem to either ignore attempts to change port/irq or give an error. Reported-by: Greg Kroah-H

[PATCH 20/27] Prohibit PCMCIA CIS storage when the kernel is locked down

2017-10-19 Thread David Howells
Prohibit replacement of the PCMCIA Card Information Structure when the kernel is locked down. Suggested-by: Dominik Brodowski Signed-off-by: David Howells cc: linux-pcm...@lists.infradead.org --- drivers/pcmcia/cistpl.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pcmcia/c

[PATCH 22/27] Lock down module params that specify hardware parameters (eg. ioport)

2017-10-19 Thread David Howells
Provided an annotation for module parameters that specify hardware parameters (such as io ports, iomem addresses, irqs, dma channels, fixed dma buffers and other types). Suggested-by: Alan Cox Signed-off-by: David Howells --- kernel/params.c | 26 +- 1 file changed, 2

[PATCH 23/27] x86/mmiotrace: Lock down the testmmiotrace module

2017-10-19 Thread David Howells
The testmmiotrace module shouldn't be permitted when the kernel is locked down as it can be used to arbitrarily read and write MMIO space. Suggested-by: Thomas Gleixner Signed-off-by: David Howells cc: Steven Rostedt cc: Ingo Molnar cc: "H. Peter Anvin" cc: x...@kernel.org --- arch/x86/mm/t

[PATCH 24/27] debugfs: Disallow use of debugfs files when the kernel is locked down

2017-10-19 Thread David Howells
Disallow opening of debugfs files when the kernel is locked down as various drivers give raw access to hardware through debugfs. Accesses to tracefs should use /sys/kernel/tracing/ rather than /sys/kernel/debug/tracing/. Possibly a symlink should be emplaced. Normal device interaction should be

[PATCH 27/27] efi: Lock down the kernel if booted in secure boot mode

2017-10-19 Thread David Howells
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

[PATCH 25/27] Lock down /proc/kcore

2017-10-19 Thread David Howells
Disallow access to /proc/kcore when the kernel is locked down to prevent access to cryptographic data. Signed-off-by: David Howells --- fs/proc/kcore.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index 45629f4b5402..176cf749e650 100644 --- a/fs/pro

[PATCH 26/27] efi: Add an EFI_SECURE_BOOT flag to indicate secure boot mode

2017-10-19 Thread David Howells
UEFI machines can be booted in Secure Boot mode. Add an EFI_SECURE_BOOT flag that can be passed to efi_enabled() to find out whether secure boot is enabled. Move the switch-statement in x86's setup_arch() that inteprets the secure_boot boot parameter to generic code and set the bit there. Sugges

[PATCH 14/27] ACPI: Limit access to custom_method when the kernel is locked down

2017-10-19 Thread David Howells
From: Matthew Garrett custom_method effectively allows arbitrary access to system memory, making it possible for an attacker to circumvent restrictions on module loading. Disable it if the kernel is locked down. Signed-off-by: Matthew Garrett Signed-off-by: David Howells cc: linux-a...@vger.ke

[PATCH 00/27] security, efi: Add kernel lockdown

2017-10-19 Thread David Howells
m methods. .RE .P The following facilities are restricted: .P .RS Only validly signed modules may be loaded. .P Only validly signed binaries may be kexec'd. .P Only validly signed device firmware may be loaded. .P Unencrypted hibernation/suspend to swap are disallowed as the kernel image is saved to a medium that can then be accessed. .P Use of debugfs is not permitted