Commit 4cb1ed94 authored by Nayna Jain's avatar Nayna Jain Committed by Jarkko Sakkinen

integrity: check whether imputed trust is enabled

trust_moklist() is specific to UEFI enabled systems. Other platforms
rely only on the Kconfig.

Define a generic wrapper named imputed_trust_enabled().
Signed-off-by: default avatarNayna Jain <nayna@linux.ibm.com>
Reviewed-by: default avatarMimi Zohar <zohar@linux.ibm.com>
Tested-by: default avatarNageswara R Sastry <rnsastry@linux.ibm.com>
Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
parent 7b9de406
...@@ -113,7 +113,7 @@ static int __init __integrity_init_keyring(const unsigned int id, ...@@ -113,7 +113,7 @@ static int __init __integrity_init_keyring(const unsigned int id,
} else { } else {
if (id == INTEGRITY_KEYRING_PLATFORM) if (id == INTEGRITY_KEYRING_PLATFORM)
set_platform_trusted_keys(keyring[id]); set_platform_trusted_keys(keyring[id]);
if (id == INTEGRITY_KEYRING_MACHINE && trust_moklist()) if (id == INTEGRITY_KEYRING_MACHINE && imputed_trust_enabled())
set_machine_trusted_keys(keyring[id]); set_machine_trusted_keys(keyring[id]);
if (id == INTEGRITY_KEYRING_IMA) if (id == INTEGRITY_KEYRING_IMA)
load_module_cert(keyring[id]); load_module_cert(keyring[id]);
......
...@@ -320,13 +320,14 @@ static inline void __init add_to_platform_keyring(const char *source, ...@@ -320,13 +320,14 @@ static inline void __init add_to_platform_keyring(const char *source,
#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING #ifdef CONFIG_INTEGRITY_MACHINE_KEYRING
void __init add_to_machine_keyring(const char *source, const void *data, size_t len); void __init add_to_machine_keyring(const char *source, const void *data, size_t len);
bool __init trust_moklist(void); bool __init imputed_trust_enabled(void);
#else #else
static inline void __init add_to_machine_keyring(const char *source, static inline void __init add_to_machine_keyring(const char *source,
const void *data, size_t len) const void *data, size_t len)
{ {
} }
static inline bool __init trust_moklist(void)
static inline bool __init imputed_trust_enabled(void)
{ {
return false; return false;
} }
......
...@@ -61,7 +61,8 @@ __init efi_element_handler_t get_handler_for_db(const efi_guid_t *sig_type) ...@@ -61,7 +61,8 @@ __init efi_element_handler_t get_handler_for_db(const efi_guid_t *sig_type)
__init efi_element_handler_t get_handler_for_mok(const efi_guid_t *sig_type) __init efi_element_handler_t get_handler_for_mok(const efi_guid_t *sig_type)
{ {
if (efi_guidcmp(*sig_type, efi_cert_x509_guid) == 0) { if (efi_guidcmp(*sig_type, efi_cert_x509_guid) == 0) {
if (IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING) && trust_moklist()) if (IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING) &&
imputed_trust_enabled())
return add_to_machine_keyring; return add_to_machine_keyring;
else else
return add_to_platform_keyring; return add_to_platform_keyring;
......
...@@ -34,7 +34,8 @@ void __init add_to_machine_keyring(const char *source, const void *data, size_t ...@@ -34,7 +34,8 @@ void __init add_to_machine_keyring(const char *source, const void *data, size_t
* If the restriction check does not pass and the platform keyring * If the restriction check does not pass and the platform keyring
* is configured, try to add it into that keyring instead. * is configured, try to add it into that keyring instead.
*/ */
if (rc && efi_enabled(EFI_BOOT) && IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING)) if (rc && efi_enabled(EFI_BOOT) &&
IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING))
rc = integrity_load_cert(INTEGRITY_KEYRING_PLATFORM, source, rc = integrity_load_cert(INTEGRITY_KEYRING_PLATFORM, source,
data, len, perm); data, len, perm);
...@@ -60,7 +61,7 @@ static __init bool uefi_check_trust_mok_keys(void) ...@@ -60,7 +61,7 @@ static __init bool uefi_check_trust_mok_keys(void)
return false; return false;
} }
bool __init trust_moklist(void) static bool __init trust_moklist(void)
{ {
static bool initialized; static bool initialized;
static bool trust_mok; static bool trust_mok;
...@@ -75,3 +76,16 @@ bool __init trust_moklist(void) ...@@ -75,3 +76,16 @@ bool __init trust_moklist(void)
return trust_mok; return trust_mok;
} }
/*
* Provides platform specific check for trusting imputed keys before loading
* on .machine keyring. UEFI systems enable this trust based on a variable,
* and for other platforms, it is always enabled.
*/
bool __init imputed_trust_enabled(void)
{
if (efi_enabled(EFI_BOOT))
return trust_moklist();
return true;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment