[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4bda209dfc891ac9044ce847785c383e89f14f97.camel@linux.ibm.com>
Date: Fri, 10 Feb 2023 08:05:22 -0500
From: Mimi Zohar <zohar@...ux.ibm.com>
To: Eric Snowberg <eric.snowberg@...cle.com>, jarkko@...nel.org,
dhowells@...hat.com, dwmw2@...radead.org
Cc: herbert@...dor.apana.org.au, davem@...emloft.net,
dmitry.kasatkin@...il.com, paul@...l-moore.com, jmorris@...ei.org,
serge@...lyn.com, pvorel@...e.cz, tadeusz.struk@...el.com,
kanth.ghatraju@...cle.com, konrad.wilk@...cle.com,
erpalmer@...ux.vnet.ibm.com, coxu@...hat.com,
keyrings@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-crypto@...r.kernel.org, linux-integrity@...r.kernel.org,
linux-security-module@...r.kernel.org
Subject: Re: [PATCH v4 6/6] integrity: machine keyring CA configuration
Hi Eric,
On Mon, 2023-02-06 at 21:59 -0500, Eric Snowberg wrote:
> Add a machine keyring CA restriction menu option to control the type of
> keys that may be added to it. The options include none, min and max
> restrictions.
>
> When no restrictions are selected, all Machine Owner Keys (MOK) are added
> to the machine keyring. When CONFIG_INTEGRITY_CA_MACHINE_KEYRING_MIN is
> selected, the CA bit must be true. Also the key usage must contain
> keyCertSign, any other usage field may be set as well.
>
> When CONFIG_INTEGRITY_CA_MACHINE_KEYRING_MAX is selected, the CA bit must
> be true. Also the key usage must contain keyCertSign and the
> digitialSignature usage may not be set.
>
> Signed-off-by: Eric Snowberg <eric.snowberg@...cle.com>
Missing from the patch description is the motivation for this change.
The choices none, min, max implies a progression, which is good, and
the technical differences between the choices, but not the reason.
The motivation, at least from my perspective, is separation of
certificate signing from code signing keys, where "none" is no
separation and "max" being total separation of keys based on usage.
Subsequent work, as discussed in the cover letter thread, will limit
certificates being loaded onto the IMA keyring to code signing keys
used for signature verification.
thanks,
Mimi
> ---
> crypto/asymmetric_keys/restrict.c | 2 ++
> security/integrity/Kconfig | 39 ++++++++++++++++++++++++++++++-
> security/integrity/digsig.c | 8 +++++--
> 3 files changed, 46 insertions(+), 3 deletions(-)
>
> diff --git a/crypto/asymmetric_keys/restrict.c b/crypto/asymmetric_keys/restrict.c
> index 48457c6f33f9..633021ea7901 100644
> --- a/crypto/asymmetric_keys/restrict.c
> +++ b/crypto/asymmetric_keys/restrict.c
> @@ -140,6 +140,8 @@ int restrict_link_by_ca(struct key *dest_keyring,
> return -ENOKEY;
> if (!test_bit(KEY_EFLAG_KEYCERTSIGN, &pkey->key_eflags))
> return -ENOKEY;
> + if (IS_ENABLED(CONFIG_INTEGRITY_CA_MACHINE_KEYRING_MIN))
> + return 0;
> if (test_bit(KEY_EFLAG_DIGITALSIG, &pkey->key_eflags))
> return -ENOKEY;
>
> diff --git a/security/integrity/Kconfig b/security/integrity/Kconfig
> index 599429f99f99..eba6fd59fd16 100644
> --- a/security/integrity/Kconfig
> +++ b/security/integrity/Kconfig
> @@ -68,13 +68,50 @@ config INTEGRITY_MACHINE_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 Machine Owner Keys (MOK) may
> be added. This keyring shall contain just MOK keys. Unlike keys
> in the platform keyring, keys contained in the .machine keyring will
> be trusted within the kernel.
>
> +choice
> + prompt "Enforce Machine Keyring CA Restrictions"
> + default INTEGRITY_CA_MACHINE_KEYRING_NONE
> + depends on INTEGRITY_MACHINE_KEYRING
> + help
> + The .machine keyring can be configured to enforce CA restriction
> + on any key added to it. The options include none, min and max
> + restrictions. By default no restrictions are in place and all
> + Machine Owner Keys (MOK) are added to the machine keyring.
> +
> +config INTEGRITY_CA_MACHINE_KEYRING_NONE
> + bool "No restrictions"
> + help
> + When no restrictions are selected, all Machine Owner Keys (MOK)
> + are added to the machine keyring. MOK keys do not require the
> + CA bit to be set. The key usage field is ignored. This is the
> + default setting.
> +
> +config INTEGRITY_CA_MACHINE_KEYRING_MIN
> + bool "Only CA keys (with or without DigitialSignature usage set)"
> + help
> + When min is selected, only load CA keys into the machine keyring.
> + The CA bit must be set along with the keyCertSign Usage field.
> + Keys containing the digitialSignature Usage field will also be
> + loaded. The remaining MOK keys are loaded into the .platform
> + keyring.
> +
> +config INTEGRITY_CA_MACHINE_KEYRING_MAX
> + bool "Only CA keys"
> + help
> + When max is selected, only load CA keys into the machine keyring.
> + The CA bit must be set along with the keyCertSign Usage field.
> + Keys containing the digitialSignature Usage field will not be
> + loaded. The remaining MOK keys are loaded into the .platform
> + keyring.
> +
> +endchoice
> +
> config LOAD_UEFI_KEYS
> depends on INTEGRITY_PLATFORM_KEYRING
> depends on EFI
> diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c
> index f2193c531f4a..3385f534f1da 100644
> --- a/security/integrity/digsig.c
> +++ b/security/integrity/digsig.c
> @@ -132,7 +132,8 @@ int __init integrity_init_keyring(const unsigned int id)
> | KEY_USR_READ | KEY_USR_SEARCH;
>
> if (id == INTEGRITY_KEYRING_PLATFORM ||
> - id == INTEGRITY_KEYRING_MACHINE) {
> + (id == INTEGRITY_KEYRING_MACHINE &&
> + IS_ENABLED(CONFIG_INTEGRITY_CA_MACHINE_KEYRING_NONE))) {
> restriction = NULL;
> goto out;
> }
> @@ -144,7 +145,10 @@ int __init integrity_init_keyring(const unsigned int id)
> 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;
>
> /*
> * MOK keys can only be added through a read-only runtime services
Powered by blists - more mailing lists