LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PULL REQUEST] Lockdown patches for 5.2
@ 2019-03-25 22:09 Matthew Garrett
  2019-03-25 22:09 ` [PATCH 01/27] Add the ability to lock down access to the running kernel image Matthew Garrett
                   ` (26 more replies)
  0 siblings, 27 replies; 53+ messages in thread
From: Matthew Garrett @ 2019-03-25 22:09 UTC (permalink / raw)
  To: jmorris; +Cc: linux-security-module, linux-kernel, dhowells

The following changes since commit 468e91cecb3218afd684b8c422490dfebe0691bb:

  keys: fix missing __user in KEYCTL_PKEY_QUERY (2019-03-04 15:48:37 -0800)

are available in the Git repository at:

  https://github.com/mjg59/linux lock_down

for you to fetch changes up to 1c57935ab108280aa79fe4420d4bc13e19bd38e2:

  kexec: Allow kexec_file() with appropriate IMA policy when locked down (2019-03-25 15:00:35 -0700)

This version replaces the original IMA integration with a new approach
tied to IMA architecture policy. It also drops the sysrq patch for now,
since that primarily makes sense in the context of lockdown policy being
automatically enabled based on boot state.

----------------------------------------------------------------
Dave Young (1):
      Copy secure_boot flag in boot params across kexec reboot

David Howells (12):
      Add the ability to lock down access to the running kernel image
      Enforce module signatures if the kernel is locked down
      Prohibit PCMCIA CIS storage when the kernel is locked down
      Lock down TIOCSSERIAL
      Lock down module params that specify hardware parameters (eg. ioport)
      x86/mmiotrace: Lock down the testmmiotrace module
      Lock down /proc/kcore
      Lock down kprobes
      bpf: Restrict kernel image access functions when the kernel is locked down
      Lock down perf
      debugfs: Restrict debugfs when the kernel is locked down
      lockdown: Print current->comm in restriction messages

Jiri Bohac (2):
      kexec_file: split KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE
      kexec_file: Restrict at runtime if the kernel is locked down

Josh Boyer (2):
      hibernate: Disable when the kernel is locked down
      acpi: Ignore acpi_rsdp kernel param when the kernel has been locked down

Linn Crosetto (2):
      acpi: Disable ACPI table override if the kernel is locked down
      acpi: Disable APEI error injection if the kernel is locked down

Matthew Garrett (8):
      Restrict /dev/{mem,kmem,port} when the kernel is locked down
      kexec_load: Disable at runtime if the kernel is locked down
      uswsusp: Disable when the kernel is locked down
      PCI: Lock down BAR access when the kernel is locked down
      x86: Lock down IO port access when the kernel is locked down
      x86/msr: Restrict MSR access when the kernel is locked down
      ACPI: Limit access to custom_method when the kernel is locked down
      kexec: Allow kexec_file() with appropriate IMA policy when locked down

 arch/x86/Kconfig                       | 20 +++++++++---
 arch/x86/kernel/ioport.c               |  6 ++--
 arch/x86/kernel/kexec-bzimage64.c      |  1 +
 arch/x86/kernel/msr.c                  | 10 ++++++
 arch/x86/mm/testmmiotrace.c            |  3 ++
 crypto/asymmetric_keys/verify_pefile.c |  4 ++-
 drivers/acpi/apei/einj.c               |  3 ++
 drivers/acpi/custom_method.c           |  3 ++
 drivers/acpi/osl.c                     |  2 +-
 drivers/acpi/tables.c                  |  5 +++
 drivers/char/mem.c                     |  2 ++
 drivers/pci/pci-sysfs.c                |  9 +++++
 drivers/pci/proc.c                     |  9 ++++-
 drivers/pci/syscall.c                  |  3 +-
 drivers/pcmcia/cistpl.c                |  3 ++
 drivers/tty/serial/serial_core.c       |  6 ++++
 fs/debugfs/file.c                      | 28 ++++++++++++++++
 fs/debugfs/inode.c                     | 30 +++++++++++++++--
 fs/proc/kcore.c                        |  2 ++
 include/linux/ima.h                    |  9 +++++
 include/linux/kernel.h                 | 17 ++++++++++
 include/linux/kexec.h                  |  4 +--
 include/linux/security.h               |  9 ++++-
 kernel/bpf/syscall.c                   |  3 ++
 kernel/events/core.c                   |  5 +++
 kernel/kexec.c                         |  7 ++++
 kernel/kexec_file.c                    | 59 +++++++++++++++++++++++++++++----
 kernel/kprobes.c                       |  3 ++
 kernel/module.c                        | 39 ++++++++++++++++++----
 kernel/params.c                        | 26 ++++++++++++---
 kernel/power/hibernate.c               |  2 +-
 kernel/power/user.c                    |  3 ++
 security/Kconfig                       | 15 +++++++++
 security/Makefile                      |  3 ++
 security/integrity/ima/ima.h           |  2 ++
 security/integrity/ima/ima_main.c      |  2 +-
 security/integrity/ima/ima_policy.c    | 50 ++++++++++++++++++++++++++++
 security/lock_down.c                   | 60 ++++++++++++++++++++++++++++++++++
 38 files changed, 430 insertions(+), 37 deletions(-)
 create mode 100644 security/lock_down.c



