dbc4a9
From: Josh Boyer <jwboyer@fedoraproject.org>
dbc4a9
Date: Thu, 3 Oct 2013 10:14:23 -0400
dbc4a9
Subject: [PATCH] MODSIGN: Support not importing certs from db
dbc4a9
dbc4a9
If a user tells shim to not use the certs/hashes in the UEFI db variable
dbc4a9
for verification purposes, shim will set a UEFI variable called MokIgnoreDB.
dbc4a9
Have the uefi import code look for this and not import things from the db
dbc4a9
variable.
dbc4a9
dbc4a9
Signed-off-by: Josh Boyer <jwboyer@fedoraproject.org>
dbc4a9
---
dbc4a9
 kernel/modsign_uefi.c | 40 +++++++++++++++++++++++++++++++---------
dbc4a9
 1 file changed, 31 insertions(+), 9 deletions(-)
dbc4a9
dbc4a9
diff --git a/kernel/modsign_uefi.c b/kernel/modsign_uefi.c
dbc4a9
index 94b0eb38a284..ae28b974d49a 100644
dbc4a9
--- a/kernel/modsign_uefi.c
dbc4a9
+++ b/kernel/modsign_uefi.c
dbc4a9
@@ -8,6 +8,23 @@
dbc4a9
 #include <keys system_keyring.h="">
dbc4a9
 #include "module-internal.h"
dbc4a9
 
dbc4a9
+static __init int check_ignore_db(void)
dbc4a9
+{
dbc4a9
+	efi_status_t status;
dbc4a9
+	unsigned int db = 0;
dbc4a9
+	unsigned long size = sizeof(db);
dbc4a9
+	efi_guid_t guid = EFI_SHIM_LOCK_GUID;
dbc4a9
+
dbc4a9
+	/* Check and see if the MokIgnoreDB variable exists.  If that fails
dbc4a9
+	 * then we don't ignore DB.  If it succeeds, we do.
dbc4a9
+	 */
dbc4a9
+	status = efi.get_variable(L"MokIgnoreDB", &guid, NULL, &size, &db);
dbc4a9
+	if (status != EFI_SUCCESS)
dbc4a9
+		return 0;
dbc4a9
+
dbc4a9
+	return 1;
dbc4a9
+}
dbc4a9
+
dbc4a9
 static __init void *get_cert_list(efi_char16_t *name, efi_guid_t *guid, unsigned long *size)
dbc4a9
 {
dbc4a9
 	efi_status_t status;
dbc4a9
@@ -47,23 +64,28 @@ static int __init load_uefi_certs(void)
dbc4a9
 	efi_guid_t mok_var = EFI_SHIM_LOCK_GUID;
dbc4a9
 	void *db = NULL, *dbx = NULL, *mok = NULL;
dbc4a9
 	unsigned long dbsize = 0, dbxsize = 0, moksize = 0;
dbc4a9
-	int rc = 0;
dbc4a9
+	int ignore_db, rc = 0;
dbc4a9
 
dbc4a9
 	/* Check if SB is enabled and just return if not */
dbc4a9
 	if (!efi_enabled(EFI_SECURE_BOOT))
dbc4a9
 		return 0;
dbc4a9
 
dbc4a9
+	/* See if the user has setup Ignore DB mode */
dbc4a9
+	ignore_db = check_ignore_db();
dbc4a9
+
dbc4a9
 	/* Get db, MokListRT, and dbx.  They might not exist, so it isn't
dbc4a9
 	 * an error if we can't get them.
dbc4a9
 	 */
dbc4a9
-	db = get_cert_list(L"db", &secure_var, &dbsize);
dbc4a9
-	if (!db) {
dbc4a9
-		pr_err("MODSIGN: Couldn't get UEFI db list\n");
dbc4a9
-	} else {
dbc4a9
-		rc = parse_efi_signature_list(db, dbsize, system_trusted_keyring);
dbc4a9
-		if (rc)
dbc4a9
-			pr_err("Couldn't parse db signatures: %d\n", rc);
dbc4a9
-		kfree(db);
dbc4a9
+	if (!ignore_db) {
dbc4a9
+		db = get_cert_list(L"db", &secure_var, &dbsize);
dbc4a9
+		if (!db) {
dbc4a9
+			pr_err("MODSIGN: Couldn't get UEFI db list\n");
dbc4a9
+		} else {
dbc4a9
+			rc = parse_efi_signature_list(db, dbsize, system_trusted_keyring);
dbc4a9
+			if (rc)
dbc4a9
+				pr_err("Couldn't parse db signatures: %d\n", rc);
dbc4a9
+			kfree(db);
dbc4a9
+		}
dbc4a9
 	}
dbc4a9
 
dbc4a9
 	mok = get_cert_list(L"MokListRT", &mok_var, &moksize);
dbc4a9
-- 
c47527
2.1.0
dbc4a9