[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<SN7PR18MB5314CEAF1CEDC95B2C874696E32B2@SN7PR18MB5314.namprd18.prod.outlook.com>
Date: Tue, 12 Mar 2024 06:00:39 +0000
From: Bharat Bhushan <bbhushan2@...vell.com>
To: Eric Snowberg <eric.snowberg@...cle.com>,
"linux-security-module@...r.kernel.org"
<linux-security-module@...r.kernel.org>
CC: "dhowells@...hat.com" <dhowells@...hat.com>,
"dwmw2@...radead.org"
<dwmw2@...radead.org>,
"herbert@...dor.apana.org.au"
<herbert@...dor.apana.org.au>,
"davem@...emloft.net" <davem@...emloft.net>,
"ardb@...nel.org" <ardb@...nel.org>,
"jarkko@...nel.org" <jarkko@...nel.org>,
"paul@...l-moore.com" <paul@...l-moore.com>,
"jmorris@...ei.org"
<jmorris@...ei.org>,
"serge@...lyn.com" <serge@...lyn.com>,
"zohar@...ux.ibm.com" <zohar@...ux.ibm.com>,
"roberto.sassu@...wei.com"
<roberto.sassu@...wei.com>,
"dmitry.kasatkin@...il.com"
<dmitry.kasatkin@...il.com>,
"mic@...ikod.net" <mic@...ikod.net>,
"casey@...aufler-ca.com" <casey@...aufler-ca.com>,
"stefanb@...ux.ibm.com"
<stefanb@...ux.ibm.com>,
"linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>,
"keyrings@...r.kernel.org"
<keyrings@...r.kernel.org>,
"linux-crypto@...r.kernel.org"
<linux-crypto@...r.kernel.org>,
"linux-efi@...r.kernel.org"
<linux-efi@...r.kernel.org>,
"linux-integrity@...r.kernel.org"
<linux-integrity@...r.kernel.org>
Subject: RE: [EXTERNAL] [PATCH RFC 1/8] certs: Introduce ability to link to a
system key
> -----Original Message-----
> From: Eric Snowberg <eric.snowberg@...cle.com>
> Sent: Monday, March 11, 2024 9:41 PM
> To: linux-security-module@...r.kernel.org
> Cc: dhowells@...hat.com; dwmw2@...radead.org;
> herbert@...dor.apana.org.au; davem@...emloft.net; ardb@...nel.org;
> jarkko@...nel.org; paul@...l-moore.com; jmorris@...ei.org;
> serge@...lyn.com; zohar@...ux.ibm.com; roberto.sassu@...wei.com;
> dmitry.kasatkin@...il.com; mic@...ikod.net; casey@...aufler-ca.com;
> stefanb@...ux.ibm.com; eric.snowberg@...cle.com; linux-
> kernel@...r.kernel.org; keyrings@...r.kernel.org; linux-
> crypto@...r.kernel.org; linux-efi@...r.kernel.org; linux-
> integrity@...r.kernel.org
> Subject: [EXTERNAL] [PATCH RFC 1/8] certs: Introduce ability to link to a
> system key
>
> Prioritize security for external emails: Confirm sender and content safety
> before clicking links or opening attachments
>
> ----------------------------------------------------------------------
> Introduce a new function to allow a keyring to link to a key contained
> within one of the system keyrings (builtin, secondary, or platform).
> Depending on how the kernel is built, if the machine keyring is
> available, it will be checked as well, since it is linked to the secondary
> keyring. If the asymmetric key id matches a key within one of these
> system keyrings, the matching key is linked into the passed in
> keyring.
>
> Signed-off-by: Eric Snowberg <eric.snowberg@...cle.com>
> ---
> certs/system_keyring.c | 29 +++++++++++++++++++++++++++++
> include/keys/system_keyring.h | 7 ++++++-
> 2 files changed, 35 insertions(+), 1 deletion(-)
>
> diff --git a/certs/system_keyring.c b/certs/system_keyring.c
> index 9de610bf1f4b..b647be49f6e0 100644
> --- a/certs/system_keyring.c
> +++ b/certs/system_keyring.c
> @@ -426,3 +426,32 @@ void __init set_platform_trusted_keys(struct key
> *keyring)
> platform_trusted_keys = keyring;
> }
> #endif
> +
> +/**
> + * system_key_link - Link to a system key
> + * @keyring: The keyring to link into
> + * @id: The asymmetric key id to look for in the system keyring
> + */
> +int system_key_link(struct key *keyring, struct asymmetric_key_id *id)
> +{
> + struct key *tkey;
> +
> +#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING
> + tkey = find_asymmetric_key(secondary_trusted_keys, id, NULL, NULL,
> false);
> +#else
> + tkey = find_asymmetric_key(builtin_trusted_keys, id, NULL, NULL,
> false);
> +#endif
> + if (!IS_ERR(tkey))
> + goto found;
> +
> + tkey = find_asymmetric_key(platform_trusted_keys, id, NULL, NULL,
> false);
> +
> + if (!IS_ERR(tkey))
> + goto found;
> +
> + return -1;
Please use -ENOKEY.
Thanks
-Bharat
> +
> +found:
> + key_link(keyring, tkey);
> + return 0;
> +}
> diff --git a/include/keys/system_keyring.h b/include/keys/system_keyring.h
> index 8365adf842ef..b47ac8e2001a 100644
> --- a/include/keys/system_keyring.h
> +++ b/include/keys/system_keyring.h
> @@ -9,6 +9,7 @@
> #define _KEYS_SYSTEM_KEYRING_H
>
> #include <linux/key.h>
> +struct asymmetric_key_id;
>
> enum blacklist_hash_type {
> /* TBSCertificate hash */
> @@ -28,7 +29,7 @@ int restrict_link_by_digsig_builtin(struct key
> *dest_keyring,
> const union key_payload *payload,
> struct key *restriction_key);
> extern __init int load_module_cert(struct key *keyring);
> -
> +extern int system_key_link(struct key *keyring, struct asymmetric_key_id
> *id);
> #else
> #define restrict_link_by_builtin_trusted restrict_link_reject
> #define restrict_link_by_digsig_builtin restrict_link_reject
> @@ -38,6 +39,10 @@ static inline __init int load_module_cert(struct key
> *keyring)
> return 0;
> }
>
> +static inline int system_key_link(struct key *keyring, struct asymmetric_key_id
> *id)
> +{
> + return 0;
> +}
> #endif
>
> #ifdef CONFIG_SECONDARY_TRUSTED_KEYRING
> --
> 2.39.3
>
Powered by blists - more mailing lists