Skip to content

Commit aefcf2f

Browse files
committed
Merge branch 'next-lockdown' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull kernel lockdown mode from James Morris: "This is the latest iteration of the kernel lockdown patchset, from Matthew Garrett, David Howells and others. From the original description: This patchset introduces an optional kernel lockdown feature, intended to strengthen the boundary between UID 0 and the kernel. When enabled, various pieces of kernel functionality are restricted. Applications that rely on low-level access to either hardware or the kernel may cease working as a result - therefore this should not be enabled without appropriate evaluation beforehand. The majority of mainstream distributions have been carrying variants of this patchset for many years now, so there's value in providing a doesn't meet every distribution requirement, but gets us much closer to not requiring external patches. There are two major changes since this was last proposed for mainline: - Separating lockdown from EFI secure boot. Background discussion is covered here: https://lwn.net/Articles/751061/ - Implementation as an LSM, with a default stackable lockdown LSM module. This allows the lockdown feature to be policy-driven, rather than encoding an implicit policy within the mechanism. The new locked_down LSM hook is provided to allow LSMs to make a policy decision around whether kernel functionality that would allow tampering with or examining the runtime state of the kernel should be permitted. The included lockdown LSM provides an implementation with a simple policy intended for general purpose use. This policy provides a coarse level of granularity, controllable via the kernel command line: lockdown={integrity|confidentiality} Enable the kernel lockdown feature. If set to integrity, kernel features that allow userland to modify the running kernel are disabled. If set to confidentiality, kernel features that allow userland to extract confidential information from the kernel are also disabled. This may also be controlled via /sys/kernel/security/lockdown and overriden by kernel configuration. New or existing LSMs may implement finer-grained controls of the lockdown features. Refer to the lockdown_reason documentation in include/linux/security.h for details. The lockdown feature has had signficant design feedback and review across many subsystems. This code has been in linux-next for some weeks, with a few fixes applied along the way. Stephen Rothwell noted that commit 9d1f8be ("bpf: Restrict bpf when kernel lockdown is in confidentiality mode") is missing a Signed-off-by from its author. Matthew responded that he is providing this under category (c) of the DCO" * 'next-lockdown' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (31 commits) kexec: Fix file verification on S390 security: constify some arrays in lockdown LSM lockdown: Print current->comm in restriction messages efi: Restrict efivar_ssdt_load when the kernel is locked down tracefs: Restrict tracefs when the kernel is locked down debugfs: Restrict debugfs when the kernel is locked down kexec: Allow kexec_file() with appropriate IMA policy when locked down lockdown: Lock down perf when in confidentiality mode bpf: Restrict bpf when kernel lockdown is in confidentiality mode lockdown: Lock down tracing and perf kprobes when in confidentiality mode lockdown: Lock down /proc/kcore x86/mmiotrace: Lock down the testmmiotrace module lockdown: Lock down module params that specify hardware parameters (eg. ioport) lockdown: Lock down TIOCSSERIAL lockdown: Prohibit PCMCIA CIS storage when the kernel is locked down acpi: Disable ACPI table override if the kernel is locked down acpi: Ignore acpi_rsdp kernel param when the kernel has been locked down ACPI: Limit access to custom_method when the kernel is locked down x86/msr: Restrict MSR access when the kernel is locked down x86: Lock down IO port access when the kernel is locked down ...
2 parents f1f2f61 + 45893a0 commit aefcf2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+861
-76
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,15 @@
22762276
lockd.nlm_udpport=M [NFS] Assign UDP port.
22772277
Format: <integer>
22782278

2279+
lockdown= [SECURITY]
2280+
{ integrity | confidentiality }
2281+
Enable the kernel lockdown feature. If set to
2282+
integrity, kernel features that allow userland to
2283+
modify the running kernel are disabled. If set to
2284+
confidentiality, kernel features that allow userland
2285+
to extract confidential information from the kernel
2286+
are also disabled.
2287+
22792288
locktorture.nreaders_stress= [KNL]
22802289
Set the number of locking read-acquisition kthreads.
22812290
Defaults to being automatically set based on the

arch/arm64/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ config KEXEC_FILE
982982
for kernel and initramfs as opposed to list of segments as
983983
accepted by previous system call.
984984

985-
config KEXEC_VERIFY_SIG
985+
config KEXEC_SIG
986986
bool "Verify kernel signature during kexec_file_load() syscall"
987987
depends on KEXEC_FILE
988988
help
@@ -997,13 +997,13 @@ config KEXEC_VERIFY_SIG
997997
config KEXEC_IMAGE_VERIFY_SIG
998998
bool "Enable Image signature verification support"
999999
default y
1000-
depends on KEXEC_VERIFY_SIG
1000+
depends on KEXEC_SIG
10011001
depends on EFI && SIGNED_PE_FILE_VERIFICATION
10021002
help
10031003
Enable Image signature verification support.
10041004

10051005
comment "Support for PE file signature verification disabled"
1006-
depends on KEXEC_VERIFY_SIG
1006+
depends on KEXEC_SIG
10071007
depends on !EFI || !SIGNED_PE_FILE_VERIFICATION
10081008

10091009
config CRASH_DUMP

arch/s390/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ config ARCH_HAS_KEXEC_PURGATORY
554554
def_bool y
555555
depends on KEXEC_FILE
556556

557-
config KEXEC_VERIFY_SIG
557+
config KEXEC_SIG
558558
bool "Verify kernel signature during kexec_file_load() syscall"
559559
depends on KEXEC_FILE && MODULE_SIG_FORMAT
560560
help

arch/s390/kernel/kexec_elf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static int s390_elf_probe(const char *buf, unsigned long len)
130130
const struct kexec_file_ops s390_kexec_elf_ops = {
131131
.probe = s390_elf_probe,
132132
.load = s390_elf_load,
133-
#ifdef CONFIG_KEXEC_VERIFY_SIG
133+
#ifdef CONFIG_KEXEC_SIG
134134
.verify_sig = s390_verify_sig,
135-
#endif /* CONFIG_KEXEC_VERIFY_SIG */
135+
#endif /* CONFIG_KEXEC_SIG */
136136
};

arch/s390/kernel/kexec_image.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static int s390_image_probe(const char *buf, unsigned long len)
5959
const struct kexec_file_ops s390_kexec_image_ops = {
6060
.probe = s390_image_probe,
6161
.load = s390_image_load,
62-
#ifdef CONFIG_KEXEC_VERIFY_SIG
62+
#ifdef CONFIG_KEXEC_SIG
6363
.verify_sig = s390_verify_sig,
64-
#endif /* CONFIG_KEXEC_VERIFY_SIG */
64+
#endif /* CONFIG_KEXEC_SIG */
6565
};

arch/s390/kernel/machine_kexec_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const struct kexec_file_ops * const kexec_file_loaders[] = {
2222
NULL,
2323
};
2424

25-
#ifdef CONFIG_KEXEC_VERIFY_SIG
25+
#ifdef CONFIG_KEXEC_SIG
2626
int s390_verify_sig(const char *kernel, unsigned long kernel_len)
2727
{
2828
const unsigned long marker_len = sizeof(MODULE_SIG_STRING) - 1;
@@ -68,7 +68,7 @@ int s390_verify_sig(const char *kernel, unsigned long kernel_len)
6868
VERIFYING_MODULE_SIGNATURE,
6969
NULL, NULL);
7070
}
71-
#endif /* CONFIG_KEXEC_VERIFY_SIG */
71+
#endif /* CONFIG_KEXEC_SIG */
7272

7373
static int kexec_file_update_purgatory(struct kimage *image,
7474
struct s390_load_data *data)

arch/x86/Kconfig

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,20 +2031,30 @@ config KEXEC_FILE
20312031
config ARCH_HAS_KEXEC_PURGATORY
20322032
def_bool KEXEC_FILE
20332033

2034-
config KEXEC_VERIFY_SIG
2034+
config KEXEC_SIG
20352035
bool "Verify kernel signature during kexec_file_load() syscall"
20362036
depends on KEXEC_FILE
20372037
---help---
2038-
This option makes kernel signature verification mandatory for
2039-
the kexec_file_load() syscall.
20402038

2041-
In addition to that option, you need to enable signature
2039+
This option makes the kexec_file_load() syscall check for a valid
2040+
signature of the kernel image. The image can still be loaded without
2041+
a valid signature unless you also enable KEXEC_SIG_FORCE, though if
2042+
there's a signature that we can check, then it must be valid.
2043+
2044+
In addition to this option, you need to enable signature
20422045
verification for the corresponding kernel image type being
20432046
loaded in order for this to work.
20442047