^ permalink raw reply	[flat|nested] 53+ messages in thread
* [PATCH 00/27] security, efi: Add kernel lockdown
@ 2017-10-19 14:50 David Howells
  2017-10-19 14:51 ` [PATCH 09/27] uswsusp: Disable when the kernel is locked down David Howells
  0 siblings, 1 reply; 53+ messages in thread
From: David Howells @ 2017-10-19 14:50 UTC (permalink / raw)
  To: linux-security-module
  Cc: gnomes, linux-efi, matthew.garrett, gregkh, linux-kernel,
	dhowells, jforbes


Here's a set of patches to institute a "locked-down mode" in the kernel and
to trigger that mode if the kernel is booted in secure-boot mode or through
the command line.

Enabling CONFIG_LOCK_DOWN_KERNEL makes lockdown mode available.

Enabling CONFIG_ALLOW_LOCKDOWN_LIFT_BY_SYSRQ will allow a SysRq combination
to lift the lockdown.  On x86 this is SysRq+x.  The keys must be pressed on
an attached keyboard.

Enabling CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT will cause EFI secure boot to
trigger kernel lockdown.

Inside the kernel, kernel_is_locked_down() is used to check if the kernel
is in lockdown mode.

Note that the secure boot mode entry doesn't work if the kernel is booted
from older versions of i386/x86_64 Grub as there's a bug in Grub whereby it
doesn't initialise the boot_params correctly.  The incorrect initialisation
causes sanitize_boot_params() to be triggered, thereby zapping the secure
boot flag determined by the EFI boot wrapper.

A manual page, kernel_lockdown.7, is proposed, to which people will be
directed by messages in dmesg.  This lists the features that are restricted
amongst other things.

I'm aware there may be things that aren't yet handled, but we can add those
later.

====================
PROPOSED MANUAL PAGE
====================

.\"
.\" Copyright (C) 2017 Red Hat, Inc. All Rights Reserved.
.\" Written by David Howells (dhowells@redhat.com)
.\"
.\" % % %LICENSE_START(GPLv2+_SW_ONEPARA)
.\" This program is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License
.\" as published by the Free Software Foundation; either version
.\" 2 of the License, or (at your option) any later version.
.\" % % %LICENSE_END
.\"
.TH "KERNEL LOCKDOWN" 7 2017-10-05 Linux "Linux Programmer's Manual"
.SH NAME
Kernel Lockdown \- Kernel image access prevention feature
.SH DESCRIPTION
The Kernel Lockdown feature is designed to prevent both direct and indirect
access to a running kernel image, attempting to protect against unauthorised
modification of the kernel image and to prevent access to security and
cryptographic data located in kernel memory, whilst still permitting driver
modules to be loaded.
.P
Lockdown is typically enabled during boot and may be terminated, if configured,
by typing a special key combination on a directly attached physical keyboard.
.P
If a prohibited or restricted feature is accessed or used, the kernel will emit
a message that looks like:
.P
.RS
	Lockdown: X is restricted, see man kernel_lockdown.7
.RE
.P
where X indicates what is restricted.
.P
On an EFI-enabled x86 or arm64 machine, lockdown will be automatically enabled
if the system boots in EFI Secure Boot mode.
.P
If the kernel is appropriately configured, lockdown may be lifted by typing the
appropriate sequence on a directly attached physical keyboard.  For x86
machines, this is
.IR SysRq+x .
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.SH COVERAGE
When lockdown is in effect, a number of things are disabled or restricted in
use.  This includes special device files and kernel services that allow direct
access of the kernel image:
.P
.RS
/dev/mem
.br
/dev/kmem
.br
/dev/kcore
.br
/dev/ioports
.br
BPF memory access functions
.RE
.P
and the ability to directly configure and control devices, so as to prevent the
use of a device to access or modify a kernel image:
.P
.RS
The use of module parameters that directly specify hardware parameters to
drivers through the kernel command line or when loading a module.
.P
The use of direct PCI BAR access.
.P
The use of the ioperm and iopl instructions on x86.
.P
The use of the KD*IO console ioctls.
.P
The use of the TIOCSSERIAL serial ioctl.
.P
The alteration of MSR registers on x86.
.P
The replacement of the PCMCIA CIS.
.P
The overriding of ACPI tables.
.P
The use of ACPI error injection.
.P
The specification of the ACPI RDSP address.
.P
The use of ACPI custom 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 as this allows a whole range of actions
including direct configuration of, access to and driving of hardware.
.RE
.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.SH SEE ALSO
.ad l
.nh


The patches can be found here also:

	http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=efi-lock-down

Tagged thusly:

	git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git
	lockdown-20171019

David
---
Chun-Yi Lee (2):
      kexec_file: Disable at runtime if securelevel has been set
      bpf: Restrict kernel image access functions when the kernel is locked down

Dave Young (1):
      Copy secure_boot flag in boot params across kexec reboot

David Howells (11):
      Add the ability to lock down access to the running kernel image
      Enforce module signatures if the kernel is locked down
      scsi: Lock down the eata driver
      Prohibit PCMCIA CIS storage when the kernel is locked down
      Lock down TIOCSSERIAL
      Lock down module params that specify hardware parameters (eg. ioport)
      x86/mmiotrace: Lock down the testmmiotrace module
      debugfs: Disallow use of debugfs files when the kernel is locked down
      Lock down /proc/kcore
      efi: Add an EFI_SECURE_BOOT flag to indicate secure boot mode
      efi: Lock down the kernel if booted in secure boot mode

Josh Boyer (2):
      hibernate: Disable when the kernel is locked down
      acpi: Ignore acpi_rsdp kernel param when the kernel has been locked down

Kyle McMartin (1):
      Add a SysRq option to lift kernel lockdown

Linn Crosetto (2):
      acpi: Disable ACPI table override if the kernel is locked down
      acpi: Disable APEI error injection if the kernel is locked down

Matthew Garrett (8):
      Restrict /dev/mem and /dev/kmem when the kernel is locked down
      kexec: Disable at runtime if the kernel is locked down
      uswsusp: Disable when the kernel is locked down
      PCI: Lock down BAR access when the kernel is locked down
      x86: Lock down IO port access when the kernel is locked down
      x86/msr: Restrict MSR access when the kernel is locked down
      asus-wmi: Restrict debugfs interface when the kernel is locked down
      ACPI: Limit access to custom_method when the kernel is locked down


 arch/x86/include/asm/setup.h      |    2 +
 arch/x86/kernel/ioport.c          |    6 +-
 arch/x86/kernel/kexec-bzimage64.c |    1 
 arch/x86/kernel/msr.c             |    7 ++
 arch/x86/kernel/setup.c           |   18 +-----
 arch/x86/mm/testmmiotrace.c       |    3 +
 drivers/acpi/apei/einj.c          |    3 +
 drivers/acpi/custom_method.c      |    3 +
 drivers/acpi/osl.c                |    2 -
 drivers/acpi/tables.c             |    5 ++
 drivers/char/mem.c                |    8 +++
 drivers/firmware/efi/Makefile     |    1 
 drivers/firmware/efi/secureboot.c |   37 +++++++++++++
 drivers/input/misc/uinput.c       |    1 
 drivers/pci/pci-sysfs.c           |    9 +++
 drivers/pci/proc.c                |    9 +++
 drivers/pci/syscall.c             |    3 +
 drivers/pcmcia/cistpl.c           |    3 +
 drivers/platform/x86/asus-wmi.c   |    9 +++
 drivers/scsi/eata.c               |    5 +-
 drivers/tty/serial/serial_core.c  |    6 ++
 drivers/tty/sysrq.c               |   19 ++++--
 fs/debugfs/file.c                 |    6 ++
 fs/proc/kcore.c                   |    2 +
 include/linux/efi.h               |   16 +++--
 include/linux/input.h             |    5 ++
 include/linux/kernel.h            |   17 ++++++
 include/linux/security.h          |    8 +++
 include/linux/sysrq.h             |    8 ++-
 kernel/debug/kdb/kdb_main.c       |    2 -
 kernel/kexec.c                    |    7 ++
 kernel/kexec_file.c               |    7 ++
 kernel/module.c                   |    3 +
 kernel/params.c                   |   26 +++++++--
 kernel/power/hibernate.c          |    2 -
 kernel/power/user.c               |    3 +
 kernel/trace/bpf_trace.c          |   11 ++++
 security/Kconfig                  |   37 +++++++++++++
 security/Makefile                 |    3 +
 security/lock_down.c              |  109 +++++++++++++++++++++++++++++++++++++
 40 files changed, 391 insertions(+), 41 deletions(-)
 create mode 100644 drivers/firmware/efi/secureboot.c
 create mode 100644 security/lock_down.c

^ permalink raw reply	[flat|nested] 53+ messages in thread

end of thread, back to index

Thread overview: 53+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-25 22:09 [PULL REQUEST] Lockdown patches for 5.2 Matthew Garrett
2019-03-25 22:09 ` [PATCH 01/27] Add the ability to lock down access to the running kernel image Matthew Garrett
2019-03-26  5:30   ` Matthew Garrett
2019-03-25 22:09 ` [PATCH 02/27] Enforce module signatures if the kernel is locked down Matthew Garrett
2019-03-25 22:09 ` [PATCH 03/27] Restrict /dev/{mem,kmem,port} when " Matthew Garrett
2019-03-25 22:09 ` [PATCH 04/27] kexec_load: Disable at runtime if " Matthew Garrett
2019-03-25 22:09 ` [PATCH 05/27] Copy secure_boot flag in boot params across kexec reboot Matthew Garrett
2019-03-25 22:09 ` [PATCH 06/27] kexec_file: split KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE Matthew Garrett
2019-03-25 22:09 ` [PATCH 07/27] kexec_file: Restrict at runtime if the kernel is locked down Matthew Garrett
2019-03-25 22:09 ` [PATCH 08/27] hibernate: Disable when " Matthew Garrett
2019-03-25 22:09 ` [PATCH 09/27] uswsusp: " Matthew Garrett
2019-03-25 22:09 ` [PATCH 10/27] PCI: Lock down BAR access " Matthew Garrett
2019-03-25 22:09 ` [PATCH 11/27] x86: Lock down IO port " Matthew Garrett
2019-03-25 22:09 ` [PATCH 12/27] x86/msr: Restrict MSR " Matthew Garrett
2019-03-25 23:40   ` Thomas Gleixner
2019-03-25 22:09 ` [PATCH 13/27] ACPI: Limit access to custom_method " Matthew Garrett
2019-03-25 22:09 ` [PATCH 14/27] acpi: Ignore acpi_rsdp kernel param when the kernel has been " Matthew Garrett
2019-03-25 22:09 ` [PATCH 15/27] acpi: Disable ACPI table override if the kernel is " Matthew Garrett
2019-03-25 22:09 ` [PATCH 16/27] acpi: Disable APEI error injection " Matthew Garrett
2019-03-25 22:09 ` [PATCH 17/27] Prohibit PCMCIA CIS storage when " Matthew Garrett
2019-03-25 22:09 ` [PATCH 18/27] Lock down TIOCSSERIAL Matthew Garrett
2019-03-25 22:09 ` [PATCH 19/27] Lock down module params that specify hardware parameters (eg. ioport) Matthew Garrett
2019-03-25 22:09 ` [PATCH 20/27] x86/mmiotrace: Lock down the testmmiotrace module Matthew Garrett
2019-03-25 23:35   ` Steven Rostedt
2019-03-25 22:09 ` [PATCH 21/27] Lock down /proc/kcore Matthew Garrett
2019-03-25 22:09 ` [PATCH 22/27] Lock down kprobes Matthew Garrett
2019-03-26 12:29   ` Masami Hiramatsu
2019-03-26 17:41     ` Matthew Garrett
2019-03-26 22:47       ` Masami Hiramatsu
2019-03-25 22:09 ` [PATCH 23/27] bpf: Restrict kernel image access functions when the kernel is locked down Matthew Garrett
2019-03-25 23:42   ` Stephen Hemminger
2019-03-25 23:59     ` Stephen Hemminger
2019-03-26  0:00     ` Daniel Borkmann
2019-03-26 13:54       ` Jordan Glover
2019-03-26  0:10     ` Andy Lutomirski
2019-03-26 18:57       ` James Morris
2019-03-26 19:22         ` Andy Lutomirski
2019-03-28  3:15           ` James Morris
2019-03-28 18:07             ` Matthew Garrett
2019-03-28 19:23               ` James Morris
2019-03-28 20:08                 ` Matthew Garrett
2019-03-26 20:19         ` Matthew Garrett
2019-03-25 22:09 ` [PATCH 24/27] Lock down perf Matthew Garrett
2019-03-25 22:09 ` [PATCH 25/27] debugfs: Restrict debugfs when the kernel is locked down Matthew Garrett
2019-03-26  0:31   ` Greg Kroah-Hartman
2019-03-26  0:38     ` Matthew Garrett
2019-03-26  0:43       ` Greg Kroah-Hartman
2019-03-25 22:09 ` [PATCH 26/27] lockdown: Print current->comm in restriction messages Matthew Garrett
2019-03-25 22:09 ` [PATCH 27/27] kexec: Allow kexec_file() with appropriate IMA policy when locked down Matthew Garrett
2019-03-26 15:33   ` Mimi Zohar
  -- strict thread matches above, loose matches on Subject: below --
2017-10-19 14:50 [PATCH 00/27] security, efi: Add kernel lockdown David Howells
2017-10-19 14:51 ` [PATCH 09/27] uswsusp: Disable when the kernel is locked down David Howells
2017-10-20  6:41   ` joeyli
2017-10-20 23:29   ` James Morris

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git
	git clone --mirror https://lore.kernel.org/lkml/10 lkml/git/10.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git