Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 24, 2020. It is now read-only.

Commit 42eacc6

Browse files
authored
Merge pull request #19 from crawford/v4.7-coreos
Rebase CoreOS patches onto Linux v4.7
2 parents 523d939 + 8a81012 commit 42eacc6

File tree

28 files changed

+326
-11
lines changed

28 files changed

+326
-11
lines changed

Documentation/x86/zero-page.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Offset Proto Name Meaning
3131
1E9/001 ALL eddbuf_entries Number of entries in eddbuf (below)
3232
1EA/001 ALL edd_mbr_sig_buf_entries Number of entries in edd_mbr_sig_buffer
3333
(below)
34+
1EB/001 ALL kbd_status Numlock is enabled
35+
1EC/001 ALL secure_boot Secure boot is enabled in the firmware
3436
1EF/001 ALL sentinel Used to detect broken bootloaders
3537
290/040 ALL edd_mbr_sig_buffer EDD MBR signatures
3638
2D0/A00 ALL e820_map E820 memory map table

Makefile

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

149149
sub-make:
150-
$(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \
150+
$(Q)$(MAKE) -C $(KBUILD_OUTPUT) \
151+
KBUILD_SRC=$(shell realpath --relative-to=$(KBUILD_OUTPUT) $(CURDIR)) \
151152
-f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
152153

153154
# Leave processing to above invocation of make

arch/x86/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,6 +1776,17 @@ config EFI_MIXED
17761776

17771777
If unsure, say N.
17781778

1779+
config EFI_SECURE_BOOT_SIG_ENFORCE
1780+
def_bool n
1781+
depends on EFI
1782+
prompt "Force module signing when UEFI Secure Boot is enabled"
1783+
---help---
1784+
UEFI Secure Boot provides a mechanism for ensuring that the
1785+
firmware will only load signed bootloaders and kernels. Certain
1786+
use cases may also require that all kernel modules also be signed.
1787+
Say Y here to automatically enable module signature enforcement
1788+
when a system boots with UEFI Secure Boot enabled.
1789+
17791790
config SECCOMP
17801791
def_bool y
17811792
prompt "Enable seccomp to safely compute untrusted bytecode"

arch/x86/boot/compressed/eboot.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <asm/efi.h>
1313
#include <asm/setup.h>
1414
#include <asm/desc.h>
15+
#include <asm/bootparam_utils.h>
1516

1617
#include "../string.h"
1718
#include "eboot.h"
@@ -571,6 +572,36 @@ static void setup_efi_pci(struct boot_params *params)
571572
efi_call_early(free_pool, pci_handle);
572573
}
573574

575+
static int get_secure_boot(void)
576+
{
577+
u8 sb, setup;
578+
unsigned long datasize = sizeof(sb);
579+
efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID;
580+
efi_status_t status;
581+
582+
status = efi_early->call((unsigned long)sys_table->runtime->get_variable,
583+
L"SecureBoot", &var_guid, NULL, &datasize, &sb);
584+
585+
if (status != EFI_SUCCESS)
586+
return 0;
587+
588+
if (sb == 0)
589+
return 0;
590+
591+
592+
status = efi_early->call((unsigned long)sys_table->runtime->get_variable,
593+
L"SetupMode", &var_guid, NULL, &datasize,
594+
&setup);
595+
596+
if (status != EFI_SUCCESS)
597+
return 0;
598+
599+
if (setup == 1)
600+
return 0;
601+
602+
return 1;
603+
}
604+
574605
static efi_status_t
575606
setup_uga32(void **uga_handle, unsigned long size, u32 *width, u32 *height)
576607
{
@@ -1126,6 +1157,10 @@ struct boot_params *efi_main(struct efi_config *c,
11261157
else
11271158
setup_boot_services32(efi_early);
11281159

1160+
sanitize_boot_params(boot_params);
1161+
1162+
boot_params->secure_boot = get_secure_boot();
1163+
11291164
setup_graphics(boot_params);
11301165

11311166
setup_efi_pci(boot_params);

arch/x86/include/uapi/asm/bootparam.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ struct boot_params {
134134
__u8 eddbuf_entries; /* 0x1e9 */
135135
__u8 edd_mbr_sig_buf_entries; /* 0x1ea */
136136
__u8 kbd_status; /* 0x1eb */
137-
__u8 _pad5[3]; /* 0x1ec */
137+
__u8 secure_boot; /* 0x1ec */
138+
__u8 _pad5[2]; /* 0x1ed */
138139
/*
139140
* The sentinel is set to a nonzero value (0xff) in header.S.
140141
*

arch/x86/kernel/ioport.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/thread_info.h>
1616
#include <linux/syscalls.h>
1717
#include <linux/bitmap.h>
18+
#include <linux/module.h>
1819
#include <asm/syscalls.h>
1920

2021
/*
@@ -28,7 +29,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
2829

2930
if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
3031
return -EINVAL;
31-
if (turn_on && !capable(CAP_SYS_RAWIO))
32+
if (turn_on && (!capable(CAP_SYS_RAWIO) || secure_modules()))
3233
return -EPERM;
3334

3435
/*
@@ -108,7 +109,7 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
108109
return -EINVAL;
109110
/* Trying to gain more privileges? */
110111
if (level > old) {
111-
if (!capable(CAP_SYS_RAWIO))
112+
if (!capable(CAP_SYS_RAWIO) || secure_modules())
112113
return -EPERM;
113114
}
114115
regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) |

arch/x86/kernel/msr.c

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

86+
if (secure_modules())
87+
return -EPERM;
88+
8689
if (count % 8)
8790
return -EINVAL; /* Invalid chunk size */
8891

@@ -130,6 +133,10 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)
130133
err = -EBADF;
131134
break;
132135
}
136+
if (secure_modules()) {
137+
err = -EPERM;
138+
break;
139+
}
133140
if (copy_from_user(&regs, uregs, sizeof regs)) {
134141
err = -EFAULT;
135142
break;

arch/x86/kernel/setup.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,14 @@ void __init setup_arch(char **cmdline_p)
11521152

11531153
io_delay_init();
11541154

1155+
#ifdef CONFIG_EFI_SECURE_BOOT_SIG_ENFORCE
1156+
if (boot_params.secure_boot) {
1157+
set_bit(EFI_SECURE_BOOT, &efi.flags);
1158+
enforce_signed_modules();
1159+
pr_info("Secure boot enabled\n");
1160+
}
1161+
#endif
1162+
11551163
/*
11561164
* Parse the ACPI tables for possible boot-time SMP configuration.
11571165
*/

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 (secure_modules())
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <linux/list.h>
4141
#include <linux/jiffies.h>
4242
#include <linux/semaphore.h>
43+
#include <linux/module.h>
4344

4445
#include <asm/io.h>
4546
#include <asm/uaccess.h>
@@ -184,7 +185,7 @@ early_param("acpi_rsdp", setup_acpi_rsdp);
184185
acpi_physical_address __init acpi_os_get_root_pointer(void)
185186
{
186187
#ifdef CONFIG_KEXEC
187-
if (acpi_rsdp)
188+
if (acpi_rsdp && !secure_modules())
188189
return acpi_rsdp;
189190
#endif
190191

0 commit comments

Comments
 (0)