From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:21:56
Back in 2013 Linus requested a feature to allow end-users to have the
ability "to add their own keys and sign modules they trust". This was
his *second* order outlined here [1]. There have been many attempts
over the years to solve this problem, all have been rejected. Many
of the failed attempts loaded all preboot firmware keys into the kernel,
including the Secure Boot keys. Many distributions carry one of these
rejected attempts [2], [3], [4]. This series tries to solve this problem
with a solution that takes into account all the problems brought up in
the previous attempts.
On UEFI based systems, this series introduces a new Linux kernel keyring
containing the Machine Owner Keys (MOK) called machine. It also defines
a new MOK variable in shim. This variable allows the end-user to decide
if they want to load MOK keys into the machine keyring. Mimi has suggested
that only CA keys contained within the MOK be loaded into the machine
keyring. All other certs will load into the platform keyring instead.
By default, nothing changes; MOK keys are not loaded into the machine
keyring. They are only loaded after the end-user makes the decision
themselves. The end-user would set this through mokutil using a new
--trust-mok option [5]. This would work similar to how the kernel uses
MOK variables to enable/disable signature validation as well as use/ignore
the db. Any kernel operation that uses either the builtin or secondary
trusted keys as a trust source shall also reference the new machine
keyring as a trust source.
Secure Boot keys will never be loaded into the machine keyring. They
will always be loaded into the platform keyring. If an end-user wanted
to load one, they would need to enroll it into the MOK.
Steps required by the end user:
Sign kernel module with user created key:
$ /usr/src/kernels/$(uname -r)/scripts/sign-file sha512 \
machine_signing_key.priv machine_signing_key.x509 my_module.ko
Import the key into the MOK
$ mokutil --import machine_signing_key.x509
Setup the kernel to load MOK keys into the .machine keyring
$ mokutil --trust-mok
Then reboot, the MokManager will load and ask if you want to trust the
MOK key and enroll the MOK into the MOKList. Afterwards the signed kernel
module will load.
I have included a link to the mokutil [5] changes I have made to support
this new functionality. The shim changes have now been accepted
upstream [6].
[1] https://marc.info/?l=linux-kernel&m=136185386310140&w=2
[2] https://lore.kernel.org/lkml/1479737095.2487.34.camel@linux.vnet.ibm.com/
[3] https://lore.kernel.org/lkml/1556221605.24945.3.camel@HansenPartnership.com/
[4] https://lore.kernel.org/linux-integrity/1e41f22b1f11784f1e943f32bf62034d4e054cdb.camel@HansenPartnership.com/
[5] https://github.com/esnowberg/mokutil/tree/mokvars-v3
[6] https://github.com/rhboot/shim/commit/4e513405b4f1641710115780d19dcec130c5208f
Eric Snowberg (17):
integrity: Introduce a Linux keyring called machine
integrity: Do not allow machine keyring updates following init
KEYS: Create static version of public_key_verify_signature
X.509: Parse Basic Constraints for CA
KEYS: CA link restriction
integrity: restrict INTEGRITY_KEYRING_MACHINE to restrict_link_by_ca
integrity: Fix warning about missing prototypes
integrity: add new keyring handler for mok keys
KEYS: Rename get_builtin_and_secondary_restriction
KEYS: add a reference to machine keyring
KEYS: Introduce link restriction for machine keys
KEYS: integrity: change link restriction to trust the machine keyring
KEYS: link secondary_trusted_keys to machine trusted keys
integrity: store reference to machine keyring
efi/mokvar: move up init order
integrity: Trust MOK keys if MokListTrustedRT found
integrity: Only use machine keyring when uefi_check_trust_mok_keys is
true
certs/system_keyring.c | 44 ++++++++++-
crypto/asymmetric_keys/restrict.c | 43 +++++++++++
crypto/asymmetric_keys/x509_cert_parser.c | 9 +++
drivers/firmware/efi/mokvar-table.c | 2 +-
include/crypto/public_key.h | 15 ++++
include/keys/system_keyring.h | 14 ++++
security/integrity/Kconfig | 12 +++
security/integrity/Makefile | 1 +
security/integrity/digsig.c | 23 +++++-
security/integrity/integrity.h | 17 +++-
.../platform_certs/keyring_handler.c | 18 ++++-
.../platform_certs/keyring_handler.h | 5 ++
security/integrity/platform_certs/load_uefi.c | 4 +-
.../platform_certs/machine_keyring.c | 77 +++++++++++++++++++
14 files changed, 273 insertions(+), 11 deletions(-)
create mode 100644 security/integrity/platform_certs/machine_keyring.c
base-commit: fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf
--
2.18.4
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:19:36
Add a new link restriction. Restrict the addition of keys in a keyring
based on the key to be added being a CA.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v1: Initial version
v2: Removed secondary keyring references
v3: Removed restrict_link_by_system_trusted_or_ca
Simplify restrict_link_by_ca - only see if the key is a CA
Did not add __init in front of restrict_link_by_ca in case
restriction could be resued in the future
v6: Unmodified from v3
v7: Check for CA restruction in public key
---
crypto/asymmetric_keys/restrict.c | 43 +++++++++++++++++++++++++++++++
include/crypto/public_key.h | 5 ++++
2 files changed, 48 insertions(+)
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:19:39
The kernel test robot reports undefined reference to
public_key_verify_signature when CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE is
not defined. Create a static version in this case and return -EINVAL.
Reported-by: kernel test robot <redacted>
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v7: Initial version
---
include/crypto/public_key.h | 9 +++++++++
1 file changed, 9 insertions(+)
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:19:48
Parse the X.509 Basic Constraints. The basic constraints extension
identifies whether the subject of the certificate is a CA.
BasicConstraints ::= SEQUENCE {
cA BOOLEAN DEFAULT FALSE,
pathLenConstraint INTEGER (0..MAX) OPTIONAL }
If the CA is true, store it in a new public_key field call key_is_ca.
This will be used in a follow on patch that requires knowing if the
public key is a CA.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v7: Initial version
---
crypto/asymmetric_keys/x509_cert_parser.c | 9 +++++++++
include/crypto/public_key.h | 1 +
2 files changed, 10 insertions(+)
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:19:54
Currently both Secure Boot DB and Machine Owner Keys (MOK) go through
the same keyring handler (get_handler_for_db). With the addition of the
new machine keyring, the end-user may choose to trust MOK keys.
Introduce a new keyring handler specific for MOK keys. If MOK keys are
trusted by the end-user, use the new keyring handler instead.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v1: Initial version
v3: Only change the keyring handler if the secondary is enabled
v4: Removed trust_moklist check
v5: Rename to machine keyring
v7: Unmodified from v5
---
.../integrity/platform_certs/keyring_handler.c | 17 ++++++++++++++++-
.../integrity/platform_certs/keyring_handler.h | 5 +++++
security/integrity/platform_certs/load_uefi.c | 4 ++--
3 files changed, 23 insertions(+), 3 deletions(-)
@@ -94,7 +94,7 @@ static int __init load_moklist_certs(void)rc=parse_efi_signature_list("UEFI:MokListRT (MOKvar table)",mokvar_entry->data,mokvar_entry->data_size,-get_handler_for_db);+get_handler_for_mok);/* All done if that worked. */if(!rc)returnrc;
@@ -77,7 +77,7 @@ int restrict_link_by_builtin_and_secondary_trusted(*Allocateastructkey_restrictionforthe"builtin and secondary trust"*keyring.Onlyforuseinsystem_trusted_keyring_init().*/-static__initstructkey_restriction*get_builtin_and_secondary_restriction(void)+static__initstructkey_restriction*get_secondary_restriction(void){structkey_restriction*restriction;
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:20:02
Expose the .machine keyring created in integrity code by adding
a reference. This makes the machine keyring accessible for keyring
restrictions in the future.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v2: Initial version
v3: set_mok_trusted_keys only available when secondary is enabled
v4: Moved code under CONFIG_INTEGRITY_MOK_KEYRING
v5: Rename to machine keyring
v7: Unmodified from v5
---
certs/system_keyring.c | 9 +++++++++
include/keys/system_keyring.h | 8 ++++++++
2 files changed, 17 insertions(+)
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:20:07
Introduce a new link restriction that includes the trusted builtin,
secondary and machine keys. The restriction is based on the key to be
added being vouched for by a key in any of these three keyrings.
Suggested-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v3: Initial version
v4: moved code under CONFIG_INTEGRITY_MOK_KEYRING
v5: Rename to machine keyring
v6: Change subject name (suggested by Mimi)
Rename restrict_link_by_builtin_secondary_and_ca_trusted
to restrict_link_by_builtin_secondary_and_machine (suggested by
Mimi)
v7: Unmodified from v6
---
certs/system_keyring.c | 23 +++++++++++++++++++++++
include/keys/system_keyring.h | 6 ++++++
2 files changed, 29 insertions(+)
@@ -99,6 +99,29 @@ void __init set_machine_trusted_keys(struct key *keyring){machine_trusted_keys=keyring;}++/**+*restrict_link_by_builtin_secondary_and_machine+*+*Restricttheadditionofkeysintoakeyringbasedonthekey-to-be-added+*beingvouchedforbyakeyineitherthebuilt-in,thesecondary,or+*themachinekeyrings.+*/+intrestrict_link_by_builtin_secondary_and_machine(+structkey*dest_keyring,+conststructkey_type*type,+constunionkey_payload*payload,+structkey*restrict_key)+{+if(machine_trusted_keys&&type==&key_type_keyring&&+dest_keyring==secondary_trusted_keys&&+payload==&machine_trusted_keys->payload)+/* Allow the machine keyring to be added to the secondary */+return0;++returnrestrict_link_by_builtin_and_secondary_trusted(dest_keyring,type,+payload,restrict_key);+}#endif/*
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:20:15
With the introduction of the machine keyring, the end-user may choose to
trust Machine Owner Keys (MOK) within the kernel. If they have chosen to
trust them, the .machine keyring will contain these keys. If not, the
machine keyring will always be empty. Update the restriction check to
allow the secondary trusted keyring and ima keyring to also trust
machine keys.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v4: Initial version (consolidated two previous patches)
v5: Rename to machine keyring
v6: Account for restriction being renamed earlier
v7: Unmodified from v6
---
certs/system_keyring.c | 5 ++++-
security/integrity/digsig.c | 4 ++++
2 files changed, 8 insertions(+), 1 deletion(-)
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:21:53
The machine keyring is setup during init. No additional keys should be
allowed to be added afterwards. Leave the permission as read only.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v2: Initial version
v4: Unmodified from v2
v5: Rename to machine keyring
v6: Add additional comment (suggested by Jarkko)
v7: Unmodified from v6
---
security/integrity/digsig.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
@@ -140,7 +140,13 @@ int __init integrity_init_keyring(const unsigned int id)return-ENOMEM;restriction->check=restrict_link_to_ima;-perm|=KEY_USR_WRITE;++/*+*Noadditionalkeysshallbeallowedtoloadintothemachine+*keyringfollowinginit+*/+if(id!=INTEGRITY_KEYRING_MACHINE)+perm|=KEY_USR_WRITE;out:return__integrity_init_keyring(id,perm,restriction);
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:21:57
Allow the .machine keyring to be linked to the secondary_trusted_keys.
After the link is created, keys contained in the .machine keyring will
automatically be searched when searching secondary_trusted_keys.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v3: Initial version
v4: Unmodified from v3
v5: Rename to machine keyring
v7: Unmodified from v5
---
certs/system_keyring.c | 3 +++
1 file changed, 3 insertions(+)
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:21:57
A new Machine Owner Key (MOK) variable called MokListTrustedRT has been
introduced in shim. When this UEFI variable is set, it indicates the
end-user has made the decision themselves that they wish to trust MOK keys
within the Linux trust boundary. It is not an error if this variable
does not exist. If it does not exist, the MOK keys should not be trusted
within the kernel.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v1: Initial version
v2: Removed mok_keyring_trust_setup function
v4: Unmodified from v2
v5: Rename to machine keyring
v6: Unmodified from v5
v7: Use mokvar table instead of EFI var (suggested by Peter Jones)
---
.../platform_certs/machine_keyring.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:21:57
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>
---
v4: Initial version
v5: Rename to machine keyring
v6: Unmodified from v5
v7: Made trust_mok static
---
security/integrity/digsig.c | 2 +-
security/integrity/integrity.h | 5 +++++
.../integrity/platform_certs/keyring_handler.c | 2 +-
.../integrity/platform_certs/machine_keyring.c | 16 ++++++++++++++++
4 files changed, 23 insertions(+), 2 deletions(-)
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:22:20
Many UEFI Linux distributions boot using shim. The UEFI shim provides
what is called Machine Owner Keys (MOK). Shim uses both the UEFI Secure
Boot DB and MOK keys to validate the next step in the boot chain. The
MOK facility can be used to import user generated keys. These keys can
be used to sign an end-users development kernel build. When Linux
boots, both UEFI Secure Boot DB and MOK keys get loaded in the Linux
.platform keyring.
Define a new Linux keyring called machine. This keyring shall contain just
MOK CA keys and not the remaining keys in the platform keyring. This new
machine keyring will be used in follow on patches. Unlike keys in the
platform keyring, keys contained in the machine keyring will be trusted
within the kernel if the end-user has chosen to do so.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v1: Initial version
v2: Removed destory keyring code
v3: Unmodified from v2
v4: Add Kconfig, merged in "integrity: add add_to_mok_keyring"
v5: Rename to machine keyring
v6: Depend on EFI in kconfig (suggested by Mimi)
Test to see if ".platform" keyring is configured in
add_to_machine_keyring (suggested by Mimi)
v7: Depend on LOAD_UEFI_KEYS instead EFI for mokvar code
---
security/integrity/Kconfig | 12 ++++++
security/integrity/Makefile | 1 +
security/integrity/digsig.c | 1 +
security/integrity/integrity.h | 12 +++++-
.../platform_certs/machine_keyring.c | 42 +++++++++++++++++++
5 files changed, 67 insertions(+), 1 deletion(-)
create mode 100644 security/integrity/platform_certs/machine_keyring.c
@@ -62,6 +62,18 @@ config INTEGRITY_PLATFORM_KEYRINGprovidedbytheplatformforverifyingthekexec'edkernedimageand,possibly,theinitramfssignature.+configINTEGRITY_MACHINE_KEYRING+bool"Provide a keyring to which CA Machine Owner Keys may be added"+depends onSECONDARY_TRUSTED_KEYRING+depends onINTEGRITY_ASYMMETRIC_KEYS+depends onSYSTEM_BLACKLIST_KEYRING+depends onLOAD_UEFI_KEYS+help+Ifset,provideakeyringtowhichCAMachineOwnerKeys(MOK)may+beadded.ThiskeyringshallcontainjustCAMOKkeys.Unlikekeys+intheplatformkeyring,keyscontainedinthe.machinekeyringwill+betrustedwithinthekernel.+configLOAD_UEFI_KEYSdepends onINTEGRITY_PLATFORM_KEYRINGdepends onEFI
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:22:23
make W=1 generates the following warning in keyring_handler.c
security/integrity/platform_certs/keyring_handler.c:71:30: warning: no previous prototype for get_handler_for_db [-Wmissing-prototypes]
__init efi_element_handler_t get_handler_for_db(const efi_guid_t *sig_type)
^~~~~~~~~~~~~~~~~~
security/integrity/platform_certs/keyring_handler.c:82:30: warning: no previous prototype for get_handler_for_dbx [-Wmissing-prototypes]
__init efi_element_handler_t get_handler_for_dbx(const efi_guid_t *sig_type)
^~~~~~~~~~~~~~~~~~~
Add the missing prototypes by including keyring_handler.h.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v7: Initial version
---
security/integrity/platform_certs/keyring_handler.c | 1 +
1 file changed, 1 insertion(+)
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:22:23
Set the restriction check for INTEGRITY_KEYRING_MACHINE keys to
restrict_link_by_ca. This will only allow CA keys into the machine
keyring.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v1: Initial version
v2: Added !IS_ENABLED(CONFIG_INTEGRITY_TRUSTED_KEYRING check so mok
keyring gets created even when it isn't enabled
v3: Rename restrict_link_by_system_trusted_or_ca to restrict_link_by_ca
v4: removed unnecessary restriction->check set
v5: Rename to machine keyring
v6: split line over 80 char (suggested by Mimi)
v7: Unmodified from v6
---
security/integrity/digsig.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
@@ -132,14 +132,18 @@ int __init integrity_init_keyring(const unsigned int id)gotoout;}-if(!IS_ENABLED(CONFIG_INTEGRITY_TRUSTED_KEYRING))+if(!IS_ENABLED(CONFIG_INTEGRITY_TRUSTED_KEYRING)&&+id!=INTEGRITY_KEYRING_MACHINE)return0;restriction=kzalloc(sizeof(structkey_restriction),GFP_KERNEL);if(!restriction)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;/**Noadditionalkeysshallbeallowedtoloadintothemachine
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:22:23
Move up the init order so it can be used by the new machine keyring.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v7: Initial version
---
drivers/firmware/efi/mokvar-table.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-16 00:22:23
Store a reference to the machine keyring in system keyring code. The
system keyring code needs this to complete the keyring link to
to machine keyring.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v2: Initial version
v3: Unmodified from v2
v4: Removed trust_moklist check
v5: Rename to machine keyring
v7: Unmodified from v5
---
security/integrity/digsig.c | 2 ++
1 file changed, 2 insertions(+)
From: Jarkko Sakkinen <jarkko@kernel.org> Date: 2021-11-16 16:00:49
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
Back in 2013 Linus requested a feature to allow end-users to have the
ability "to add their own keys and sign modules they trust". This was
his *second* order outlined here [1]. There have been many attempts
over the years to solve this problem, all have been rejected. Many
of the failed attempts loaded all preboot firmware keys into the kernel,
including the Secure Boot keys. Many distributions carry one of these
rejected attempts [2], [3], [4]. This series tries to solve this problem
with a solution that takes into account all the problems brought up in
the previous attempts.
On UEFI based systems, this series introduces a new Linux kernel keyring
containing the Machine Owner Keys (MOK) called machine. It also defines
a new MOK variable in shim. This variable allows the end-user to decide
if they want to load MOK keys into the machine keyring. Mimi has suggested
that only CA keys contained within the MOK be loaded into the machine
keyring. All other certs will load into the platform keyring instead.
By default, nothing changes; MOK keys are not loaded into the machine
keyring. They are only loaded after the end-user makes the decision
themselves. The end-user would set this through mokutil using a new
--trust-mok option [5]. This would work similar to how the kernel uses
MOK variables to enable/disable signature validation as well as use/ignore
the db. Any kernel operation that uses either the builtin or secondary
trusted keys as a trust source shall also reference the new machine
keyring as a trust source.
Secure Boot keys will never be loaded into the machine keyring. They
will always be loaded into the platform keyring. If an end-user wanted
to load one, they would need to enroll it into the MOK.
Steps required by the end user:
Sign kernel module with user created key:
$ /usr/src/kernels/$(uname -r)/scripts/sign-file sha512 \
machine_signing_key.priv machine_signing_key.x509 my_module.ko
Import the key into the MOK
$ mokutil --import machine_signing_key.x509
Setup the kernel to load MOK keys into the .machine keyring
$ mokutil --trust-mok
Then reboot, the MokManager will load and ask if you want to trust the
MOK key and enroll the MOK into the MOKList. Afterwards the signed kernel
module will load.
I have included a link to the mokutil [5] changes I have made to support
this new functionality. The shim changes have now been accepted
upstream [6].
[1] https://marc.info/?l=linux-kernel&m=136185386310140&w=2
[2] https://lore.kernel.org/lkml/1479737095.2487.34.camel@linux.vnet.ibm.com/
[3] https://lore.kernel.org/lkml/1556221605.24945.3.camel@HansenPartnership.com/
[4] https://lore.kernel.org/linux-integrity/1e41f22b1f11784f1e943f32bf62034d4e054cdb.camel@HansenPartnership.com/
[5] https://github.com/esnowberg/mokutil/tree/mokvars-v3
[6] https://github.com/rhboot/shim/commit/4e513405b4f1641710115780d19dcec130c5208f
Eric Snowberg (17):
integrity: Introduce a Linux keyring called machine
integrity: Do not allow machine keyring updates following init
KEYS: Create static version of public_key_verify_signature
X.509: Parse Basic Constraints for CA
KEYS: CA link restriction
integrity: restrict INTEGRITY_KEYRING_MACHINE to restrict_link_by_ca
integrity: Fix warning about missing prototypes
integrity: add new keyring handler for mok keys
KEYS: Rename get_builtin_and_secondary_restriction
KEYS: add a reference to machine keyring
KEYS: Introduce link restriction for machine keys
KEYS: integrity: change link restriction to trust the machine keyring
KEYS: link secondary_trusted_keys to machine trusted keys
integrity: store reference to machine keyring
efi/mokvar: move up init order
integrity: Trust MOK keys if MokListTrustedRT found
integrity: Only use machine keyring when uefi_check_trust_mok_keys is
true
certs/system_keyring.c | 44 ++++++++++-
crypto/asymmetric_keys/restrict.c | 43 +++++++++++
crypto/asymmetric_keys/x509_cert_parser.c | 9 +++
drivers/firmware/efi/mokvar-table.c | 2 +-
include/crypto/public_key.h | 15 ++++
include/keys/system_keyring.h | 14 ++++
security/integrity/Kconfig | 12 +++
security/integrity/Makefile | 1 +
security/integrity/digsig.c | 23 +++++-
security/integrity/integrity.h | 17 +++-
.../platform_certs/keyring_handler.c | 18 ++++-
.../platform_certs/keyring_handler.h | 5 ++
security/integrity/platform_certs/load_uefi.c | 4 +-
.../platform_certs/machine_keyring.c | 77 +++++++++++++++++++
14 files changed, 273 insertions(+), 11 deletions(-)
create mode 100644 security/integrity/platform_certs/machine_keyring.c
base-commit: fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf
Does shim have the necessary features in a release?
/Jarkko
Does shim have the necessary features in a release?
Hi!
It has been accepted in the upstream shim. If you are looking
for a distribution having rolled out a shim with this feature (so signed
by MSF) I fear that distributions are not that fast with shim releases.
Also these:
https://github.com/rhboot/shim/pullshttps://github.com/rhboot/shim/issues
do mean some extra work would need to go in before an official
release is cut.
Hope this helps?
Does shim have the necessary features in a release?
Hi!
It has been accepted in the upstream shim. If you are looking
for a distribution having rolled out a shim with this feature (so signed
by MSF) I fear that distributions are not that fast with shim releases.
Also these:
https://github.com/rhboot/shim/pullshttps://github.com/rhboot/shim/issues
do mean some extra work would need to go in before an official
release is cut.
Hope this helps?
Yes. I'll hold with this up until there is an official release. Thank you.
/Jarkko
Does shim have the necessary features in a release?
Hi!
It has been accepted in the upstream shim. If you are looking
for a distribution having rolled out a shim with this feature (so signed
by MSF) I fear that distributions are not that fast with shim releases.
Also these:
https://github.com/rhboot/shim/pullshttps://github.com/rhboot/shim/issues
do mean some extra work would need to go in before an official
release is cut.
Hope this helps?
Yes. I'll hold with this up until there is an official release. Thank you.
Not sure I understand - but what are the concerns you have with shim
code that has been accepted?
Does shim have the necessary features in a release?
Hi!
It has been accepted in the upstream shim. If you are looking
for a distribution having rolled out a shim with this feature (so signed
by MSF) I fear that distributions are not that fast with shim releases.
Yes. I'll hold with this up until there is an official release. Thank you.
Not sure I understand - but what are the concerns you have with shim
code that has been accepted?
Maybe my concern is that none of the patches have a tested-by?
Probably would be easier to get a test coverage, e.g. for people like
me who do not even know how to self-compile Shim, how to setup user
space using the product and so forth.
I don't demand a release, if the changes have been accepted, but 17
patches do need to be tested.
/Jarkko
Does shim have the necessary features in a release?
Hi!
It has been accepted in the upstream shim. If you are looking
for a distribution having rolled out a shim with this feature (so signed
by MSF) I fear that distributions are not that fast with shim releases.
Yes. I'll hold with this up until there is an official release. Thank you.
Not sure I understand - but what are the concerns you have with shim
code that has been accepted?
Maybe my concern is that none of the patches have a tested-by?
Probably would be easier to get a test coverage, e.g. for people like
me who do not even know how to self-compile Shim, how to setup user
space using the product and so forth.
Hi Eric,
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
Many UEFI Linux distributions boot using shim. The UEFI shim provides
what is called Machine Owner Keys (MOK). Shim uses both the UEFI Secure
Boot DB and MOK keys to validate the next step in the boot chain. The
MOK facility can be used to import user generated keys. These keys can
be used to sign an end-users development kernel build. When Linux
boots, both UEFI Secure Boot DB and MOK keys get loaded in the Linux
.platform keyring.
, which can be used to verify kexec'ed kernel images.
Define a new Linux keyring called machine. This keyring shall contain just
MOK CA keys and not the remaining keys in the platform keyring. This new
machine keyring will be used in follow on patches. Unlike keys in the
platform keyring, keys contained in the machine keyring will be trusted
within the kernel if the end-user has chosen to do so.
allowing, for example, keys to be loaded onto the trusted IMA keyring.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Thank you for all the work! Just letting you know I'm slowly making my
through the patch set. With the previous patch re-organization, we
should be able to test everything up to the introduction of the MOK
variable support.
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
The machine keyring is setup during init. No additional keys should be
allowed to be added afterwards. Leave the permission as read only.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
The kernel test robot reports undefined reference to
public_key_verify_signature when CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE is
not defined. Create a static version in this case and return -EINVAL.
Reported-by: kernel test robot <redacted>
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
On Wed, 2021-11-17 at 08:32 -0500, Mimi Zohar wrote:
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
quoted
The kernel test robot reports undefined reference to
public_key_verify_signature when CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE is
not defined. Create a static version in this case and return -EINVAL.
Reported-by: kernel test robot <redacted>
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Perhaps this patch wouldn't be needed if
+config INTEGRITY_MACHINE_KEYRING
+ bool "Provide a keyring to which CA Machine Owner Keys may be
added"
+ depends on SECONDARY_TRUSTED_KEYRING
+ depends on INTEGRITY_ASYMMETRIC_KEYS
depends on ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y
+ depends on SYSTEM_BLACKLIST_KEYRING
+ depends on LOAD_UEFI_KEYS
Mimi
Hi Eric,
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
make W=1 generates the following warning in keyring_handler.c
security/integrity/platform_certs/keyring_handler.c:71:30: warning: no previous prototype for get_handler_for_db [-Wmissing-prototypes]
__init efi_element_handler_t get_handler_for_db(const efi_guid_t *sig_type)
^~~~~~~~~~~~~~~~~~
security/integrity/platform_certs/keyring_handler.c:82:30: warning: no previous prototype for get_handler_for_dbx [-Wmissing-prototypes]
__init efi_element_handler_t get_handler_for_dbx(const efi_guid_t *sig_type)
^~~~~~~~~~~~~~~~~~~
Add the missing prototypes by including keyring_handler.h.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
These sorts of fixes, which aren't really dependent on the patch set,
could be moved to the begining of the patch set.
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Does shim have the necessary features in a release?
Hi!
It has been accepted in the upstream shim. If you are looking
for a distribution having rolled out a shim with this feature (so signed
by MSF) I fear that distributions are not that fast with shim releases.
Yes. I'll hold with this up until there is an official release. Thank you.
Not sure I understand - but what are the concerns you have with shim
code that has been accepted?
Maybe my concern is that none of the patches have a tested-by?
Probably would be easier to get a test coverage, e.g. for people like
me who do not even know how to self-compile Shim, how to setup user
space using the product and so forth.
Does shim have the necessary features in a release?
Hi!
It has been accepted in the upstream shim. If you are looking
for a distribution having rolled out a shim with this feature (so signed
by MSF) I fear that distributions are not that fast with shim releases.
Yes. I'll hold with this up until there is an official release. Thank you.
Not sure I understand - but what are the concerns you have with shim
code that has been accepted?
Maybe my concern is that none of the patches have a tested-by?
Probably would be easier to get a test coverage, e.g. for people like
me who do not even know how to self-compile Shim, how to setup user
space using the product and so forth.
Those are the steps I use for building. I then move over mmx64.efi and
shimx64.efi to the ESP. I can add the shim build/install instructions to the next
cover letter If you think that would be appropriate.
Does shim have the necessary features in a release?
Hi!
It has been accepted in the upstream shim. If you are looking
for a distribution having rolled out a shim with this feature (so signed
by MSF) I fear that distributions are not that fast with shim releases.
Yes. I'll hold with this up until there is an official release. Thank you.
Not sure I understand - but what are the concerns you have with shim
code that has been accepted?
Maybe my concern is that none of the patches have a tested-by?
Probably would be easier to get a test coverage, e.g. for people like
me who do not even know how to self-compile Shim, how to setup user
space using the product and so forth.
Those are the steps I use for building. I then move over mmx64.efi and
shimx64.efi to the ESP. I can add the shim build/install instructions to the next
cover letter If you think that would be appropriate.
Yeah, that would be great. I'll try to setup VM for that purpose. I have
already a script to build UEFI enabled archlinux VM's, which I use to
test SGX patches. I can probably tailor that for this purpose.
/Jarkko
Hi Eric,
Is the subject line left over from the original patch? Shouldn't it
be "link machine trusted keys to secondary_trusted_keys".
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
quoted hunk
Allow the .machine keyring to be linked to the secondary_trusted_keys.
After the link is created, keys contained in the .machine keyring will
automatically be searched when searching secondary_trusted_keys.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v3: Initial version
v4: Unmodified from v3
v5: Rename to machine keyring
v7: Unmodified from v5
---
certs/system_keyring.c | 3 +++
1 file changed, 3 insertions(+)
In general is the ordering of the patches "bisect safe"[1]? Only in
the next patch is machine_trusted_keys set. In this case, either
merge the two patches or reverse their order.
thanks,
Mimi
[1] Refer to the section "Separate your changes" in
Documentation/process/submitting-patches.rst.
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-18 21:38:01
On Nov 18, 2021, at 5:32 AM, Mimi Zohar [off-list ref] wrote:
Hi Eric,
Is the subject line left over from the original patch? Shouldn't it
be "link machine trusted keys to secondary_trusted_keys".
Yes, you are right, this was left over from the original patch. I’ll update
the heading in the next round.
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
quoted
Allow the .machine keyring to be linked to the secondary_trusted_keys.
After the link is created, keys contained in the .machine keyring will
automatically be searched when searching secondary_trusted_keys.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v3: Initial version
v4: Unmodified from v3
v5: Rename to machine keyring
v7: Unmodified from v5
---
certs/system_keyring.c | 3 +++
1 file changed, 3 insertions(+)
In general is the ordering of the patches "bisect safe"[1]? Only in
the next patch is machine_trusted_keys set. In this case, either
merge the two patches or reverse their order.
I’ll also reverse the ordering in the next round too. Thanks.
Hi Eric,
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
quoted hunk
Parse the X.509 Basic Constraints. The basic constraints extension
identifies whether the subject of the certificate is a CA.
BasicConstraints ::= SEQUENCE {
cA BOOLEAN DEFAULT FALSE,
pathLenConstraint INTEGER (0..MAX) OPTIONAL }
If the CA is true, store it in a new public_key field call key_is_ca.
This will be used in a follow on patch that requires knowing if the
public key is a CA.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v7: Initial version
---
crypto/asymmetric_keys/x509_cert_parser.c | 9 +++++++++
include/crypto/public_key.h | 1 +
2 files changed, 10 insertions(+)
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-18 23:30:13
On Nov 18, 2021, at 3:59 PM, Mimi Zohar [off-list ref] wrote:
Hi Eric,
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
quoted
Parse the X.509 Basic Constraints. The basic constraints extension
identifies whether the subject of the certificate is a CA.
BasicConstraints ::= SEQUENCE {
cA BOOLEAN DEFAULT FALSE,
pathLenConstraint INTEGER (0..MAX) OPTIONAL }
If the CA is true, store it in a new public_key field call key_is_ca.
This will be used in a follow on patch that requires knowing if the
public key is a CA.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v7: Initial version
---
crypto/asymmetric_keys/x509_cert_parser.c | 9 +++++++++
include/crypto/public_key.h | 1 +
2 files changed, 10 insertions(+)
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
Currently both Secure Boot DB and Machine Owner Keys (MOK) go through
the same keyring handler (get_handler_for_db). With the addition of the
new machine keyring, the end-user may choose to trust MOK keys.
Introduce a new keyring handler specific for MOK keys. If MOK keys are
trusted by the end-user, use the new keyring handler instead.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Hi Eric,
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
To improve clarity, rename get_builtin_and_secondary_restriction to
get_secondary_restriction.
The existing name clarity is fine. Perhaps instead prefix the above
sentence with "In preparation for returning either the existing
restrict_link_by_builtin_and_secondary_trusted or the new restriction
that includes the trusted builtin, secondary and machine keys, ..."
Suggested-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Hi Eric,
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
quoted hunk
Introduce a new link restriction that includes the trusted builtin,
secondary and machine keys. The restriction is based on the key to be
added being vouched for by a key in any of these three keyrings.
Suggested-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v3: Initial version
v4: moved code under CONFIG_INTEGRITY_MOK_KEYRING
v5: Rename to machine keyring
v6: Change subject name (suggested by Mimi)
Rename restrict_link_by_builtin_secondary_and_ca_trusted
to restrict_link_by_builtin_secondary_and_machine (suggested by
Mimi)
v7: Unmodified from v6
---
certs/system_keyring.c | 23 +++++++++++++++++++++++
include/keys/system_keyring.h | 6 ++++++
2 files changed, 29 insertions(+)
Missing are the parameter defintions. Please refer to
Documentation/doc-guide/kernel-doc.rst for details.
Mimi
quoted hunk
+ *
+ * Restrict the addition of keys into a keyring based on the key-to-be-added
+ * being vouched for by a key in either the built-in, the secondary, or
+ * the machine keyrings.
+ */
+int restrict_link_by_builtin_secondary_and_machine(
+ struct key *dest_keyring,
+ const struct key_type *type,
+ const union key_payload *payload,
+ struct key *restrict_key)
+{
+ if (machine_trusted_keys && type == &key_type_keyring &&
+ dest_keyring == secondary_trusted_keys &&
+ payload == &machine_trusted_keys->payload)
+ /* Allow the machine keyring to be added to the secondary */
+ return 0;
+
+ return restrict_link_by_builtin_and_secondary_trusted(dest_keyring, type,
+ payload, restrict_key);
+}
#endif
/*
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
With the introduction of the machine keyring, the end-user may choose to
trust Machine Owner Keys (MOK) within the kernel. If they have chosen to
trust them, the .machine keyring will contain these keys. If not, the
machine keyring will always be empty. Update the restriction check to
allow the secondary trusted keyring and ima keyring to also trust
machine keys.
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
From: Eric Snowberg <eric.snowberg@oracle.com> Date: 2021-11-19 02:53:28
On Nov 18, 2021, at 5:20 PM, Mimi Zohar [off-list ref] wrote:
Hi Eric,
On Mon, 2021-11-15 at 19:15 -0500, Eric Snowberg wrote:
quoted
Introduce a new link restriction that includes the trusted builtin,
secondary and machine keys. The restriction is based on the key to be
added being vouched for by a key in any of these three keyrings.
Suggested-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
v3: Initial version
v4: moved code under CONFIG_INTEGRITY_MOK_KEYRING
v5: Rename to machine keyring
v6: Change subject name (suggested by Mimi)
Rename restrict_link_by_builtin_secondary_and_ca_trusted
to restrict_link_by_builtin_secondary_and_machine (suggested by
Mimi)
v7: Unmodified from v6
---
certs/system_keyring.c | 23 +++++++++++++++++++++++
include/keys/system_keyring.h | 6 ++++++
2 files changed, 29 insertions(+)