public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: ebiederm@xmission.com, hpa@zytor.com, mjg59@srcf.ucam.org,
	greg@kroah.com, bp@alien8.de, dyoung@redhat.com,
	chaowang@redhat.com, bhe@redhat.com, akpm@linux-foundation.org,
	dhowells@redhat.com, pjones@redhat.com,
	Vivek Goyal <vgoyal@redhat.com>
Subject: [PATCH 8/9] PEFILE: Validate PKCS#7 trust chain
Date: Thu,  3 Jul 2014 17:07:20 -0400	[thread overview]
Message-ID: <1404421641-12691-9-git-send-email-vgoyal@redhat.com> (raw)
In-Reply-To: <1404421641-12691-1-git-send-email-vgoyal@redhat.com>

Validate the PKCS#7 trust chain against the contents of the system keyring.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
 arch/x86/Kconfig                |  1 +
 arch/x86/kernel/pefile_parser.c | 12 +++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 29b9967..741d90d 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1579,6 +1579,7 @@ config SIGNED_PE_FILE_PARSER
 	depends on PKCS7_MESSAGE_PARSER=y
 	select ASN1
 	select OID_REGISTRY
+	select SYSTEM_TRUSTED_KEYRING
 	---help---
 	  This option provides support for parsing signed PE
 	  (Protable Executable) binaries.
diff --git a/arch/x86/kernel/pefile_parser.c b/arch/x86/kernel/pefile_parser.c
index f11c254..de61279 100644
--- a/arch/x86/kernel/pefile_parser.c
+++ b/arch/x86/kernel/pefile_parser.c
@@ -18,6 +18,7 @@
 #include <linux/asn1.h>
 #include <keys/asymmetric-subtype.h>
 #include <keys/asymmetric-parser.h>
+#include <keys/system_keyring.h>
 #include <crypto/hash.h>
 #include <crypto/pkcs7.h>
 #include "pefile_parser.h"
@@ -388,6 +389,7 @@ int pefile_parse_verify_sig(const void *pebuf, unsigned int pelen)
 	void *pkcs7;
 	struct pefile_context ctx;
 	int ret;
+	bool trusted;
 
 	kenter("");
 
@@ -421,9 +423,13 @@ int pefile_parse_verify_sig(const void *pebuf, unsigned int pelen)
 	ret = pkcs7_verify(pkcs7);
 	if (ret < 0)
 		goto error;
-
-	/* Not yet complete */
-	ret = -ENOANO;
+	/*
+	 * Trust is being verified against system_trusted_keyring. This is
+	 * a trusted keyring and all the keys in this keyring should be
+	 * trusted. So there should not be any need to check "trusted"
+	 * parameter.
+	 */
+	ret = pkcs7_validate_trust(pkcs7, system_trusted_keyring, &trusted);
 
 error:
 	pkcs7_free_message(ctx.pkcs7);
-- 
1.9.0


  parent reply	other threads:[~2014-07-03 21:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-03 21:07 [RFC PATCH 0/9] kexec: Verify signature of PE signed bzImage Vivek Goyal
2014-07-03 21:07 ` [PATCH 1/9] pkcs7: Forward declare struct key in pkcs7.h Vivek Goyal
2014-07-03 21:07 ` [PATCH 2/9] Provide PE binary definitions Vivek Goyal
2014-07-04 19:12   ` Anca Emanuel
2014-07-04 19:14     ` H. Peter Anvin
2014-07-04 19:16     ` Matthew Garrett
2014-07-03 21:07 ` [PATCH 3/9] pefile: Parse a PE binary and verify signature Vivek Goyal
2014-07-03 21:07 ` [PATCH 4/9] pefile: Strip the wrapper off of the cert data block Vivek Goyal
2014-07-03 21:07 ` [PATCH 5/9] pefile: Parse the presumed PKCS#7 content of the certificate blob Vivek Goyal
2014-07-03 21:07 ` [PATCH 6/9] pefile: Parse the "Microsoft individual code signing" data blob Vivek Goyal
2014-07-03 21:07 ` [PATCH 7/9] pefile: Digest the PE binary and compare to the PKCS#7 data Vivek Goyal
2014-07-03 21:07 ` Vivek Goyal [this message]
2014-07-03 21:07 ` [PATCH 9/9] kexec: Verify the signature of signed PE bzImage Vivek Goyal
2014-07-04 14:51 ` [RFC PATCH 0/9] kexec: Verify signature of PE signed bzImage Borislav Petkov
2014-07-05  3:01   ` Vivek Goyal
2014-07-08 15:54     ` Borislav Petkov
2014-07-08 16:07       ` Vivek Goyal
2014-07-08 16:12         ` Borislav Petkov

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=1404421641-12691-9-git-send-email-vgoyal@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=bp@alien8.de \
    --cc=chaowang@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=dyoung@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=greg@kroah.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=pjones@redhat.com \
    /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