Commit efc7d880 authored by Josh Boyer's avatar Josh Boyer Committed by Tim Gardner

UBUNTU: SAUCE: (noup) KEYS: Add a system blacklist keyring

BugLink: http://bugs.launchpad.net/bugs/1569924

This adds an additional keyring that is used to store certificates that
are blacklisted.  This keyring is searched first when loading signed modules
and if the module's certificate is found, it will refuse to load.  This is
useful in cases where third party certificates are used for module signing.
Signed-off-by: default avatarJosh Boyer <jwboyer@fedoraproject.org>
Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
Signed-off-by: default avatarAndy Whitcroft <andy.whitcroft@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 1786f4db
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
struct key *system_trusted_keyring; struct key *system_trusted_keyring;
EXPORT_SYMBOL_GPL(system_trusted_keyring); EXPORT_SYMBOL_GPL(system_trusted_keyring);
#ifdef CONFIG_SYSTEM_BLACKLIST_KEYRING
struct key *system_blacklist_keyring;
#endif
extern __initconst const u8 system_certificate_list[]; extern __initconst const u8 system_certificate_list[];
extern __initconst const unsigned long system_certificate_list_size; extern __initconst const unsigned long system_certificate_list_size;
...@@ -41,6 +44,20 @@ static __init int system_trusted_keyring_init(void) ...@@ -41,6 +44,20 @@ static __init int system_trusted_keyring_init(void)
panic("Can't allocate system trusted keyring\n"); panic("Can't allocate system trusted keyring\n");
set_bit(KEY_FLAG_TRUSTED_ONLY, &system_trusted_keyring->flags); set_bit(KEY_FLAG_TRUSTED_ONLY, &system_trusted_keyring->flags);
#ifdef CONFIG_SYSTEM_BLACKLIST_KEYRING
system_blacklist_keyring = keyring_alloc(".system_blacklist_keyring",
KUIDT_INIT(0), KGIDT_INIT(0),
current_cred(),
(KEY_POS_ALL & ~KEY_POS_SETATTR) |
KEY_USR_VIEW | KEY_USR_READ,
KEY_ALLOC_NOT_IN_QUOTA, NULL);
if (IS_ERR(system_blacklist_keyring))
panic("Can't allocate system blacklist keyring\n");
set_bit(KEY_FLAG_TRUSTED_ONLY, &system_blacklist_keyring->flags);
#endif
return 0; return 0;
} }
...@@ -139,6 +156,16 @@ int system_verify_data(const void *data, unsigned long len, ...@@ -139,6 +156,16 @@ int system_verify_data(const void *data, unsigned long len,
if (ret < 0) if (ret < 0)
goto error; goto error;
#ifdef CONFIG_SYSTEM_BLACKLIST_KEYRING
ret = pkcs7_validate_trust(pkcs7, system_blacklist_keyring, &trusted);
if (!ret) {
/* module is signed with a cert in the blacklist. reject */
pr_err("Module key is in the blacklist\n");
ret = -EKEYREJECTED;
goto error;
}
#endif
ret = pkcs7_validate_trust(pkcs7, system_trusted_keyring, &trusted); ret = pkcs7_validate_trust(pkcs7, system_trusted_keyring, &trusted);
if (ret < 0) if (ret < 0)
goto error; goto error;
......
...@@ -35,6 +35,10 @@ extern int system_verify_data(const void *data, unsigned long len, ...@@ -35,6 +35,10 @@ extern int system_verify_data(const void *data, unsigned long len,
enum key_being_used_for usage); enum key_being_used_for usage);
#endif #endif
#ifdef CONFIG_SYSTEM_BLACKLIST_KEYRING
extern struct key *system_blacklist_keyring;
#endif
#ifdef CONFIG_IMA_MOK_KEYRING #ifdef CONFIG_IMA_MOK_KEYRING
extern struct key *ima_mok_keyring; extern struct key *ima_mok_keyring;
extern struct key *ima_blacklist_keyring; extern struct key *ima_blacklist_keyring;
......
...@@ -1804,6 +1804,15 @@ config SYSTEM_DATA_VERIFICATION ...@@ -1804,6 +1804,15 @@ config SYSTEM_DATA_VERIFICATION
module verification, kexec image verification and firmware blob module verification, kexec image verification and firmware blob
verification. verification.
config SYSTEM_BLACKLIST_KEYRING
bool "Provide system-wide ring of blacklisted keys"
depends on KEYS
help
Provide a system keyring to which blacklisted keys can be added.
Keys in the keyring are considered entirely untrusted. Keys in this
keyring are used by the module signature checking to reject loading
of modules signed with a blacklisted key.
config PROFILING config PROFILING
bool "Profiling support" bool "Profiling support"
help help
......
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