Enroll kernel keys thru MOK
Subsystems (7)
Eric Snowberg
reviewerv9 cover Enroll kernel keys thru MOK
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.
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.
Unlike previous versions of this patch set, IMA support has been removed to simplify the series. After acceptance, a follow-on series will add IMA support.
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].
Upstream shim is located here [7], the build instructions are here [8]. TLDR:
$ git clone --recurse-submodules https://github.com/rhboot/shim $ cd shim $ make
After building shim, move shimx64.efi and mmx64.efi to the vendor or distribution specific directory on your EFI System Partition (assuming you are building on x86). The instructions above are the minimal steps needed to build shim to test this feature. It is assumed Secure Boot shall not be enabled for this testing. To do testing with Secure Boot enabled, all steps in the build instructions [8] must be followed.
Instructions for building mokutil (including the new changes):
$ git clone -b mokvars-v3 https://github.com/esnowberg/mokutil.git $ cd mokutil/ $ ./autogen.sh $ make
[1] https://marc.info/?l=linux-kernel&m=136185386310140&w=2
[2] https://lore.kernel.org/lkml/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/
[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
[7] https://github.com/rhboot/shim
[8] https://github.com/rhboot/shim/blob/main/BUILDING
Eric Snowberg (8):
integrity: Fix warning about missing prototypes
integrity: Introduce a Linux keyring called machine
integrity: add new keyring handler for mok keys
KEYS: store reference to machine keyring
KEYS: Introduce link restriction for machine keys 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 ++++++++++- drivers/firmware/efi/mokvar-table.c | 2 +- include/keys/system_keyring.h | 14 ++++ security/integrity/Kconfig | 13 ++++ security/integrity/Makefile | 1 + security/integrity/digsig.c | 15 +++- 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 +++++++++++++++++++ 11 files changed, 202 insertions(+), 8 deletions(-) create mode 100644 security/integrity/platform_certs/machine_keyring.c
base-commit: c9e6606c7fe92b50a02ce51dda82586ebdf99b48
Signature · 1 line
2.18.4
Eric Snowberg
reviewerPATCH v9 1/8 integrity: Fix warning about missing prototypes
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.
---
v7: Initial version
v8: Code unmodified from v7 added Mimi's Reviewed-by
v9: Unmodified from v8
--- security/integrity/platform_certs/keyring_handler.c | 1 + 1 file changed, 1 insertion(+)
security/integrity/platform_certs/keyring_handler.c +1 -0
@@ -9,6 +9,7 @@#include <keys/asymmetric-type.h> #include <keys/system_keyring.h> #include "../integrity.h" +#include "keyring_handler.h" static efi_guid_t efi_cert_x509_guid__initdata =EFI_CERT_X509_GUID ; static efi_guid_t efi_cert_x509_sha256_guid __initdata =
Signature · 1 line
2.18.4
Re: [PATCH v9 1/8] integrity: Fix warning about missing prototypes
Quoted 36 lines · Eric Snowberg
make W=1 generates the following warning in
keyring_handler.c
security/integrity/platform_certs/keyring_handler.c:71:30: warning: no previous prototype forget_handler_for_db[-Wmissing-prototypes]
__initefi_element_handler_tget_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.Reported-by kernel test robot <[email protected]>Signed-off-by Eric Snowberg <[email protected]>Reviewed-by Mimi Zohar <[email protected]>---
v7: Initial version
v8: Code unmodified from v7 added Mimi's Reviewed-by
v9: Unmodified from v8--- security/integrity/platform_certs/keyring_handler.c | 1 + 1 file changed, 1 insertion(+)security/integrity/platform_certs/keyring_handler.c +1
-0@@ -9,6 +9,7 @@#include <keys/asymmetric-type.h> #include <keys/system_keyring.h> #include "../integrity.h" +#include "keyring_handler.h" static efi_guid_t efi_cert_x509_guid__initdata =EFI_CERT_X509_GUID ; static efi_guid_t efi_cert_x509_sha256_guid __initdata =Signature · 1 line
2.18.4
BR, Jarkko
Eric Snowberg
reviewerPATCH v9 2/8 integrity: Introduce a Linux keyring called machine
In reply to Eric SnowbergMany 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.
---
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
v8: Code unmodified from v7 added Mimi's Reviewed-by
v9: Removed Reviewed-by. Prevent IMA from being able to
use the machine keyring since the CA restrictions have been removed.
--- security/integrity/Kconfig | 13 ++++++ security/integrity/Makefile | 1 + security/integrity/digsig.c | 13 +++++- security/integrity/integrity.h | 12 +++++- .../platform_certs/machine_keyring.c | 42 +++++++++++++++++++ 5 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 security/integrity/platform_certs/machine_keyring.c
security/integrity/Kconfig +13 -0
@@ -62,6 +62,19 @@ config INTEGRITY_PLATFORM_KEYRING provided by the platform for verifying the kexec'ed kerned image and, possibly, the initramfs signature. +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 SYSTEM_BLACKLIST_KEYRING + depends on LOAD_UEFI_KEYS + depends on !IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY + help + If set, provide a keyring to which CA Machine Owner Keys (MOK) may + be added. This keyring shall contain just CA MOK keys. Unlike keys + in the platform keyring, keys contained in the .machine keyring will + be trusted within the kernel. + config LOAD_UEFI_KEYS depends on INTEGRITY_PLATFORM_KEYRING depends on EFI
security/integrity/Makefile +1 -0
@@ -10,6 +10,7 @@ integrity-$(CONFIG_INTEGRITY_AUDIT) += integrity_audit.o integrity-$(CONFIG_INTEGRITY_SIGNATURE) += digsig.o integrity-$(CONFIG_INTEGRITY_ASYMMETRIC_KEYS) += digsig_asymmetric.o integrity-$(CONFIG_INTEGRITY_PLATFORM_KEYRING) += platform_certs/platform_keyring.o +integrity-$(CONFIG_INTEGRITY_MACHINE_KEYRING) += platform_certs/machine_keyring.o integrity-$(CONFIG_LOAD_UEFI_KEYS) += platform_certs/efi_parser.o \ platform_certs/load_uefi.o \ platform_certs/keyring_handler.o
security/integrity/digsig.c +11 -2
@@ -30,6 +30,7 @@ static const char * const keyring_name[INTEGRITY_KEYRING_MAX] = {".ima" , #endif".platform" , + ".machine", };#ifdef CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY
@@ -126,7 +127,8 @@ int __init integrity_init_keyring(const unsigned int id) perm = (KEY_POS_ALL & ~KEY_POS_SETATTR ) |KEY_USR_VIEW |KEY_USR_READ |KEY_USR_SEARCH ; -if (id ==INTEGRITY_KEYRING_PLATFORM ) { +if (id ==INTEGRITY_KEYRING_PLATFORM || + id ==INTEGRITY_KEYRING_MACHINE ) { restriction =NULL ; goto out; }
@@ -139,7 +141,14 @@ int __init integrity_init_keyring(const unsigned int id)return -ENOMEM ; restriction->check = restrict_link_to_ima; - perm |=KEY_USR_WRITE ; + +/* +* MOK keys can only be added through a read-only runtime services +* UEFI variable during boot. No additional keys shall be allowed to +* load into the machine keyring following init from userspace. +*/ +if (id !=INTEGRITY_KEYRING_MACHINE ) + perm |=KEY_USR_WRITE ; out:return __integrity_init_keyring (id, perm, restriction);
security/integrity/integrity.h +11 -1
@@ -151,7 +151,8 @@ int integrity_kernel_read(struct file *file, loff_t offset,#define INTEGRITY_KEYRING_EVM 0#define INTEGRITY_KEYRING_IMA 1#define INTEGRITY_KEYRING_PLATFORM 2 -#define INTEGRITY_KEYRING_MAX 3 +#define INTEGRITY_KEYRING_MACHINE 3 +#define INTEGRITY_KEYRING_MAX 4extern struct dentry *integrity_dir;
@@ -283,3 +284,12 @@ static inline void __init add_to_platform_keyring(const char *source, { }#endif + +#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +void __init add_to_machine_keyring (const char *source,const void *data,size_t len); +#else +static inline void __init add_to_machine_keyring (const char *source, +const void *data,size_t len) +{ +} +#endif
security/integrity/platform_certs/machine_keyring.c new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.18.4
Mimi Zohar
maintainerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 8 lines · Eric Snowberg
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.
Quoted 5 lines
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.
True, from an IMA perspective only the CA keys should be loaded onto the .machine keyring, but this version (v9) of the patch set does not enforce that. The patch set and this paragraph are out of sync.
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
thanks,
Mimi
Quoted 16 lines
Signed-off-by Eric Snowberg <[email protected]>---
v1: Initial version
v2: Removed destory keyring code
v3: Unmodified from v2
v4: AddKconfig, merged in "integrity: addadd_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 onLOAD_UEFI_KEYSinstead EFI for mokvar code
v8: Code unmodified from v7 added Mimi's Reviewed-by
v9: Removed Reviewed-by. Prevent IMA from being able to
use the machine keyring since the CA restrictions have been removed.
Eric Snowberg
reviewerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 19 lines · Mimi Zohar
Quoted 8 lines · Eric Snowberg
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.
Quoted 5 lines
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.
Quoted 3 lines
True, from an IMA perspective only the CA keys should be loaded onto the .machine keyring, but this version (v9) of the patch set does not enforce that. The patch set and this paragraph are out of sync.
I missed that when I dropped IMA support. I will strike that sentence in the next round. Or if no code changes are identified, feel free to remove that sentence.
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
My thinking for the dropped CA restriction patches was to introduce a new Kconfig. This Kconfig would do the CA enforcement on the machine keyring. However if the Kconfig option was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.
Mimi Zohar
maintainerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 9 lines · Eric Snowberg
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
Quoted 7 lines
My thinking for the dropped CA restriction patches was to introduce a new
Kconfig. ThisKconfigwould do the CA enforcement on the machine keyring. However if theKconfigoption was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.
True the problem currently exists with the builtin keys, but there's a major difference between trusting the builtin keys and those being loading via MOK. This is an integrity gap that needs to be closed and shouldn't be expanded to keys on the .machine keyring.
"plus it would allow IMA to work with non-CA keys" is unacceptable.
Mimi
Eric Snowberg
reviewerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 22 lines · Mimi Zohar
Quoted 9 lines · Eric Snowberg
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
Quoted 7 lines
My thinking for the dropped CA restriction patches was to introduce a new
Kconfig. ThisKconfigwould do the CA enforcement on the machine keyring. However if theKconfigoption was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.
Quoted 6 lines
True the problem currently exists with the builtin keys, but there's a major difference between trusting the builtin keys and those being loading via MOK. This is an integrity gap that needs to be closed and shouldn't be expanded to keys on the .machine keyring.
"plus it would allow IMA to work with non-CA keys" is unacceptable.
Ok, I’ll leave that part out. Could you clarify the wording I should include in the future cover letter, which adds IMA support, on why it is unacceptable for the end-user to make this decision?
Mimi Zohar
maintainerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 26 lines · Eric Snowberg
Quoted 26 lines · Mimi Zohar
Quoted 9 lines · Eric Snowberg
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
Quoted 7 lines
My thinking for the dropped CA restriction patches was to introduce a new
Kconfig. ThisKconfigwould do the CA enforcement on the machine keyring. However if theKconfigoption was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.True the problem currently exists with the builtin keys, but there's a major difference between trusting the builtin keys and those being loading via MOK. This is an integrity gap that needs to be closed and shouldn't be expanded to keys on the .machine keyring.
Quoted 5 lines
Quoted 1 line
"plus it would allow IMA to work with non-CA keys" is unacceptable.
Ok, I’ll leave that part out. Could you clarify the wording I should include in the future cover letter, which adds IMA support, on why it is unacceptable for the end-user to make this decision?
The Kconfig IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY "help" is very clear:
help
Keys may be added to the IMA or IMA blacklist keyrings, if
the
key is validly signed by a CA cert in the system built-in or secondary trusted keyrings.
Intermediate keys between those the kernel has compiled in
and the
IMA keys to be added may be added to the system secondary
keyring,
provided they are validly signed by a key already resident in
the
built-in or secondary trusted keyrings.
Mimi
Mimi Zohar
maintainerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 27 lines · Mimi Zohar
Quoted 26 lines · Eric Snowberg
Quoted 26 lines · Mimi Zohar
Quoted 9 lines · Eric Snowberg
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
Quoted 7 lines
My thinking for the dropped CA restriction patches was to introduce a new
Kconfig. ThisKconfigwould do the CA enforcement on the machine keyring. However if theKconfigoption was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.True the problem currently exists with the builtin keys, but there's a major difference between trusting the builtin keys and those being loading via MOK. This is an integrity gap that needs to be closed and shouldn't be expanded to keys on the .machine keyring.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
"plus it would allow IMA to work with non-CA keys" is unacceptable.
Ok, I’ll leave that part out. Could you clarify the wording I should include in the future cover letter, which adds IMA support, on why it is unacceptable for the end-user to make this decision?
The
KconfigIMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY"help" is very clear:
[Reposting the text due to email formatting issues.]
help
Keys may be added to the IMA or IMA blacklist keyrings, if the key is validly signed by a CA cert in the system built-in or secondary trusted keyrings.
Intermediate keys between those the kernel has compiled in and the IMA keys to be added may be added to the system secondary keyring, provided they are validly signed by a key already resident in the built-in or secondary trusted keyrings.
The first paragraph requires "validly signed by a CA cert in the system built-in or secondary trusted keyrings" for keys to be loaded onto the IMA keyring. This Kconfig is limited to just the builtin and secondary keyrings. Changing this silently to include the ".machine" keyring introduces integrity risks that previously did not exist. A new IMA Kconfig needs to be defined to allow all three keyrings - builtin, machine, and secondary.
The second paragraph implies that only CA and intermediate CA keys are on secondary keyring, or as in our case the ".machine" keyring linked to the secondary keyring.
Mimi
Jarkko Sakkinen
maintainerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 58 lines · Mimi Zohar
Quoted 27 lines · Mimi Zohar
Quoted 26 lines · Eric Snowberg
Quoted 26 lines · Mimi Zohar
Quoted 9 lines · Eric Snowberg
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
Quoted 7 lines
My thinking for the dropped CA restriction patches was to introduce a new
Kconfig. ThisKconfigwould do the CA enforcement on the machine keyring. However if theKconfigoption was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.True the problem currently exists with the builtin keys, but there's a major difference between trusting the builtin keys and those being loading via MOK. This is an integrity gap that needs to be closed and shouldn't be expanded to keys on the .machine keyring.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
"plus it would allow IMA to work with non-CA keys" is unacceptable.
Ok, I’ll leave that part out. Could you clarify the wording I should include in the future cover letter, which adds IMA support, on why it is unacceptable for the end-user to make this decision?
The
KconfigIMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY"help" is very clear:[Reposting the text due to email formatting issues.]
help
Keys may be added to the IMA or IMA blacklist keyrings, if the key is validly signed by a CA cert in the system built-in or secondary trusted keyrings.Intermediate keys between those the kernel has compiled in and the IMA keys to be added may be added to the system secondary keyring, provided they are validly signed by a key already resident in the built-in or secondary trusted keyrings.
The first paragraph requires "validly signed by a CA cert in the system built-in or secondary trusted keyrings" for keys to be loaded onto the IMA keyring. This
Kconfigis limited to just the builtin and secondary keyrings. Changing this silently to include the ".machine" keyring introduces integrity risks that previously did not exist. A new IMAKconfigneeds to be defined to allow all three keyrings - builtin, machine, and secondary.
Quoted 6 lines
The second paragraph implies that only CA and intermediate CA keys are on secondary keyring, or as in our case the ".machine" keyring linked to the secondary keyring.
Mimi
I have also now test environment for this patch set but if there are any possible changes, I'm waiting for a new version, as it is anyway for 5.18 cycle earliest.
/Jarkko
Eric Snowberg
reviewerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 67 lines · Jarkko Sakkinen
Quoted 62 lines · Mimi Zohar
Quoted 27 lines · Mimi Zohar
Quoted 26 lines · Eric Snowberg
Quoted 26 lines · Mimi Zohar
Quoted 9 lines · Eric Snowberg
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
Quoted 7 lines
My thinking for the dropped CA restriction patches was to introduce a new
Kconfig. ThisKconfigwould do the CA enforcement on the machine keyring. However if theKconfigoption was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.True the problem currently exists with the builtin keys, but there's a major difference between trusting the builtin keys and those being loading via MOK. This is an integrity gap that needs to be closed and shouldn't be expanded to keys on the .machine keyring.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
"plus it would allow IMA to work with non-CA keys" is unacceptable.
Ok, I’ll leave that part out. Could you clarify the wording I should include in the future cover letter, which adds IMA support, on why it is unacceptable for the end-user to make this decision?
The
KconfigIMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY"help" is very clear:[Reposting the text due to email formatting issues.]
help
Keys may be added to the IMA or IMA blacklist keyrings, if the key is validly signed by a CA cert in the system built-in or secondary trusted keyrings.Intermediate keys between those the kernel has compiled in and the IMA keys to be added may be added to the system secondary keyring, provided they are validly signed by a key already resident in the built-in or secondary trusted keyrings.
The first paragraph requires "validly signed by a CA cert in the system built-in or secondary trusted keyrings" for keys to be loaded onto the IMA keyring. This
Kconfigis limited to just the builtin and secondary keyrings. Changing this silently to include the ".machine" keyring introduces integrity risks that previously did not exist. A new IMAKconfigneeds to be defined to allow all three keyrings - builtin, machine, and secondary.The second paragraph implies that only CA and intermediate CA keys are on secondary keyring, or as in our case the ".machine" keyring linked to the secondary keyring.
Quoted 5 lines
Quoted 2 lines
Mimi
I have also now test environment for this patch set but if there are any possible changes, I'm waiting for a new version, as it is anyway for 5.18 cycle earliest.
Other than the two sentence changes, I have not seen anything identified code wise requiring a change. If you’d like me to respin a v10 with the sentence changes let me know. Or if you want to remove the ima reference, that works too. Just let me know how you want to handle this. Thanks.
Re: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 69 lines · Eric Snowberg
Quoted 69 lines · Jarkko Sakkinen
Quoted 64 lines · Mimi Zohar
Quoted 27 lines · Mimi Zohar
Quoted 26 lines · Eric Snowberg
Quoted 26 lines · Mimi Zohar
Quoted 9 lines · Eric Snowberg
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
Quoted 7 lines
My thinking for the dropped CA restriction patches was to introduce a new
Kconfig. ThisKconfigwould do the CA enforcement on the machine keyring. However if theKconfigoption was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.True the problem currently exists with the builtin keys, but there's a major difference between trusting the builtin keys and those being loading via MOK. This is an integrity gap that needs to be closed and shouldn't be expanded to keys on the .machine keyring.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
"plus it would allow IMA to work with non-CA keys" is unacceptable.
Ok, I’ll leave that part out. Could you clarify the wording I should include in the future cover letter, which adds IMA support, on why it is unacceptable for the end-user to make this decision?
The
KconfigIMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY"help" is very clear:[Reposting the text due to email formatting issues.]
help
Keys may be added to the IMA or IMA blacklist keyrings, if the key is validly signed by a CA cert in the system built-in or secondary trusted keyrings.Intermediate keys between those the kernel has compiled in and the IMA keys to be added may be added to the system secondary keyring, provided they are validly signed by a key already resident in the built-in or secondary trusted keyrings.
The first paragraph requires "validly signed by a CA cert in the system built-in or secondary trusted keyrings" for keys to be loaded onto the IMA keyring. This
Kconfigis limited to just the builtin and secondary keyrings. Changing this silently to include the ".machine" keyring introduces integrity risks that previously did not exist. A new IMAKconfigneeds to be defined to allow all three keyrings - builtin, machine, and secondary.The second paragraph implies that only CA and intermediate CA keys are on secondary keyring, or as in our case the ".machine" keyring linked to the secondary keyring.
Mimi
Quoted 8 lines
Quoted 3 lines
I have also now test environment for this patch set but if there are any possible changes, I'm waiting for a new version, as it is anyway for 5.18 cycle earliest.
Other than the two sentence changes, I have not seen anything identified code wise requiring a change. If you’d like me to respin a v10 with the sentence changes let me know. Or if you want to remove the ima reference, that works too. Just let me know how you want to handle this. Thanks.
I'm basically waiting also Mimi to test this as I do not have IMA test environment.
From my side:
/Jarkko
Jarkko Sakkinen
maintainerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 79 lines · Jarkko Sakkinen
Quoted 69 lines · Eric Snowberg
Quoted 69 lines · Jarkko Sakkinen
Quoted 64 lines · Mimi Zohar
Quoted 27 lines · Mimi Zohar
Quoted 26 lines · Eric Snowberg
Quoted 26 lines · Mimi Zohar
Quoted 9 lines · Eric Snowberg
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
Quoted 7 lines
My thinking for the dropped CA restriction patches was to introduce a new
Kconfig. ThisKconfigwould do the CA enforcement on the machine keyring. However if theKconfigoption was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.True the problem currently exists with the builtin keys, but there's a major difference between trusting the builtin keys and those being loading via MOK. This is an integrity gap that needs to be closed and shouldn't be expanded to keys on the .machine keyring.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
"plus it would allow IMA to work with non-CA keys" is unacceptable.
Ok, I’ll leave that part out. Could you clarify the wording I should include in the future cover letter, which adds IMA support, on why it is unacceptable for the end-user to make this decision?
The
KconfigIMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY"help" is very clear:[Reposting the text due to email formatting issues.]
help
Keys may be added to the IMA or IMA blacklist keyrings, if the key is validly signed by a CA cert in the system built-in or secondary trusted keyrings.Intermediate keys between those the kernel has compiled in and the IMA keys to be added may be added to the system secondary keyring, provided they are validly signed by a key already resident in the built-in or secondary trusted keyrings.
The first paragraph requires "validly signed by a CA cert in the system built-in or secondary trusted keyrings" for keys to be loaded onto the IMA keyring. This
Kconfigis limited to just the builtin and secondary keyrings. Changing this silently to include the ".machine" keyring introduces integrity risks that previously did not exist. A new IMAKconfigneeds to be defined to allow all three keyrings - builtin, machine, and secondary.The second paragraph implies that only CA and intermediate CA keys are on secondary keyring, or as in our case the ".machine" keyring linked to the secondary keyring.
Mimi
Quoted 8 lines
Quoted 3 lines
I have also now test environment for this patch set but if there are any possible changes, I'm waiting for a new version, as it is anyway for 5.18 cycle earliest.
Other than the two sentence changes, I have not seen anything identified code wise requiring a change. If you’d like me to respin a v10 with the sentence changes let me know. Or if you want to remove the ima reference, that works too. Just let me know how you want to handle this. Thanks.
Quoted 6 lines
I'm basically waiting also Mimi to test this as I do not have IMA test environment.
From my side:
Tested-by Jarkko Sakkinen <[email protected]>
I can pick the whole thing at the time when I get green light.
/Jarkko
Mimi Zohar
maintainerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 80 lines · Jarkko Sakkinen
Quoted 79 lines · Jarkko Sakkinen
Quoted 77 lines · Eric Snowberg
Quoted 67 lines · Jarkko Sakkinen
Quoted 62 lines · Mimi Zohar
Quoted 27 lines · Mimi Zohar
Quoted 26 lines · Eric Snowberg
Quoted 26 lines · Mimi Zohar
Quoted 9 lines · Eric Snowberg
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
Quoted 7 lines
My thinking for the dropped CA restriction patches was to introduce a new
Kconfig. ThisKconfigwould do the CA enforcement on the machine keyring. However if theKconfigoption was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.True the problem currently exists with the builtin keys, but there's a major difference between trusting the builtin keys and those being loading via MOK. This is an integrity gap that needs to be closed and shouldn't be expanded to keys on the .machine keyring.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
"plus it would allow IMA to work with non-CA keys" is unacceptable.
Ok, I’ll leave that part out. Could you clarify the wording I should include in the future cover letter, which adds IMA support, on why it is unacceptable for the end-user to make this decision?
The
KconfigIMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY"help" is very clear:[Reposting the text due to email formatting issues.]
help
Keys may be added to the IMA or IMA blacklist keyrings, if the key is validly signed by a CA cert in the system built-in or secondary trusted keyrings.Intermediate keys between those the kernel has compiled in and the IMA keys to be added may be added to the system secondary keyring, provided they are validly signed by a key already resident in the built-in or secondary trusted keyrings.
The first paragraph requires "validly signed by a CA cert in the system built-in or secondary trusted keyrings" for keys to be loaded onto the IMA keyring. This
Kconfigis limited to just the builtin and secondary keyrings. Changing this silently to include the ".machine" keyring introduces integrity risks that previously did not exist. A new IMAKconfigneeds to be defined to allow all three keyrings - builtin, machine, and secondary.The second paragraph implies that only CA and intermediate CA keys are on secondary keyring, or as in our case the ".machine" keyring linked to the secondary keyring.
Quoted 5 lines
Quoted 2 lines
Mimi
I have also now test environment for this patch set but if there are any possible changes, I'm waiting for a new version, as it is anyway for 5.18 cycle earliest.
Other than the two sentence changes, I have not seen anything identified code wise requiring a change. If you’d like me to respin a v10 with the sentence changes let me know. Or if you want to remove the ima reference, that works too. Just let me know how you want to handle this. Thanks.
Quoted 8 lines
Quoted 6 lines
I'm basically waiting also Mimi to test this as I do not have IMA test environment.
From my side:
Tested-by Jarkko Sakkinen <[email protected]>I can pick the whole thing at the time when I get green light.
The MOK keys are not loaded onto the .machine keyring if CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY is enabled. From an IMA perspective nothing has changed.
After the IMA references in the patch descriptions are removed, feel free to add Tested-by: Mimi Zohar <[email protected]> on patches 1 - 5.
thanks,
Mimi
Jarkko Sakkinen
maintainerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 94 lines · Mimi Zohar
Quoted 80 lines · Jarkko Sakkinen
Quoted 79 lines · Jarkko Sakkinen
Quoted 77 lines · Eric Snowberg
Quoted 67 lines · Jarkko Sakkinen
Quoted 62 lines · Mimi Zohar
Quoted 27 lines · Mimi Zohar
Quoted 26 lines · Eric Snowberg
Quoted 26 lines · Mimi Zohar
Quoted 9 lines · Eric Snowberg
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
Quoted 7 lines
My thinking for the dropped CA restriction patches was to introduce a new
Kconfig. ThisKconfigwould do the CA enforcement on the machine keyring. However if theKconfigoption was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.True the problem currently exists with the builtin keys, but there's a major difference between trusting the builtin keys and those being loading via MOK. This is an integrity gap that needs to be closed and shouldn't be expanded to keys on the .machine keyring.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
"plus it would allow IMA to work with non-CA keys" is unacceptable.
Ok, I’ll leave that part out. Could you clarify the wording I should include in the future cover letter, which adds IMA support, on why it is unacceptable for the end-user to make this decision?
The
KconfigIMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY"help" is very clear:[Reposting the text due to email formatting issues.]
help
Keys may be added to the IMA or IMA blacklist keyrings, if the key is validly signed by a CA cert in the system built-in or secondary trusted keyrings.Intermediate keys between those the kernel has compiled in and the IMA keys to be added may be added to the system secondary keyring, provided they are validly signed by a key already resident in the built-in or secondary trusted keyrings.
The first paragraph requires "validly signed by a CA cert in the system built-in or secondary trusted keyrings" for keys to be loaded onto the IMA keyring. This
Kconfigis limited to just the builtin and secondary keyrings. Changing this silently to include the ".machine" keyring introduces integrity risks that previously did not exist. A new IMAKconfigneeds to be defined to allow all three keyrings - builtin, machine, and secondary.The second paragraph implies that only CA and intermediate CA keys are on secondary keyring, or as in our case the ".machine" keyring linked to the secondary keyring.
Quoted 5 lines
Quoted 2 lines
Mimi
I have also now test environment for this patch set but if there are any possible changes, I'm waiting for a new version, as it is anyway for 5.18 cycle earliest.
Other than the two sentence changes, I have not seen anything identified code wise requiring a change. If you’d like me to respin a v10 with the sentence changes let me know. Or if you want to remove the ima reference, that works too. Just let me know how you want to handle this. Thanks.
Quoted 8 lines
Quoted 6 lines
I'm basically waiting also Mimi to test this as I do not have IMA test environment.
From my side:
Tested-by Jarkko Sakkinen <[email protected]>I can pick the whole thing at the time when I get green light.
The MOK keys are not loaded onto the .machine keyring if
CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARYis enabled. From an IMA perspective nothing has changed.
Quoted 7 lines
After the IMA references in the patch descriptions are removed, feel free to add Tested-by: Mimi Zohar <[email protected]> on patches 1 - 5.
thanks,
Mimi
Eric, for me it would be at least a convenience, and overally it would make sure that I pick the right thing if you would fix the typos (and you can add all the tested-by tags of course as no functional changes).
There's been times when I've manually "just fixed typos", and failed in a way or another because of human error. Just want to make sure that we have exactly the right content applied, I hope you understand my point of view. And we are early for the 5.18 release cycle anyway.
BR, Jarkko
Eric Snowberg
reviewerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 107 lines · Jarkko Sakkinen
Quoted 94 lines · Mimi Zohar
Quoted 80 lines · Jarkko Sakkinen
Quoted 79 lines · Jarkko Sakkinen
Quoted 77 lines · Eric Snowberg
Quoted 67 lines · Jarkko Sakkinen
Quoted 62 lines · Mimi Zohar
Quoted 27 lines · Mimi Zohar
Quoted 26 lines · Eric Snowberg
Quoted 26 lines · Mimi Zohar
Quoted 9 lines · Eric Snowberg
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
Quoted 7 lines
My thinking for the dropped CA restriction patches was to introduce a new
Kconfig. ThisKconfigwould do the CA enforcement on the machine keyring. However if theKconfigoption was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.True the problem currently exists with the builtin keys, but there's a major difference between trusting the builtin keys and those being loading via MOK. This is an integrity gap that needs to be closed and shouldn't be expanded to keys on the .machine keyring.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
"plus it would allow IMA to work with non-CA keys" is unacceptable.
Ok, I’ll leave that part out. Could you clarify the wording I should include in the future cover letter, which adds IMA support, on why it is unacceptable for the end-user to make this decision?
The
KconfigIMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY"help" is very clear:[Reposting the text due to email formatting issues.]
help
Keys may be added to the IMA or IMA blacklist keyrings, if the key is validly signed by a CA cert in the system built-in or secondary trusted keyrings.Intermediate keys between those the kernel has compiled in and the IMA keys to be added may be added to the system secondary keyring, provided they are validly signed by a key already resident in the built-in or secondary trusted keyrings.
The first paragraph requires "validly signed by a CA cert in the system built-in or secondary trusted keyrings" for keys to be loaded onto the IMA keyring. This
Kconfigis limited to just the builtin and secondary keyrings. Changing this silently to include the ".machine" keyring introduces integrity risks that previously did not exist. A new IMAKconfigneeds to be defined to allow all three keyrings - builtin, machine, and secondary.The second paragraph implies that only CA and intermediate CA keys are on secondary keyring, or as in our case the ".machine" keyring linked to the secondary keyring.
Quoted 5 lines
Quoted 2 lines
Mimi
I have also now test environment for this patch set but if there are any possible changes, I'm waiting for a new version, as it is anyway for 5.18 cycle earliest.
Other than the two sentence changes, I have not seen anything identified code wise requiring a change. If you’d like me to respin a v10 with the sentence changes let me know. Or if you want to remove the ima reference, that works too. Just let me know how you want to handle this. Thanks.
Quoted 8 lines
Quoted 6 lines
I'm basically waiting also Mimi to test this as I do not have IMA test environment.
From my side:
Tested-by Jarkko Sakkinen <[email protected]>I can pick the whole thing at the time when I get green light.
The MOK keys are not loaded onto the .machine keyring if
CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARYis enabled. From an IMA perspective nothing has changed.Quoted 7 lines
After the IMA references in the patch descriptions are removed, feel free to add Tested-by: Mimi Zohar <[email protected]> on patches 1 - 5.
thanks,
Mimi
Quoted 8 lines
Eric, for me it would be at least a convenience, and overally it would make sure that I pick the right thing if you would fix the typos (and you can add all the tested-by tags of course as no functional changes).
There's been times when I've manually "just fixed typos", and failed in a way or another because of human error. Just want to make sure that we have exactly the right content applied, I hope you understand my point of view. And we are early for the 5.18 release cycle anyway.
No problem, I’ll put together a v10 with the changes. Thanks for your review.
Mimi Zohar
maintainerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
In reply to Mimi ZoharQuoted 27 lines · Mimi Zohar
Quoted 26 lines · Eric Snowberg
Quoted 26 lines · Mimi Zohar
Quoted 9 lines · Eric Snowberg
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
Quoted 7 lines
My thinking for the dropped CA restriction patches was to introduce a new
Kconfig. ThisKconfigwould do the CA enforcement on the machine keyring. However if theKconfigoption was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.True the problem currently exists with the builtin keys, but there's a major difference between trusting the builtin keys and those being loading via MOK. This is an integrity gap that needs to be closed and shouldn't be expanded to keys on the .machine keyring.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
"plus it would allow IMA to work with non-CA keys" is unacceptable.
Ok, I’ll leave that part out. Could you clarify the wording I should include in the future cover letter, which adds IMA support, on why it is unacceptable for the end-user to make this decision?
The
KconfigIMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY"help" is very clear:
[Reposting the text due to email formatting issues.]
help
Keys may be added to the IMA or IMA blacklist keyrings, if the key is validly signed by a CA cert in the system built-in or secondary trusted keyrings.
Intermediate keys between those the kernel has compiled in and the IMA keys to be added may be added to the system secondary keyring, provided they are validly signed by a key already resident in the built-in or secondary trusted keyrings.
The first paragraph requires "validly signed by a CA cert in the system built-in or secondary trusted keyrings" for keys to be loaded onto the IMA keyring. This Kconfig is limited to just the builtin and secondary keyrings. Changing this silently to include the ".machine" keyring introduces integrity risks that previously did not exist. A new IMA Kconfig needs to be defined to allow all three keyrings - builtin, machine, and secondary.
The second paragraph implies that only CA and intermediate CA keys are on secondary keyring, or as in our case the ".machine" keyring linked to the secondary keyring.
Mimi
Eric Snowberg
reviewerRe: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine
Quoted 62 lines · Mimi Zohar
Quoted 27 lines · Mimi Zohar
Quoted 26 lines · Eric Snowberg
Quoted 26 lines · Mimi Zohar
Quoted 9 lines · Eric Snowberg
Quoted 3 lines
Jarkko, my concern is that once this version of the patch set is upstreamed, would limiting which keys may be loaded onto the .machine keyring be considered a regression?
Currently certificates built into the kernel do not have a CA restriction on them. IMA will trust anything in this keyring even if the CA bit is not set. While it would be advisable for a kernel to be built with a CA, nothing currently enforces it.
Quoted 7 lines
My thinking for the dropped CA restriction patches was to introduce a new
Kconfig. ThisKconfigwould do the CA enforcement on the machine keyring. However if theKconfigoption was not set for enforcement, it would work as it does in this series, plus it would allow IMA to work with non-CA keys. This would be done by removing the restriction placed in this patch. Let me know your thoughts on whether this would be an appropriate solution. I believe this would get around what you are identifying as a possible regression.True the problem currently exists with the builtin keys, but there's a major difference between trusting the builtin keys and those being loading via MOK. This is an integrity gap that needs to be closed and shouldn't be expanded to keys on the .machine keyring.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
"plus it would allow IMA to work with non-CA keys" is unacceptable.
Ok, I’ll leave that part out. Could you clarify the wording I should include in the future cover letter, which adds IMA support, on why it is unacceptable for the end-user to make this decision?
The
KconfigIMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY"help" is very clear:[Reposting the text due to email formatting issues.]
help
Keys may be added to the IMA or IMA blacklist keyrings, if the key is validly signed by a CA cert in the system built-in or secondary trusted keyrings.Intermediate keys between those the kernel has compiled in and the IMA keys to be added may be added to the system secondary keyring, provided they are validly signed by a key already resident in the built-in or secondary trusted keyrings.
The first paragraph requires "validly signed by a CA cert in the system built-in or secondary trusted keyrings" for keys to be loaded onto the IMA keyring. This
Kconfigis limited to just the builtin and secondary keyrings. Changing this silently to include the ".machine" keyring introduces integrity risks that previously did not exist. A new IMAKconfigneeds to be defined to allow all three keyrings - builtin, machine, and secondary.
Quoted 3 lines
The second paragraph implies that only CA and intermediate CA keys are on secondary keyring, or as in our case the ".machine" keyring linked to the secondary keyring.
Got it, thanks. I’ll use this in the cover letter that introduces the CA restrictions to enable IMA.
Eric Snowberg
reviewerPATCH v9 3/8 integrity: add new keyring handler for mok keys
In reply to Eric SnowbergCurrently 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.
---
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
v8: Code unmodified from v7 added Mimi's Reviewed-by
v9: Unmodified from v8
--- .../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(-)
security/integrity/platform_certs/keyring_handler.c +16 -1
@@ -67,7 +67,7 @@ static __init void uefi_revocation_list_x509(const char *source,/* * Return the appropriate handler for particular signature list types found in -* the UEFI db and MokListRT tables. +* the UEFI db tables. */ __init efi_element_handler_t get_handler_for_db (const efi_guid_t *sig_type) {
@@ -76,6 +76,21 @@ __init efi_element_handler_t get_handler_for_db(const efi_guid_t *sig_type)return 0 ; } +/* +* Return the appropriate handler for particular signature list types found in +* the MokListRT tables. +*/ +__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 (IS_ENABLED (CONFIG_INTEGRITY_MACHINE_KEYRING )) +return add_to_machine_keyring; +else +return add_to_platform_keyring; + } +return 0 ; +} +/* * Return the appropriate handler for particular signature list types found in * the UEFI dbx and MokListXRT tables.
security/integrity/platform_certs/keyring_handler.h +5 -0
@@ -24,6 +24,11 @@ void blacklist_binary(const char *source, const void *data, size_t len);*/ efi_element_handler_t get_handler_for_db (const efi_guid_t *sig_type); +/* +* Return the handler for particular signature list types found in the mok. +*/ +efi_element_handler_t get_handler_for_mok (const efi_guid_t *sig_type); +/* * Return the handler for particular signature list types found in the dbx. */
security/integrity/platform_certs/load_uefi.c +2 -2
@@ -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)return rc;
@@ -109,7 +109,7 @@ static int __init load_moklist_certs(void) mok =get_cert_list (L"MokListRT" , &mok_var, &moksize, &status);if (mok) { rc =parse_efi_signature_list ("UEFI:MokListRT" , - mok, moksize, get_handler_for_db); + mok, moksize, get_handler_for_mok);kfree (mok);if (rc)pr_err ("Couldn't parse MokListRT signatures: %d\n" , rc);
Signature · 1 line
2.18.4
Re: [PATCH v9 3/8] integrity: add new keyring handler for mok keys
Quoted 99 lines · Eric Snowberg
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 <[email protected]>Reviewed-by Mimi Zohar <[email protected]>---
v1: Initial version
v3: Only change the keyring handler if the secondary is enabled
v4: Removedtrust_moklistcheck
v5: Rename to machine keyring
v7: Unmodified from v5
v8: Code unmodified from v7 added Mimi's Reviewed-by
v9: Unmodified from v8--- .../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(-)security/integrity/platform_certs/keyring_handler.c +16
-1@@ -67,7 +67,7 @@ static __init void uefi_revocation_list_x509(const char *source,/* * Return the appropriate handler for particular signature list types found in -* the UEFI db and MokListRT tables. +* the UEFI db tables. */ __init efi_element_handler_t get_handler_for_db (const efi_guid_t *sig_type) {@@ -76,6 +76,21 @@ __init efi_element_handler_t get_handler_for_db(const efi_guid_t *sig_type)return 0 ; } +/* +* Return the appropriate handler for particular signature list types found in +* the MokListRT tables. +*/ +__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 (IS_ENABLED (CONFIG_INTEGRITY_MACHINE_KEYRING )) +return add_to_machine_keyring; +else +return add_to_platform_keyring; + } +return 0 ; +} +/* * Return the appropriate handler for particular signature list types found in * the UEFI dbx and MokListXRT tables. security/integrity/platform_certs/keyring_handler.h +5
-0@@ -24,6 +24,11 @@ void blacklist_binary(const char *source, const void *data, size_t len);*/ efi_element_handler_t get_handler_for_db (const efi_guid_t *sig_type); +/* +* Return the handler for particular signature list types found in the mok. +*/ +efi_element_handler_t get_handler_for_mok (const efi_guid_t *sig_type); +/* * Return the handler for particular signature list types found in the dbx. */ security/integrity/platform_certs/load_uefi.c +2
-2@@ -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)return rc;@@ -109,7 +109,7 @@ static int __init load_moklist_certs(void) mok =get_cert_list (L"MokListRT" , &mok_var, &moksize, &status);if (mok) { rc =parse_efi_signature_list ("UEFI:MokListRT" , - mok, moksize, get_handler_for_db); + mok, moksize, get_handler_for_mok);kfree (mok);if (rc)pr_err ("Couldn't parse MokListRT signatures: %d\n" , rc);Signature · 1 line
2.18.4
/Jarkko
Eric Snowberg
reviewerPATCH v9 4/8 KEYS: store reference to machine keyring
In reply to Eric SnowbergExpose the .machine keyring created in integrity code by adding a reference. Store a reference to the machine keyring in system keyring code. The system keyring code needs this to complete the keyring link to the machine keyring.
---
v2: Initial version
v3: Unmodified from v2
v4: Removed trust_moklist check
v5: Rename to machine keyring
v8: Unmodified from v5
v9: Combine with "add reference to machine keyring" patch
--- certs/system_keyring.c | 9 +++++++++ include/keys/system_keyring.h | 8 ++++++++ security/integrity/digsig.c | 2 ++ 3 files changed, 19 insertions(+)
certs/system_keyring.c +9 -0
@@ -22,6 +22,9 @@ static struct key *builtin_trusted_keys;#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING static struct key *secondary_trusted_keys;#endif +#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +static struct key *machine_trusted_keys; +#endif #ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING static struct key *platform_trusted_keys;#endif
@@ -91,6 +94,12 @@ static __init struct key_restriction *get_builtin_and_secondary_restriction(void return restriction; }#endif +#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +void __init set_machine_trusted_keys (struct key *keyring) +{ + machine_trusted_keys = keyring; +} +#endif /* * Create the trusted keyrings
include/keys/system_keyring.h +8 -0
@@ -38,6 +38,14 @@ extern int restrict_link_by_builtin_and_secondary_trusted(#define restrict_link_by_builtin_and_secondary_trusted restrict_link_by_builtin_trusted#endif +#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +extern void __init set_machine_trusted_keys (struct key *keyring); +#else +static inline void __init set_machine_trusted_keys (struct key *keyring) +{ +} +#endif +extern struct pkcs7_message *pkcs7;#ifdef CONFIG_SYSTEM_BLACKLIST_KEYRING extern int mark_hash_blacklisted (const char *hash);
security/integrity/digsig.c +2 -0
@@ -112,6 +112,8 @@ static int __init __integrity_init_keyring(const unsigned int id, }else {if (id ==INTEGRITY_KEYRING_PLATFORM )set_platform_trusted_keys (keyring[id]); +if (id ==INTEGRITY_KEYRING_MACHINE ) +set_machine_trusted_keys (keyring[id]);if (id ==INTEGRITY_KEYRING_IMA )load_module_cert (keyring[id]); }
Signature · 1 line
2.18.4
Re: [PATCH v9 4/8] KEYS: store reference to machine keyring
Quoted 81 lines · Eric Snowberg
Expose the .machine keyring created in integrity code by adding a reference. Store a reference to the machine keyring in system keyring code. The system keyring code needs this to complete the keyring link to the machine keyring.
Signed-off-by Eric Snowberg <[email protected]>---
v2: Initial version
v3: Unmodified from v2
v4: Removedtrust_moklistcheck
v5: Rename to machine keyring
v8: Unmodified from v5
v9: Combine with "add reference to machine keyring" patch--- certs/system_keyring.c | 9 +++++++++ include/keys/system_keyring.h | 8 ++++++++ security/integrity/digsig.c | 2 ++ 3 files changed, 19 insertions(+)certs/system_keyring.c +9
-0@@ -22,6 +22,9 @@ static struct key *builtin_trusted_keys;#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING static struct key *secondary_trusted_keys;#endif +#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +static struct key *machine_trusted_keys; +#endif #ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING static struct key *platform_trusted_keys;#endif @@ -91,6 +94,12 @@ static __init struct key_restriction *get_builtin_and_secondary_restriction(void return restriction; }#endif +#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +void __init set_machine_trusted_keys (struct key *keyring) +{ + machine_trusted_keys = keyring; +} +#endif /* * Create the trusted keyrings include/keys/system_keyring.h +8
-0@@ -38,6 +38,14 @@ extern int restrict_link_by_builtin_and_secondary_trusted(#define restrict_link_by_builtin_and_secondary_trusted restrict_link_by_builtin_trusted#endif +#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +extern void __init set_machine_trusted_keys (struct key *keyring); +#else +static inline void __init set_machine_trusted_keys (struct key *keyring) +{ +} +#endif +extern struct pkcs7_message *pkcs7;#ifdef CONFIG_SYSTEM_BLACKLIST_KEYRING extern int mark_hash_blacklisted (const char *hash);security/integrity/digsig.c +2
-0@@ -112,6 +112,8 @@ static int __init __integrity_init_keyring(const unsigned int id, }else {if (id ==INTEGRITY_KEYRING_PLATFORM )set_platform_trusted_keys (keyring[id]); +if (id ==INTEGRITY_KEYRING_MACHINE ) +set_machine_trusted_keys (keyring[id]);if (id ==INTEGRITY_KEYRING_IMA )load_module_cert (keyring[id]); }Signature · 1 line
2.18.4
BR, Jarkko
Eric Snowberg
reviewerPATCH v9 5/8 KEYS: Introduce link restriction for machine keys
In reply to Eric SnowbergIntroduce 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.
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.
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.
---
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
v8: Add missing parameter definitions (suggested by Mimi)
v9: Combine with "change link restriction to trust the machine keyring"
patch
--- certs/system_keyring.c | 35 ++++++++++++++++++++++++++++++++++- include/keys/system_keyring.h | 6 ++++++ 2 files changed, 40 insertions(+), 1 deletion(-)
certs/system_keyring.c +34 -1
@@ -89,7 +89,10 @@ static __init struct key_restriction *get_builtin_and_secondary_restriction(voidif (!restriction)panic ("Can't allocate secondary trusted keyring restriction\n" ); - restriction->check = restrict_link_by_builtin_and_secondary_trusted; +if (IS_ENABLED (CONFIG_INTEGRITY_MACHINE_KEYRING )) + restriction->check = restrict_link_by_builtin_secondary_and_machine; +else + restriction->check = restrict_link_by_builtin_and_secondary_trusted;return restriction; }
@@ -98,6 +101,36 @@ static __init struct key_restriction *get_builtin_and_secondary_restriction(voidvoid __init set_machine_trusted_keys (struct key *keyring) { machine_trusted_keys = keyring; + +if (key_link (secondary_trusted_keys, machine_trusted_keys) <0 ) +panic ("Can't link (machine) trusted keyrings\n" ); +} + +/** +* restrict_link_by_builtin_secondary_and_machine - Restrict keyring addition. +* @dest_keyring: Keyring being linked to. +* @type: The type of key being added. +* @payload: The payload of the new key. +* @restrict_key: A ring of keys that can be used to vouch for the new cert. +* +* 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
include/keys/system_keyring.h +6 -0
@@ -39,8 +39,14 @@ extern int restrict_link_by_builtin_and_secondary_trusted(#endif #ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +extern 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);extern void __init set_machine_trusted_keys (struct key *keyring);#else +#define restrict_link_by_builtin_secondary_and_machine restrict_link_by_builtin_trustedstatic inline void __init set_machine_trusted_keys (struct key *keyring) { }
Signature · 1 line
2.18.4
Re: [PATCH v9 5/8] KEYS: Introduce link restriction for machine keys
Quoted 109 lines · Eric Snowberg
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.
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.
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 searchingsecondary_trusted_keys.Suggested-by Mimi Zohar <[email protected]>Signed-off-by Eric Snowberg <[email protected]>---
v3: Initial version
v4: moved code underCONFIG_INTEGRITY_MOK_KEYRING
v5: Rename to machine keyring
v6: Change subject name (suggested by Mimi)
Renamerestrict_link_by_builtin_secondary_and_ca_trusted
torestrict_link_by_builtin_secondary_and_machine(suggested by Mimi)
v7: Unmodified from v6
v8: Add missing parameter definitions (suggested by Mimi)
v9: Combine with "change link restriction to trust the machine keyring"
patch--- certs/system_keyring.c | 35 ++++++++++++++++++++++++++++++++++- include/keys/system_keyring.h | 6 ++++++ 2 files changed, 40 insertions(+), 1 deletion(-)certs/system_keyring.c +34
-1@@ -89,7 +89,10 @@ static __init struct key_restriction *get_builtin_and_secondary_restriction(voidif (!restriction)panic ("Can't allocate secondary trusted keyring restriction\n" ); - restriction->check = restrict_link_by_builtin_and_secondary_trusted; +if (IS_ENABLED (CONFIG_INTEGRITY_MACHINE_KEYRING )) + restriction->check = restrict_link_by_builtin_secondary_and_machine; +else + restriction->check = restrict_link_by_builtin_and_secondary_trusted;return restriction; }@@ -98,6 +101,36 @@ static __init struct key_restriction *get_builtin_and_secondary_restriction(voidvoid __init set_machine_trusted_keys (struct key *keyring) { machine_trusted_keys = keyring; + +if (key_link (secondary_trusted_keys, machine_trusted_keys) <0 ) +panic ("Can't link (machine) trusted keyrings\n" ); +} + +/** +* restrict_link_by_builtin_secondary_and_machine - Restrict keyring addition. +* @dest_keyring: Keyring being linked to. +* @type: The type of key being added. +* @payload: The payload of the new key. +* @restrict_key: A ring of keys that can be used to vouch for the new cert. +* +* 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 include/keys/system_keyring.h +6
-0@@ -39,8 +39,14 @@ extern int restrict_link_by_builtin_and_secondary_trusted(#endif #ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +extern 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);extern void __init set_machine_trusted_keys (struct key *keyring);#else +#define restrict_link_by_builtin_secondary_and_machine restrict_link_by_builtin_trustedstatic inline void __init set_machine_trusted_keys (struct key *keyring) { }Signature · 1 line
2.18.4
/Jarkko
Mimi Zohar
maintainerRe: [PATCH v9 5/8] KEYS: Introduce link restriction for machine keys
In reply to Eric SnowbergQuoted 10 lines · Eric Snowberg
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.
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.
As suggested the Kconfig in "[PATCH v9 2/8] integrity: Introduce a Linux keyring called machine" only loads the platform keys onto the .machine keyring, when IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY is not enabled. The last sentence needs to be updated to reflect v9.
thanks,
Mimi
Eric Snowberg
reviewerRe: [PATCH v9 5/8] KEYS: Introduce link restriction for machine keys
Quoted 16 lines · Mimi Zohar
Quoted 10 lines · Eric Snowberg
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.
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.
Quoted 5 lines
As suggested the
Kconfigin "[PATCH v9 2/8] integrity: Introduce a Linux keyring called machine" only loads the platform keys onto the .machine keyring, whenIMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARYis not enabled. The last sentence needs to be updated to reflect v9.
I missed that when I dropped IMA support. I will remove the ima reference in the next round. Thanks.
Eric Snowberg
reviewerPATCH v9 6/8 efi/mokvar: move up init order
In reply to Eric SnowbergMove up the init order so it can be used by the new machine keyring.
---
v7: Initial version
v9: Unmodified from v7
--- drivers/firmware/efi/mokvar-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/mokvar-table.c +1 -1
@@ -359,4 +359,4 @@ static int __init efi_mokvar_sysfs_init(void) }return err; } -device_initcall (efi_mokvar_sysfs_init); +fs_initcall (efi_mokvar_sysfs_init);
Signature · 1 line
2.18.4
Re: [PATCH v9 6/8] efi/mokvar: move up init order
Quoted 23 lines · Eric Snowberg
Move up the init order so it can be used by the new machine keyring.
Signed-off-by Eric Snowberg <[email protected]>---
v7: Initial version
v9: Unmodified from v7--- drivers/firmware/efi/mokvar-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/firmware/efi/mokvar-table.c +1
-1@@ -359,4 +359,4 @@ static int __init efi_mokvar_sysfs_init(void) }return err; } -device_initcall (efi_mokvar_sysfs_init); +fs_initcall (efi_mokvar_sysfs_init);Signature · 1 line
2.18.4
/Jarkko
Eric Snowberg
reviewerPATCH v9 7/8 integrity: Trust MOK keys if MokListTrustedRT found
In reply to Eric SnowbergA 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.
---
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)
v9: Unmodified from v7
--- .../platform_certs/machine_keyring.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
security/integrity/platform_certs/machine_keyring.c +19 -0
@@ -5,6 +5,7 @@* Copyright (c) 2021, Oracle and/or its affiliates. */ +#include <linux/efi.h> #include "../integrity.h" static __init int machine_keyring_init (void )
@@ -40,3 +41,21 @@ void __init add_to_machine_keyring(const char *source, const void *data, size_tif (rc)pr_info ("Error adding keys to machine keyring %s\n" , source); } + +/* +* Try to load the MokListTrustedRT MOK variable to see if we should trust +* the MOK keys within the kernel. It is not an error if this variable +* does not exist. If it does not exist, MOK keys should not be trusted +* within the machine keyring. +*/ +static __init bool uefi_check_trust_mok_keys (void ) +{ +struct efi_mokvar_table_entry *mokvar_entry; + + mokvar_entry =efi_mokvar_entry_find ("MokListTrustedRT" ); + +if (mokvar_entry) +return true; + +return false; +}
Signature · 1 line
2.18.4
Re: [PATCH v9 7/8] integrity: Trust MOK keys if MokListTrustedRT found
Quoted 57 lines · Eric Snowberg
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 <[email protected]>---
v1: Initial version
v2: Removedmok_keyring_trust_setupfunction
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)
v9: Unmodified from v7--- .../platform_certs/machine_keyring.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)security/integrity/platform_certs/machine_keyring.c +19
-0@@ -5,6 +5,7 @@* Copyright (c) 2021, Oracle and/or its affiliates. */ +#include <linux/efi.h> #include "../integrity.h" static __init int machine_keyring_init (void )@@ -40,3 +41,21 @@ void __init add_to_machine_keyring(const char *source, const void *data, size_tif (rc)pr_info ("Error adding keys to machine keyring %s\n" , source); } + +/* +* Try to load the MokListTrustedRT MOK variable to see if we should trust +* the MOK keys within the kernel. It is not an error if this variable +* does not exist. If it does not exist, MOK keys should not be trusted +* within the machine keyring. +*/ +static __init bool uefi_check_trust_mok_keys (void ) +{ +struct efi_mokvar_table_entry *mokvar_entry; + + mokvar_entry =efi_mokvar_entry_find ("MokListTrustedRT" ); + +if (mokvar_entry) +return true; + +return false; +}Signature · 1 line
2.18.4
BR, Jarkko
Eric Snowberg
reviewerPATCH v9 8/8 integrity: Only use machine keyring when uefi_check_trust_mok_keys is true
In reply to Eric SnowbergWith 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.
---
v4: Initial version
v5: Rename to machine keyring
v6: Unmodified from v5
v7: Made trust_mok static
v8: Unmodified from v7
--- 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(-)
security/integrity/digsig.c +1 -1
@@ -112,7 +112,7 @@ static int __init __integrity_init_keyring(const unsigned int id, }else {if (id ==INTEGRITY_KEYRING_PLATFORM )set_platform_trusted_keys (keyring[id]); -if (id ==INTEGRITY_KEYRING_MACHINE ) +if (id ==INTEGRITY_KEYRING_MACHINE &&trust_moklist ())set_machine_trusted_keys (keyring[id]);if (id ==INTEGRITY_KEYRING_IMA )load_module_cert (keyring[id]);
security/integrity/integrity.h +5 -0
@@ -287,9 +287,14 @@ static inline void __init add_to_platform_keyring(const char *source,#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING void __init add_to_machine_keyring (const char *source,const void *data,size_t len); +bool __init trust_moklist (void );#else static inline void __init add_to_machine_keyring (const char *source,const void *data,size_t len) { } +static inline bool __init trust_moklist (void ) +{ +return false; +}#endif
security/integrity/platform_certs/keyring_handler.c +1 -1
@@ -83,7 +83,7 @@ __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) {if (efi_guidcmp (*sig_type, efi_cert_x509_guid) ==0 ) { -if (IS_ENABLED (CONFIG_INTEGRITY_MACHINE_KEYRING )) +if (IS_ENABLED (CONFIG_INTEGRITY_MACHINE_KEYRING ) &&trust_moklist ())return add_to_machine_keyring;else return add_to_platform_keyring;
security/integrity/platform_certs/machine_keyring.c +16 -0
@@ -8,6 +8,8 @@#include <linux/efi.h> #include "../integrity.h" +static bool trust_mok; +static __init int machine_keyring_init (void ) {int rc;
@@ -59,3 +61,17 @@ static __init bool uefi_check_trust_mok_keys(void)return false; } + +bool __init trust_moklist (void ) +{ +static bool initialized; + +if (!initialized) { + initialized = true; + +if (uefi_check_trust_mok_keys ()) + trust_mok = true; + } + +return trust_mok; +}
Signature · 1 line
2.18.4
Re: [PATCH v9 8/8] integrity: Only use machine keyring when uefi_check_trust_mok_keys is true
Quoted 100 lines · Eric Snowberg
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 <[email protected]>---
v4: Initial version
v5: Rename to machine keyring
v6: Unmodified from v5
v7: Madetrust_mokstatic
v8: Unmodified from v7--- 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(-)security/integrity/digsig.c +1
-1@@ -112,7 +112,7 @@ static int __init __integrity_init_keyring(const unsigned int id, }else {if (id ==INTEGRITY_KEYRING_PLATFORM )set_platform_trusted_keys (keyring[id]); -if (id ==INTEGRITY_KEYRING_MACHINE ) +if (id ==INTEGRITY_KEYRING_MACHINE &&trust_moklist ())set_machine_trusted_keys (keyring[id]);if (id ==INTEGRITY_KEYRING_IMA )load_module_cert (keyring[id]);security/integrity/integrity.h +5
-0@@ -287,9 +287,14 @@ static inline void __init add_to_platform_keyring(const char *source,#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING void __init add_to_machine_keyring (const char *source,const void *data,size_t len); +bool __init trust_moklist (void );#else static inline void __init add_to_machine_keyring (const char *source,const void *data,size_t len) { } +static inline bool __init trust_moklist (void ) +{ +return false; +}#endif security/integrity/platform_certs/keyring_handler.c +1
-1@@ -83,7 +83,7 @@ __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) {if (efi_guidcmp (*sig_type, efi_cert_x509_guid) ==0 ) { -if (IS_ENABLED (CONFIG_INTEGRITY_MACHINE_KEYRING )) +if (IS_ENABLED (CONFIG_INTEGRITY_MACHINE_KEYRING ) &&trust_moklist ())return add_to_machine_keyring;else return add_to_platform_keyring;security/integrity/platform_certs/machine_keyring.c +16
-0@@ -8,6 +8,8 @@#include <linux/efi.h> #include "../integrity.h" +static bool trust_mok; +static __init int machine_keyring_init (void ) {int rc;@@ -59,3 +61,17 @@ static __init bool uefi_check_trust_mok_keys(void)return false; } + +bool __init trust_moklist (void ) +{ +static bool initialized; + +if (!initialized) { + initialized = true; + +if (uefi_check_trust_mok_keys ()) + trust_mok = true; + } + +return trust_mok; +}Signature · 1 line
2.18.4
Mimi, have you tested these patches already?
/Jarkko
Mimi Zohar
maintainerRe: [PATCH v9 8/8] integrity: Only use machine keyring when uefi_check_trust_mok_keys is true
Quoted 3 lines · Jarkko Sakkinen
Reviewed-by Jarkko Sakkinen <[email protected]>Mimi, have you tested these patches already?
Sorry, not yet this version this of the patch set. Planning to test shortly.
Mimi
Mimi Zohar
maintainerRe: [PATCH v9 8/8] integrity: Only use machine keyring when uefi_check_trust_mok_keys is true
Quoted 7 lines · Mimi Zohar
Quoted 3 lines · Jarkko Sakkinen
Reviewed-by Jarkko Sakkinen <[email protected]>Mimi, have you tested these patches already?
Sorry, not yet this version this of the patch set. Planning to test shortly.
I've only tested v9 1/8 - 6/8 patches on top of Takashi Iwai and Joey Lee's patches, which are queued to be upstreamed.
92ad19559ea9 integrity: Do not load MOK and MOKx when secure boot be disabled54bf7fa3efd0 ima: Fix undefined arch_ima_get_secureboot() and co
With secure boot enabled and IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY disabled, all of the MOK keys are loaded onto the .machine keyring. With secure boot disabled, none of the MOK keys are loaded onto either the .platform or .machine keyrings, irrespective of IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY.
This patch set is working as expected, but the v9 2/8 & 5/8 patch descriptions haven't been updated, nor have the related comments been updated. Please note that the subsequent patch set will limit the MOK keys being loaded onto the .machine keyring to only the MOK CA keys.
thanks,
Mimi
Jarkko Sakkinen
maintainerRe: [PATCH v9 8/8] integrity: Only use machine keyring when uefi_check_trust_mok_keys is true
In reply to Mimi ZoharQuoted 10 lines · Mimi Zohar
Quoted 3 lines · Jarkko Sakkinen
Reviewed-by Jarkko Sakkinen <[email protected]>Mimi, have you tested these patches already?
Sorry, not yet this version this of the patch set. Planning to test shortly.
Mimi
Yeah, it is otherwise good IMHO. It's too late for v5.17 tho, so there is no rush. We will get this to v5.18.
/Jarkko