Skip to content

Commit 3d6ae1a

Browse files
esnowbergjarkkojs
authored andcommitted
integrity: Only use machine keyring when uefi_check_trust_mok_keys is true
With the introduction of uefi_check_trust_mok_keys, it signifies the end- user wants to trust the machine keyring as trusted keys. If they have chosen to trust the machine keyring, load the qualifying keys into it during boot, then link it to the secondary keyring . If the user has not chosen to trust the machine keyring, it will be empty and not linked to the secondary keyring. Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
1 parent 74f5e30 commit 3d6ae1a

4 files changed

Lines changed: 23 additions & 2 deletions

File tree

security/integrity/digsig.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static int __init __integrity_init_keyring(const unsigned int id,
112112
} else {
113113
if (id == INTEGRITY_KEYRING_PLATFORM)
114114
set_platform_trusted_keys(keyring[id]);
115-
if (id == INTEGRITY_KEYRING_MACHINE)
115+
if (id == INTEGRITY_KEYRING_MACHINE && trust_moklist())
116116
set_machine_trusted_keys(keyring[id]);
117117
if (id == INTEGRITY_KEYRING_IMA)
118118
load_module_cert(keyring[id]);

security/integrity/integrity.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,14 @@ static inline void __init add_to_platform_keyring(const char *source,
287287

288288
#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING
289289
void __init add_to_machine_keyring(const char *source, const void *data, size_t len);
290+
bool __init trust_moklist(void);
290291
#else
291292
static inline void __init add_to_machine_keyring(const char *source,
292293
const void *data, size_t len)
293294
{
294295
}
296+
static inline bool __init trust_moklist(void)
297+
{
298+
return false;
299+
}
295300
#endif

security/integrity/platform_certs/keyring_handler.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ __init efi_element_handler_t get_handler_for_db(const efi_guid_t *sig_type)
8383
__init efi_element_handler_t get_handler_for_mok(const efi_guid_t *sig_type)
8484
{
8585
if (efi_guidcmp(*sig_type, efi_cert_x509_guid) == 0) {
86-
if (IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING))
86+
if (IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING) && trust_moklist())
8787
return add_to_machine_keyring;
8888
else
8989
return add_to_platform_keyring;

security/integrity/platform_certs/machine_keyring.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <linux/efi.h>
99
#include "../integrity.h"
1010

11+
static bool trust_mok;
12+
1113
static __init int machine_keyring_init(void)
1214
{
1315
int rc;
@@ -59,3 +61,17 @@ static __init bool uefi_check_trust_mok_keys(void)
5961

6062
return false;
6163
}
64+
65+
bool __init trust_moklist(void)
66+
{
67+
static bool initialized;
68+
69+
if (!initialized) {
70+
initialized = true;
71+
72+
if (uefi_check_trust_mok_keys())
73+
trust_mok = true;
74+
}
75+
76+
return trust_mok;
77+
}

0 commit comments

Comments
 (0)