Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit cb161c5

Browse files
authored
Merge pull request torvalds#112 from coreosbot/v4.13.16-coreos
Rebase patches onto 4.13.16
2 parents e87c139 + f15db8d commit cb161c5

File tree

31 files changed

+208
-10
lines changed

31 files changed

+208
-10
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
142142

143143
# Invoke a second make in the output directory, passing relevant variables
144144
sub-make:
145-
$(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \
145+
$(Q)$(MAKE) -C $(KBUILD_OUTPUT) \
146+
KBUILD_SRC=$(shell realpath --relative-to=$(KBUILD_OUTPUT) $(CURDIR)) \
146147
-f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
147148

148149
# Leave processing to above invocation of make

arch/arm64/kernel/efi-header.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ section_table:
103103

104104
.set section_count, (. - section_table) / 40
105105

106+
/* CoreOS 64 byte verity hash value. */
107+
.org _head + 512
108+
.ascii "verity-hash"
109+
.org _head + 512 + 64
110+
106111
#ifdef CONFIG_DEBUG_EFI
107112
/*
108113
* The debug table is referenced via its Relative Virtual Address (RVA),

arch/x86/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,6 +1836,18 @@ config EFI_MIXED
18361836

18371837
If unsure, say N.
18381838

1839+
config EFI_SECURE_BOOT_LOCK_DOWN
1840+
def_bool n
1841+
depends on EFI
1842+
prompt "Lock down the kernel when UEFI Secure Boot is enabled"
1843+
---help---
1844+
UEFI Secure Boot provides a mechanism for ensuring that the firmware
1845+
will only load signed bootloaders and kernels. Certain use cases may
1846+
also require that all kernel modules also be signed and that
1847+
userspace is prevented from directly changing the running kernel
1848+
image. Say Y here to automatically lock down the kernel when a
1849+
system boots with UEFI Secure Boot enabled.
1850+
18391851
config SECCOMP
18401852
def_bool y
18411853
prompt "Enable seccomp to safely compute untrusted bytecode"

arch/x86/kernel/ioport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
3030

3131
if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
3232
return -EINVAL;
33-
if (turn_on && !capable(CAP_SYS_RAWIO))
33+
if (turn_on && (!capable(CAP_SYS_RAWIO) || kernel_is_locked_down()))
3434
return -EPERM;
3535

3636
/*
@@ -120,7 +120,7 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
120120
return -EINVAL;
121121
/* Trying to gain more privileges? */
122122
if (level > old) {
123-
if (!capable(CAP_SYS_RAWIO))
123+
if (!capable(CAP_SYS_RAWIO) || kernel_is_locked_down())
124124
return -EPERM;
125125
}
126126
regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) |

arch/x86/kernel/kexec-bzimage64.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ setup_efi_state(struct boot_params *params, unsigned long params_load_addr,
179179
if (efi_enabled(EFI_OLD_MEMMAP))
180180
return 0;
181181

182+
params->secure_boot = boot_params.secure_boot;
182183
ei->efi_loader_signature = current_ei->efi_loader_signature;
183184
ei->efi_systab = current_ei->efi_systab;
184185
ei->efi_systab_hi = current_ei->efi_systab_hi;

arch/x86/kernel/msr.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
8484
int err = 0;
8585
ssize_t bytes = 0;
8686

87+
if (kernel_is_locked_down())
88+
return -EPERM;
89+
8790
if (count % 8)
8891
return -EINVAL; /* Invalid chunk size */
8992

@@ -131,6 +134,10 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)
131134
err = -EBADF;
132135
break;
133136
}
137+
if (kernel_is_locked_down()) {
138+
err = -EPERM;
139+
break;
140+
}
134141
if (copy_from_user(&regs, uregs, sizeof regs)) {
135142
err = -EFAULT;
136143
break;

arch/x86/kernel/setup.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include <linux/crash_dump.h>
7070
#include <linux/tboot.h>
7171
#include <linux/jiffies.h>
72+
#include <linux/security.h>
7273

7374
#include <linux/usb/xhci-dbgp.h>
7475
#include <video/edid.h>
@@ -1190,7 +1191,13 @@ void __init setup_arch(char **cmdline_p)
11901191
pr_info("Secure boot disabled\n");
11911192
break;
11921193
case efi_secureboot_mode_enabled:
1193-
pr_info("Secure boot enabled\n");
1194+
set_bit(EFI_SECURE_BOOT, &efi.flags);
1195+
if (IS_ENABLED(CONFIG_EFI_SECURE_BOOT_LOCK_DOWN)) {
1196+
lock_kernel_down();
1197+
pr_info("Secure boot enabled and kernel locked down\n");
1198+
} else {
1199+
pr_info("Secure boot enabled\n");
1200+
}
11941201
break;
11951202
default:
11961203
pr_info("Secure boot could not be determined\n");

drivers/acpi/apei/einj.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,9 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
518518
int rc;
519519
u64 base_addr, size;
520520

521+
if (kernel_is_locked_down())
522+
return -EPERM;
523+
521524
/* If user manually set "flags", make sure it is legal */
522525
if (flags && (flags &
523526
~(SETWA_FLAGS_APICID|SETWA_FLAGS_MEM|SETWA_FLAGS_PCIE_SBDF)))

drivers/acpi/custom_method.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
2929
struct acpi_table_header table;
3030
acpi_status status;
3131

32+
if (kernel_is_locked_down())
33+
return -EPERM;
34+
3235
if (!(*ppos)) {
3336
/* parse the table header to get the table length */
3437
if (count <= sizeof(struct acpi_table_header))

drivers/acpi/osl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
192192
acpi_physical_address pa = 0;
193193

194194
#ifdef CONFIG_KEXEC
195-
if (acpi_rsdp)
195+
if (acpi_rsdp && !kernel_is_locked_down())
196196
return acpi_rsdp;
197197
#endif
198198

0 commit comments

Comments
 (0)