Skip to content

Commit 9c0114e

Browse files

File tree

1 file changed

+17
-31
lines changed

1 file changed

+17
-31
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
From fa96a2ef86466da0a43756ee39ce3b1cb555a55a Mon Sep 17 00:00:00 2001
21
From: Ben Hutchings <ben@decadent.org.uk>
32
Date: Tue, 10 Sep 2019 11:54:28 +0100
4-
Subject: [PATCH 2/4] efi: Lock down the kernel if booted in secure boot mode
3+
Subject: efi: Lock down the kernel if booted in secure boot mode
54

65
Based on an earlier patch by David Howells, who wrote the following
76
description:
@@ -18,18 +17,16 @@ help text for LOCK_DOWN_IN_EFI_SECURE_BOOT was adjusted to mention that
1817
lockdown is triggered in integrity mode (https://bugs.debian.org/1025417)]
1918
Signed-off-by: Salvatore Bonaccorso <carnil@debian.org>
2019
---
21-
arch/x86/kernel/setup.c | 4 ++--
22-
drivers/firmware/efi/secureboot.c | 5 +++++
23-
include/linux/security.h | 6 ++++++
24-
security/lockdown/Kconfig | 15 +++++++++++++++
25-
security/lockdown/lockdown.c | 2 +-
26-
5 files changed, 29 insertions(+), 3 deletions(-)
20+
arch/x86/kernel/setup.c | 4 ++--
21+
drivers/firmware/efi/secureboot.c | 3 +++
22+
include/linux/security.h | 6 ++++++
23+
security/lockdown/Kconfig | 15 +++++++++++++++
24+
security/lockdown/lockdown.c | 2 +-
25+
5 files changed, 27 insertions(+), 3 deletions(-)
2726

28-
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
29-
index 7c4a6697e39d..04e73973098e 100644
3027
--- a/arch/x86/kernel/setup.c
3128
+++ b/arch/x86/kernel/setup.c
32-
@@ -1028,6 +1028,8 @@ void __init setup_arch(char **cmdline_p)
29+
@@ -900,6 +900,8 @@ void __init setup_arch(char **cmdline_p)
3330
if (efi_enabled(EFI_BOOT))
3431
efi_init();
3532

@@ -38,7 +35,7 @@ index 7c4a6697e39d..04e73973098e 100644
3835
reserve_ibft_region();
3936
x86_init.resources.dmi_setup();
4037

41-
@@ -1190,8 +1192,6 @@ void __init setup_arch(char **cmdline_p)
38+
@@ -1061,8 +1063,6 @@ void __init setup_arch(char **cmdline_p)
4239
/* Allocate bigger log buffer */
4340
setup_log_buf(1);
4441

@@ -47,8 +44,6 @@ index 7c4a6697e39d..04e73973098e 100644
4744
reserve_initrd();
4845

4946
acpi_table_upgrade();
50-
diff --git a/drivers/firmware/efi/secureboot.c b/drivers/firmware/efi/secureboot.c
51-
index b6620669e32b..8f2554291fb1 100644
5247
--- a/drivers/firmware/efi/secureboot.c
5348
+++ b/drivers/firmware/efi/secureboot.c
5449
@@ -15,6 +15,7 @@
@@ -59,7 +54,7 @@ index b6620669e32b..8f2554291fb1 100644
5954

6055
/*
6156
* Decide what to do when UEFI secure boot mode is enabled.
62-
@@ -28,6 +29,10 @@ void __init efi_set_secure_boot(enum efi_secureboot_mode mode)
57+
@@ -28,6 +29,10 @@ void __init efi_set_secure_boot(enum efi
6358
break;
6459
case efi_secureboot_mode_enabled:
6560
set_bit(EFI_SECURE_BOOT, &efi.flags);
@@ -70,21 +65,19 @@ index b6620669e32b..8f2554291fb1 100644
7065
pr_info("Secure boot enabled\n");
7166
break;
7267
default:
73-
diff --git a/include/linux/security.h b/include/linux/security.h
74-
index 4bd0f6fc553e..08258ecbb5f9 100644
7568
--- a/include/linux/security.h
7669
+++ b/include/linux/security.h
77-
@@ -486,6 +486,7 @@ int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
78-
int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
79-
int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
70+
@@ -509,6 +509,7 @@ int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
8071
int security_locked_down(enum lockdown_reason what);
72+
int lsm_fill_user_ctx(struct lsm_ctx __user *uctx, u32 *uctx_len,
73+
void *val, size_t val_len, u64 id, u64 flags);
8174
+int lock_kernel_down(const char *where, enum lockdown_reason level);
8275
#else /* CONFIG_SECURITY */
8376

8477
static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data)
85-
@@ -1404,6 +1405,11 @@ static inline int security_locked_down(enum lockdown_reason what)
78+
@@ -1483,6 +1484,11 @@ static inline int lsm_fill_user_ctx(struct lsm_ctx __user *uctx,
8679
{
87-
return 0;
80+
return -EOPNOTSUPP;
8881
}
8982
+static inline int
9083
+lock_kernel_down(const char *where, enum lockdown_reason level)
@@ -94,11 +87,9 @@ index 4bd0f6fc553e..08258ecbb5f9 100644
9487
#endif /* CONFIG_SECURITY */
9588

9689
#if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
97-
diff --git a/security/lockdown/Kconfig b/security/lockdown/Kconfig
98-
index e84ddf484010..4175b50b1e6e 100644
9990
--- a/security/lockdown/Kconfig
10091
+++ b/security/lockdown/Kconfig
101-
@@ -45,3 +45,18 @@ config LOCK_DOWN_KERNEL_FORCE_CONFIDENTIALITY
92+
@@ -45,3 +45,18 @@ config LOCK_DOWN_KERNEL_FORCE_CONFIDENTI
10293
disabled.
10394

10495
endchoice
@@ -117,11 +108,9 @@ index e84ddf484010..4175b50b1e6e 100644
117108
+
118109
+ Enabling this option results in kernel lockdown being
119110
+ triggered in integrity mode if EFI Secure Boot is set.
120-
diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c
121-
index 68d19632aeb7..67cc9839952f 100644
122111
--- a/security/lockdown/lockdown.c
123112
+++ b/security/lockdown/lockdown.c
124-
@@ -23,7 +23,7 @@ static const enum lockdown_reason lockdown_levels[] = {LOCKDOWN_NONE,
113+
@@ -24,7 +24,7 @@ static const enum lockdown_reason lockdo
125114
/*
126115
* Put the kernel into lock-down mode.
127116
*/
@@ -130,6 +119,3 @@ index 68d19632aeb7..67cc9839952f 100644
130119
{
131120
if (kernel_locked_down >= level)
132121
return -EPERM;
133-
--
134-
2.39.2
135-

0 commit comments

Comments
 (0)