Skip to content

Commit b465030

Browse files
committed
certs: Only allow certs signed by keys on the builtin keyring
Originally the secondary trusted keyring provided a keyring to which extra keys may be added, provided those keys were not blacklisted and were vouched for by a key built into the kernel or already in the secondary trusted keyring. On systems with the machine keyring configured, additional keys may also be vouched for by a key on the machine keyring. Prevent loading additional certificates directly onto the secondary keyring, vouched for by keys on the machine keyring, yet allow these certificates to be loaded onto other trusted keyrings. Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent 7b5c308 commit b465030

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

certs/Kconfig

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,21 @@ config SECONDARY_TRUSTED_KEYRING
8888
help
8989
If set, provide a keyring to which extra keys may be added, provided
9090
those keys are not blacklisted and are vouched for by a key built
91-
into the kernel or already in the secondary trusted keyring.
91+
into the kernel, machine keyring (if configured), or already in the
92+
secondary trusted keyring.
93+
94+
config SECONDARY_TRUSTED_KEYRING_SIGNED_BY_BUILTIN
95+
bool "Only allow additional certs signed by keys on the builtin trusted keyring"
96+
depends on SECONDARY_TRUSTED_KEYRING
97+
help
98+
If set, only certificates signed by keys on the builtin trusted
99+
keyring may be loaded onto the secondary trusted keyring.
100+
101+
Note: The machine keyring, if configured, will be linked to the
102+
secondary keyring. When enabling this option, it is recommended
103+
to also configure INTEGRITY_CA_MACHINE_KEYRING_MAX to prevent
104+
linking code signing keys with imputed trust to the secondary
105+
trusted keyring.
92106

93107
config SYSTEM_BLACKLIST_KEYRING
94108
bool "Provide system-wide ring of blacklisted keys"

crypto/asymmetric_keys/restrict.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ int restrict_link_by_signature(struct key *dest_keyring,
102102

103103
if (use_builtin_keys && !test_bit(KEY_FLAG_BUILTIN, &key->flags))
104104
ret = -ENOKEY;
105+
else if (IS_BUILTIN(CONFIG_SECONDARY_TRUSTED_KEYRING_SIGNED_BY_BUILTIN) &&
106+
!strcmp(dest_keyring->description, ".secondary_trusted_keys") &&
107+
!test_bit(KEY_FLAG_BUILTIN, &key->flags))
108+
ret = -ENOKEY;
105109
else
106110
ret = verify_signature(key, sig);
107111
key_put(key);

0 commit comments

Comments
 (0)