[PATCH] security/integrity: Include __func__ in messages for easier debug

Shuah Khan skhan at linuxfoundation.org
Thu Jan 30 02:01:29 UTC 2020


Change messages to messages to make it easier to debug. The following
error message isn't informative enough to figure out what failed.

Couldn't get size: 0x800000000000000e

Change messages to include function information.

Signed-off-by: Shuah Khan <skhan at linuxfoundation.org>
---
 .../integrity/platform_certs/load_powerpc.c     | 14 ++++++++------
 security/integrity/platform_certs/load_uefi.c   | 17 ++++++++++-------
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/security/integrity/platform_certs/load_powerpc.c b/security/integrity/platform_certs/load_powerpc.c
index a2900cb85357..621454148fbc 100644
--- a/security/integrity/platform_certs/load_powerpc.c
+++ b/security/integrity/platform_certs/load_powerpc.c
@@ -25,7 +25,7 @@ static __init void *get_cert_list(u8 *key, unsigned long keylen, uint64_t *size)
 
 	rc = secvar_ops->get(key, keylen, NULL, size);
 	if (rc) {
-		pr_err("Couldn't get size: %d\n", rc);
+		pr_err("%s: Couldn't get size: %d\n", __func__, rc);
 		return NULL;
 	}
 
@@ -36,7 +36,7 @@ static __init void *get_cert_list(u8 *key, unsigned long keylen, uint64_t *size)
 	rc = secvar_ops->get(key, keylen, db, size);
 	if (rc) {
 		kfree(db);
-		pr_err("Error reading %s var: %d\n", key, rc);
+		pr_err("%s: Error reading %s var: %d\n", __func__, key, rc);
 		return NULL;
 	}
 
@@ -69,23 +69,25 @@ static int __init load_powerpc_certs(void)
 	 */
 	db = get_cert_list("db", 3, &dbsize);
 	if (!db) {
-		pr_err("Couldn't get db list from firmware\n");
+		pr_err("%s: Couldn't get db list from firmware\n", __func__);
 	} else {
 		rc = parse_efi_signature_list("powerpc:db", db, dbsize,
 					      get_handler_for_db);
 		if (rc)
-			pr_err("Couldn't parse db signatures: %d\n", rc);
+			pr_err("%s: Couldn't parse db signatures: %d\n",
+				__func__, rc);
 		kfree(db);
 	}
 
 	dbx = get_cert_list("dbx", 4,  &dbxsize);
 	if (!dbx) {
-		pr_info("Couldn't get dbx list from firmware\n");
+		pr_info("%s: Couldn't get dbx list from firmware\n", __func__);
 	} else {
 		rc = parse_efi_signature_list("powerpc:dbx", dbx, dbxsize,
 					      get_handler_for_dbx);
 		if (rc)
-			pr_err("Couldn't parse dbx signatures: %d\n", rc);
+			pr_err("%s: Couldn't parse dbx signatures: %d\n",
+				__func__, rc);
 		kfree(dbx);
 	}
 
diff --git a/security/integrity/platform_certs/load_uefi.c b/security/integrity/platform_certs/load_uefi.c
index 111898aad56e..c3cf6575abc1 100644
--- a/security/integrity/platform_certs/load_uefi.c
+++ b/security/integrity/platform_certs/load_uefi.c
@@ -44,7 +44,7 @@ static __init void *get_cert_list(efi_char16_t *name, efi_guid_t *guid,
 
 	status = efi.get_variable(name, guid, NULL, &lsize, &tmpdb);
 	if (status != EFI_BUFFER_TOO_SMALL) {
-		pr_err("Couldn't get size: 0x%lx\n", status);
+		pr_err("%s: Couldn't get size: 0x%lx\n", __func__, status);
 		return NULL;
 	}
 
@@ -55,7 +55,7 @@ static __init void *get_cert_list(efi_char16_t *name, efi_guid_t *guid,
 	status = efi.get_variable(name, guid, NULL, &lsize, db);
 	if (status != EFI_SUCCESS) {
 		kfree(db);
-		pr_err("Error reading db var: 0x%lx\n", status);
+		pr_err("%s: Error reading db var: 0x%lx\n", __func__, status);
 		return NULL;
 	}
 
@@ -85,13 +85,14 @@ static int __init load_uefi_certs(void)
 	if (!uefi_check_ignore_db()) {
 		db = get_cert_list(L"db", &secure_var, &dbsize);
 		if (!db) {
-			pr_err("MODSIGN: Couldn't get UEFI db list\n");
+			pr_err("%s: MODSIGN: Couldn't get UEFI db list\n",
+				__func__);
 		} else {
 			rc = parse_efi_signature_list("UEFI:db",
 					db, dbsize, get_handler_for_db);
 			if (rc)
-				pr_err("Couldn't parse db signatures: %d\n",
-				       rc);
+				pr_err("%s: Couldn't parse db signatures: %d\n",
+				       __func__, rc);
 			kfree(db);
 		}
 	}
@@ -103,7 +104,8 @@ static int __init load_uefi_certs(void)
 		rc = parse_efi_signature_list("UEFI:MokListRT",
 					      mok, moksize, get_handler_for_db);
 		if (rc)
-			pr_err("Couldn't parse MokListRT signatures: %d\n", rc);
+			pr_err("%s: Couldn't parse MokListRT signatures: %d\n",
+				__func__, rc);
 		kfree(mok);
 	}
 
@@ -115,7 +117,8 @@ static int __init load_uefi_certs(void)
 					      dbx, dbxsize,
 					      get_handler_for_dbx);
 		if (rc)
-			pr_err("Couldn't parse dbx signatures: %d\n", rc);
+			pr_err("%s: Couldn't parse dbx signatures: %d\n",
+				__func__, rc);
 		kfree(dbx);
 	}
 
-- 
2.20.1



More information about the Linux-security-module-archive mailing list