1
- From fa96a2ef86466da0a43756ee39ce3b1cb555a55a Mon Sep 17 00:00:00 2001
2
1
From: Ben Hutchings <ben@decadent.org.uk>
3
2
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
5
4
6
5
Based on an earlier patch by David Howells, who wrote the following
7
6
description:
@@ -18,18 +17,16 @@ help text for LOCK_DOWN_IN_EFI_SECURE_BOOT was adjusted to mention that
18
17
lockdown is triggered in integrity mode (https://bugs.debian.org/1025417)]
19
18
Signed-off-by: Salvatore Bonaccorso <carnil@debian.org>
20
19
---
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(-)
27
26
28
- diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
29
- index 7c4a6697e39d..04e73973098e 100644
30
27
--- a/arch/x86/kernel/setup.c
31
28
+++ 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)
33
30
if (efi_enabled(EFI_BOOT))
34
31
efi_init();
35
32
@@ -38,7 +35,7 @@ index 7c4a6697e39d..04e73973098e 100644
38
35
reserve_ibft_region();
39
36
x86_init.resources.dmi_setup();
40
37
41
- @@ -1190 ,8 +1192 ,6 @@ void __init setup_arch(char **cmdline_p)
38
+ @@ -1061 ,8 +1063 ,6 @@ void __init setup_arch(char **cmdline_p)
42
39
/* Allocate bigger log buffer */
43
40
setup_log_buf(1);
44
41
@@ -47,8 +44,6 @@ index 7c4a6697e39d..04e73973098e 100644
47
44
reserve_initrd();
48
45
49
46
acpi_table_upgrade();
50
- diff --git a/drivers/firmware/efi/secureboot.c b/drivers/firmware/efi/secureboot.c
51
- index b6620669e32b..8f2554291fb1 100644
52
47
--- a/drivers/firmware/efi/secureboot.c
53
48
+++ b/drivers/firmware/efi/secureboot.c
54
49
@@ -15,6 +15,7 @@
@@ -59,7 +54,7 @@ index b6620669e32b..8f2554291fb1 100644
59
54
60
55
/*
61
56
* 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
63
58
break;
64
59
case efi_secureboot_mode_enabled:
65
60
set_bit(EFI_SECURE_BOOT, &efi.flags);
@@ -70,21 +65,19 @@ index b6620669e32b..8f2554291fb1 100644
70
65
pr_info("Secure boot enabled\n");
71
66
break;
72
67
default:
73
- diff --git a/include/linux/security.h b/include/linux/security.h
74
- index 4bd0f6fc553e..08258ecbb5f9 100644
75
68
--- a/include/linux/security.h
76
69
+++ 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);
80
71
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);
81
74
+ int lock_kernel_down(const char *where, enum lockdown_reason level);
82
75
#else /* CONFIG_SECURITY */
83
76
84
77
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,
86
79
{
87
- return 0 ;
80
+ return -EOPNOTSUPP ;
88
81
}
89
82
+ static inline int
90
83
+ lock_kernel_down(const char *where, enum lockdown_reason level)
@@ -94,11 +87,9 @@ index 4bd0f6fc553e..08258ecbb5f9 100644
94
87
#endif /* CONFIG_SECURITY */
95
88
96
89
#if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
97
- diff --git a/security/lockdown/Kconfig b/security/lockdown/Kconfig
98
- index e84ddf484010..4175b50b1e6e 100644
99
90
--- a/security/lockdown/Kconfig
100
91
+++ 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
102
93
disabled.
103
94
104
95
endchoice
@@ -117,11 +108,9 @@ index e84ddf484010..4175b50b1e6e 100644
117
108
+
118
109
+ Enabling this option results in kernel lockdown being
119
110
+ 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
122
111
--- a/security/lockdown/lockdown.c
123
112
+++ 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
125
114
/*
126
115
* Put the kernel into lock-down mode.
127
116
*/
@@ -130,6 +119,3 @@ index 68d19632aeb7..67cc9839952f 100644
130
119
{
131
120
if (kernel_locked_down >= level)
132
121
return -EPERM;
133
- - -
134
- 2.39.2
135
-
0 commit comments