From: David Howells <dhowells@redhat.com>
To: Kees Cook <keescook@chromium.org>
Cc: dhowells@redhat.com, LKML <linux-kernel@vger.kernel.org>
Subject: Re: Pull "Load keys from signed PE binaries" branch into linux-next
Date: Thu, 10 Jan 2013 16:12:15 +0000 [thread overview]
Message-ID: <8057.1357834335@warthog.procyon.org.uk> (raw)
In-Reply-To: <CAGXu5jJtuorV9GcetPA+v9K4p-jX4oacaDPrJ3j+RTM+eK5kFA@mail.gmail.com>
Kees Cook <keescook@chromium.org> wrote:
> This is a quick review of the devel-pekeys tree...
Thanks!
> +static int public_key_verify_signature_2(const struct key *key,
>
> Maybe name this "key_verify_signature" instead of using the trailing _2?
I would prefer that it begin with "public_key_" as that reflects the what it
deals with and makes it easier for me to find.
> --- a/crypto/asymmetric_keys/x509_public_key.c
> +++ b/crypto/asymmetric_keys/x509_public_key.c
> @@ -24,72 +24,83 @@
> [...]
> - tfm = crypto_alloc_shash(pkey_hash_algo_name[cert->sig_hash_algo],
> 0, 0);
> + tfm = crypto_alloc_shash(pkey_hash_algo_name[cert->sig.pkey_hash_algo],
> 0, 0);
>
> I think, even if it wasn't done before, it's worth bounds-checking the
> array access here too.
Probably not necessary, but I should check that we have the algorithms if the
number is in range. How about:
--- a/crypto/asymmetric_keys/x509_public_key.c
+++ b/crypto/asymmetric_keys/x509_public_key.c
@@ -176,6 +176,16 @@ static int x509_key_preparse(struct key_preparsed_payload *prep)
goto error_free_cert;
}
+ if (cert->pub->pkey_algo > PKEY_ALGO__LAST ||
+ cert->sig.pkey_algo > PKEY_ALGO__LAST ||
+ cert->sig.pkey_hash_algo > PKEY_HASH__LAST ||
+ !pkey_algo[cert->pub->pkey_algo] ||
+ !pkey_algo[cert->sig.pkey_algo] ||
+ !pkey_hash_algo_name[cert->sig.pkey_hash_algo]) {
+ ret = -ENOPKG;
+ goto error_free_cert;
+ }
+
cert->pub->algo = pkey_algo[cert->pub->pkey_algo];
cert->pub->id_type = PKEY_ID_X509;
> + tfm = crypto_alloc_shash(pkey_hash_algo_name[pkcs7->sig.pkey_hash_algo],
> + 0, 0);
>
> More of my paranoia for array access here. :)
I've added this at the top of pkc7_digest():
if (pkcs7->sig.pkey_hash_algo > PKEY_HASH__LAST ||
pkey_hash_algo_name[pkcs7->sig.pkey_hash_algo])
return -ENOPKG;
> --- /dev/null
> +++ b/crypto/asymmetric_keys/pkcs7_trust.c
> @@ -0,0 +1,145 @@
> [...]
> + id[signer_len + 0] = ':';
> + id[signer_len + 1] = ' ';
>
> the key matching routing seems to not expect this trailing space
> character? Also, is there some risk here that a requested signer
> string could include a ":" character to confuse things?
This bit of asymmetric_key_match() takes care of that:
/* See if the full key description matches as is */
if (key->description && strcmp(key->description, description) == 0)
return 1;
David
next prev parent reply other threads:[~2013-01-10 16:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-03 13:05 David Howells
2013-01-03 23:24 ` Stephen Rothwell
2013-01-09 21:09 ` Kees Cook
2013-01-10 16:12 ` David Howells [this message]
2013-01-10 18:16 ` David Howells
2013-01-10 20:05 ` Josh Boyer
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=8057.1357834335@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=keescook@chromium.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®