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

Signed-off-by: David Howells <dhowe...@redhat.com>
Signed-off-by: Vivek Goyal <vgo...@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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to