2048+
config KEXEC_SIG_FORCE
2049+
bool "Require a valid signature in kexec_file_load() syscall"
2050+
depends on KEXEC_SIG
2051+
---help---
2052+
This option makes kernel signature verification mandatory for
2053+
the kexec_file_load() syscall.
2054+
20452055
config KEXEC_BZIMAGE_VERIFY_SIG
20462056
bool "Enable bzImage signature verification support"
2047-
depends on KEXEC_VERIFY_SIG
2057+
depends on KEXEC_SIG
20482058
depends on SIGNED_PE_FILE_VERIFICATION
20492059
select SYSTEM_TRUSTED_KEYRING
20502060
---help---

arch/x86/boot/compressed/acpi.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct mem_vector immovable_mem[MAX_NUMNODES*2];
2626
*/
2727
#define MAX_ADDR_LEN 19
2828

29-
static acpi_physical_address get_acpi_rsdp(void)
29+
static acpi_physical_address get_cmdline_acpi_rsdp(void)
3030
{
3131
acpi_physical_address addr = 0;
3232

@@ -278,10 +278,7 @@ acpi_physical_address get_rsdp_addr(void)
278278
{
279279
acpi_physical_address pa;
280280

281-
pa = get_acpi_rsdp();
282-
283-
if (!pa)
284-
pa = boot_params->acpi_rsdp_addr;
281+
pa = boot_params->acpi_rsdp_addr;
285282

286283
/*
287284
* Try to get EFI data from setup_data. This can happen when we're a
@@ -311,7 +308,17 @@ static unsigned long get_acpi_srat_table(void)
311308
char arg[10];
312309
u8 *entry;
313310

314-
rsdp = (struct acpi_table_rsdp *)(long)boot_params->acpi_rsdp_addr;
311+
/*
312+
* Check whether we were given an RSDP on the command line. We don't
313+
* stash this in boot params because the kernel itself may have
314+
* different ideas about whether to trust a command-line parameter.
315+
*/
316+
rsdp = (struct acpi_table_rsdp *)get_cmdline_acpi_rsdp();
317+
318+
if (!rsdp)
319+
rsdp = (struct acpi_table_rsdp *)(long)
320+
boot_params->acpi_rsdp_addr;
321+
315322
if (!rsdp)
316323
return 0;
317324

arch/x86/include/asm/acpi.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ static inline bool acpi_has_cpu_in_madt(void)
117117
return !!acpi_lapic;
118118
}
119119

120+
#define ACPI_HAVE_ARCH_SET_ROOT_POINTER
121+
static inline void acpi_arch_set_root_pointer(u64 addr)
122+
{
123+
x86_init.acpi.set_root_pointer(addr);
124+
}
125+
120126
#define ACPI_HAVE_ARCH_GET_ROOT_POINTER
121127
static inline u64 acpi_arch_get_root_pointer(void)
122128
{
@@ -125,6 +131,7 @@ static inline u64 acpi_arch_get_root_pointer(void)
125131

126132
void acpi_generic_reduced_hw_init(void);
127133

134+
void x86_default_set_root_pointer(u64 addr);
128135
u64 x86_default_get_root_pointer(void);
129136

130137
#else /* !CONFIG_ACPI */
@@ -138,6 +145,8 @@ static inline void disable_acpi(void) { }
138145

139146
static inline void acpi_generic_reduced_hw_init(void) { }
140147

148+
static inline void x86_default_set_root_pointer(u64 addr) { }
149+
141150
static inline u64 x86_default_get_root_pointer(void)
142151
{
143152
return 0;

arch/x86/include/asm/x86_init.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ struct x86_hyper_init {
134134

135135
/**
136136
* struct x86_init_acpi - x86 ACPI init functions
137+
* @set_root_poitner: set RSDP address
137138
* @get_root_pointer: get RSDP address
138139
* @reduced_hw_early_init: hardware reduced platform early init
139140
*/
140141
struct x86_init_acpi {
142+
void (*set_root_pointer)(u64 addr);
141143
u64 (*get_root_pointer)(void);
142144
void (*reduced_hw_early_init)(void);
143145
};

0 commit comments

Comments
 (0)