mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
integrity: machine keyring CA configuration
Add machine keyring CA restriction options to control the type of keys that may be added to it. The motivation is separation of certificate signing from code signing keys. Subsquent work will limit certificates being loaded into the IMA keyring to code signing keys used for signature verification. When no restrictions are selected, all Machine Owner Keys (MOK) are added to the machine keyring. When CONFIG_INTEGRITY_CA_MACHINE_KEYRING is selected, the CA bit must be true. Also the key usage must contain keyCertSign, any other usage field may be set as well. When CONFIG_INTEGRITY_CA_MACHINE_KEYRING_MAX is selected, the CA bit must be true. Also the key usage must contain keyCertSign and the digitialSignature usage may not be set. Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com> Acked-by: Mimi Zohar <zohar@linux.ibm.com> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Tested-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
This commit is contained in:
parent
76adb2fbc6
commit
099f26f22f
@ -140,6 +140,8 @@ int restrict_link_by_ca(struct key *dest_keyring,
|
|||||||
return -ENOKEY;
|
return -ENOKEY;
|
||||||
if (!test_bit(KEY_EFLAG_KEYCERTSIGN, &pkey->key_eflags))
|
if (!test_bit(KEY_EFLAG_KEYCERTSIGN, &pkey->key_eflags))
|
||||||
return -ENOKEY;
|
return -ENOKEY;
|
||||||
|
if (!IS_ENABLED(CONFIG_INTEGRITY_CA_MACHINE_KEYRING_MAX))
|
||||||
|
return 0;
|
||||||
if (test_bit(KEY_EFLAG_DIGITALSIG, &pkey->key_eflags))
|
if (test_bit(KEY_EFLAG_DIGITALSIG, &pkey->key_eflags))
|
||||||
return -ENOKEY;
|
return -ENOKEY;
|
||||||
|
|
||||||
|
@ -68,13 +68,34 @@ config INTEGRITY_MACHINE_KEYRING
|
|||||||
depends on INTEGRITY_ASYMMETRIC_KEYS
|
depends on INTEGRITY_ASYMMETRIC_KEYS
|
||||||
depends on SYSTEM_BLACKLIST_KEYRING
|
depends on SYSTEM_BLACKLIST_KEYRING
|
||||||
depends on LOAD_UEFI_KEYS
|
depends on LOAD_UEFI_KEYS
|
||||||
depends on !IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY
|
|
||||||
help
|
help
|
||||||
If set, provide a keyring to which Machine Owner Keys (MOK) may
|
If set, provide a keyring to which Machine Owner Keys (MOK) may
|
||||||
be added. This keyring shall contain just MOK keys. Unlike keys
|
be added. This keyring shall contain just MOK keys. Unlike keys
|
||||||
in the platform keyring, keys contained in the .machine keyring will
|
in the platform keyring, keys contained in the .machine keyring will
|
||||||
be trusted within the kernel.
|
be trusted within the kernel.
|
||||||
|
|
||||||
|
config INTEGRITY_CA_MACHINE_KEYRING
|
||||||
|
bool "Enforce Machine Keyring CA Restrictions"
|
||||||
|
depends on INTEGRITY_MACHINE_KEYRING
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
The .machine keyring can be configured to enforce CA restriction
|
||||||
|
on any key added to it. By default no restrictions are in place
|
||||||
|
and all Machine Owner Keys (MOK) are added to the machine keyring.
|
||||||
|
If enabled only CA keys are added to the machine keyring, all
|
||||||
|
other MOK keys load into the platform keyring.
|
||||||
|
|
||||||
|
config INTEGRITY_CA_MACHINE_KEYRING_MAX
|
||||||
|
bool "Only CA keys without DigitialSignature usage set"
|
||||||
|
depends on INTEGRITY_CA_MACHINE_KEYRING
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
When selected, only load CA keys are loaded into the machine
|
||||||
|
keyring that contain the CA bit set along with the keyCertSign
|
||||||
|
Usage field. Keys containing the digitialSignature Usage field
|
||||||
|
will not be loaded. The remaining MOK keys are loaded into the
|
||||||
|
.platform keyring.
|
||||||
|
|
||||||
config LOAD_UEFI_KEYS
|
config LOAD_UEFI_KEYS
|
||||||
depends on INTEGRITY_PLATFORM_KEYRING
|
depends on INTEGRITY_PLATFORM_KEYRING
|
||||||
depends on EFI
|
depends on EFI
|
||||||
|
@ -132,7 +132,8 @@ int __init integrity_init_keyring(const unsigned int id)
|
|||||||
| KEY_USR_READ | KEY_USR_SEARCH;
|
| KEY_USR_READ | KEY_USR_SEARCH;
|
||||||
|
|
||||||
if (id == INTEGRITY_KEYRING_PLATFORM ||
|
if (id == INTEGRITY_KEYRING_PLATFORM ||
|
||||||
id == INTEGRITY_KEYRING_MACHINE) {
|
(id == INTEGRITY_KEYRING_MACHINE &&
|
||||||
|
!IS_ENABLED(CONFIG_INTEGRITY_CA_MACHINE_KEYRING))) {
|
||||||
restriction = NULL;
|
restriction = NULL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -144,7 +145,10 @@ int __init integrity_init_keyring(const unsigned int id)
|
|||||||
if (!restriction)
|
if (!restriction)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
restriction->check = restrict_link_to_ima;
|
if (id == INTEGRITY_KEYRING_MACHINE)
|
||||||
|
restriction->check = restrict_link_by_ca;
|
||||||
|
else
|
||||||
|
restriction->check = restrict_link_to_ima;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MOK keys can only be added through a read-only runtime services
|
* MOK keys can only be added through a read-only runtime services
|
||||||
|
Loading…
Reference in New Issue
Block a user