From: Sergey Shtylyov <s.shtylyov@omp.ru>
To: Denis Glazkov <d.glazkov@omp.ru>
Cc: David Howells <dhowells@redhat.com>,
David Woodhouse <dwmw2@infradead.org>,
"keyrings@vger.kernel.org" <keyrings@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] certs: Add the ability to add only CA certificates to the secondary trusted keyring
Date: Wed, 6 Sep 2023 15:58:58 +0300 [thread overview]
Message-ID: <f5a1d856-0482-a2c3-0e62-3ca911ce3dd2@omp.ru> (raw)
In-Reply-To: <20230906113211.82362-1-d.glazkov@omp.ru>
On 9/6/23 2:32 PM, Denis Glazkov wrote:
> When building a chain of trust for IMA certificates issued from
It's a shame I forgot what IMA stands for... and even Google doesn't
give any suitable value...
> intermediate certificates using a secondary trusted keying, there
> is no way to restrict the addition of IMA certificates to trusted
> certificates, since any certificate signed by an built-in or
> secondary trusted certificate can be added to the secondary
> trusted keying.
>
> With root privileges, an attacker can load a certificate intended
> for IMA into the trusted certificates and sign the kernel modules
> with the corresponding private key. This allows an attacker to
> load untrusted modules into kernel space.
>
> This patch adds the configuration that once enabled, only
> certificates that meet the following requirements can be added
> to the secondary trusted keying:
>
> 1. The certificate is a CA.
Oh, and I also forgot what CA stands for... :-/
> 2. The certificate must be used for verifying a CA's signatures.
> 3. The certificate must not be used for digital signatures.
>
> Signed-off-by: Denis Glazkov <d.glazkov@omp.ru>
[...]
> diff --git a/certs/system_keyring.c b/certs/system_keyring.c
> index 9de610bf1f4b..8d45c19ba92e 100644
> --- a/certs/system_keyring.c
> +++ b/certs/system_keyring.c
> @@ -90,6 +90,10 @@ int restrict_link_by_builtin_and_secondary_trusted(
> const union key_payload *payload,
> struct key *restrict_key)
> {
> +#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING_FOR_CA_CERTIFICATES_ONLY
> + struct public_key *pub;
> +#endif
Mhm, why this is not a part of the *if* block in the next hunk?
You don't use this variable outside that block...
[...]
> @@ -99,6 +103,23 @@ int restrict_link_by_builtin_and_secondary_trusted(
> /* Allow the builtin keyring to be added to the secondary */
> return 0;
>
> +#ifdef CONFIG_SECONDARY_TRUSTED_KEYRING_FOR_CA_CERTIFICATES_ONLY
> + if (dest_keyring == secondary_trusted_keys) {
> + if (type != &key_type_asymmetric)
> + return -EOPNOTSUPP;
> +
> + pub = payload->data[asym_crypto];
I'm not seeing this index declared in Linus' repo...
> + if (!pub)
> + return -ENOPKG;
> + if (!test_bit(KEY_EFLAG_CA, &pub->key_eflags))
> + return -EPERM;
> + if (!test_bit(KEY_EFLAG_KEYCERTSIGN, &pub->key_eflags))
> + return -EPERM;
> + if (test_bit(KEY_EFLAG_DIGITALSIG, &pub->key_eflags))
> + return -EPERM;
> + }
> +#endif
> +
> return restrict_link_by_signature(dest_keyring, type, payload,
> secondary_trusted_keys);
> }
MBR, Sergey
next prev parent reply other threads:[~2023-09-06 12:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-06 11:32 Denis Glazkov
2023-09-06 12:58 ` Sergey Shtylyov [this message]
2023-09-08 12:14 ` [PATCH v2] certs: Add option to disallow non-CA certificates in secondary trusted keying Denis Glazkov
2023-09-11 21:15 ` Jarkko Sakkinen
2023-09-15 17:50 ` Denis Glazkov
2023-09-25 16:54 ` Jarkko Sakkinen
2023-10-02 10:46 ` [PATCH v3] " Denis Glazkov
2023-10-02 23:49 ` Jarkko Sakkinen
2023-10-03 19:04 ` Eric Snowberg
2023-10-05 21:33 ` Denis Glazkov
2023-10-09 14:10 ` Mimi Zohar
2023-10-17 12:43 ` Mimi Zohar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f5a1d856-0482-a2c3-0e62-3ca911ce3dd2@omp.ru \
--to=s.shtylyov@omp.ru \
--cc=d.glazkov@omp.ru \
--cc=dhowells@redhat.com \
--cc=dwmw2@infradead.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®