|
|
4210fa |
From 868b3721159ee615a1b774645d610a13b5827e5e Mon Sep 17 00:00:00 2001
|
|
|
4210fa |
From: Gary Ching-Pang Lin <glin@suse.com>
|
|
|
4210fa |
Date: Thu, 31 Oct 2013 16:08:32 +0800
|
|
|
4210fa |
Subject: [PATCH 40/74] Check the secure variables with the lib functions
|
|
|
4210fa |
|
|
|
4210fa |
There are functions defined in lib to check the secure variables.
|
|
|
4210fa |
Use the functions to shun the duplicate code.
|
|
|
4210fa |
|
|
|
4210fa |
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
|
|
|
4210fa |
|
|
|
4210fa |
Conflicts:
|
|
|
4210fa |
shim.c
|
|
|
4210fa |
---
|
|
|
4210fa |
lib/variables.c | 14 ++++++++++----
|
|
|
4210fa |
shim.c | 32 ++------------------------------
|
|
|
4210fa |
2 files changed, 12 insertions(+), 34 deletions(-)
|
|
|
4210fa |
|
|
|
4210fa |
diff --git a/lib/variables.c b/lib/variables.c
|
|
|
4210fa |
index 3a9735e..4c64d7e 100644
|
|
|
4210fa |
--- a/lib/variables.c
|
|
|
4210fa |
+++ b/lib/variables.c
|
|
|
4210fa |
@@ -284,9 +284,12 @@ variable_is_setupmode(void)
|
|
|
4210fa |
/* set to 1 because we return true if SetupMode doesn't exist */
|
|
|
4210fa |
UINT8 SetupMode = 1;
|
|
|
4210fa |
UINTN DataSize = sizeof(SetupMode);
|
|
|
4210fa |
+ EFI_STATUS status;
|
|
|
4210fa |
|
|
|
4210fa |
- uefi_call_wrapper(RT->GetVariable, 5, L"SetupMode", &GV_GUID, NULL,
|
|
|
4210fa |
- &DataSize, &SetupMode);
|
|
|
4210fa |
+ status = uefi_call_wrapper(RT->GetVariable, 5, L"SetupMode", &GV_GUID, NULL,
|
|
|
4210fa |
+ &DataSize, &SetupMode);
|
|
|
4210fa |
+ if (EFI_ERROR(status))
|
|
|
4210fa |
+ return 1;
|
|
|
4210fa |
|
|
|
4210fa |
return SetupMode;
|
|
|
4210fa |
}
|
|
|
4210fa |
@@ -297,10 +300,13 @@ variable_is_secureboot(void)
|
|
|
4210fa |
/* return false if variable doesn't exist */
|
|
|
4210fa |
UINT8 SecureBoot = 0;
|
|
|
4210fa |
UINTN DataSize;
|
|
|
4210fa |
+ EFI_STATUS status;
|
|
|
4210fa |
|
|
|
4210fa |
DataSize = sizeof(SecureBoot);
|
|
|
4210fa |
- uefi_call_wrapper(RT->GetVariable, 5, L"SecureBoot", &GV_GUID, NULL,
|
|
|
4210fa |
- &DataSize, &SecureBoot);
|
|
|
4210fa |
+ status = uefi_call_wrapper(RT->GetVariable, 5, L"SecureBoot", &GV_GUID, NULL,
|
|
|
4210fa |
+ &DataSize, &SecureBoot);
|
|
|
4210fa |
+ if (EFI_ERROR(status))
|
|
|
4210fa |
+ return 0;
|
|
|
4210fa |
|
|
|
4210fa |
return SecureBoot;
|
|
|
4210fa |
}
|
|
|
4210fa |
diff --git a/shim.c b/shim.c
|
|
|
4210fa |
index 210e778..14fb601 100644
|
|
|
4210fa |
--- a/shim.c
|
|
|
4210fa |
+++ b/shim.c
|
|
|
4210fa |
@@ -475,44 +475,16 @@ static EFI_STATUS check_whitelist (WIN_CERTIFICATE_EFI_PKCS *cert,
|
|
|
4210fa |
|
|
|
4210fa |
static BOOLEAN secure_mode (void)
|
|
|
4210fa |
{
|
|
|
4210fa |
- EFI_STATUS status;
|
|
|
4210fa |
- EFI_GUID global_var = EFI_GLOBAL_VARIABLE;
|
|
|
4210fa |
- UINTN len;
|
|
|
4210fa |
- UINT8 *Data;
|
|
|
4210fa |
- UINT8 sb, setupmode;
|
|
|
4210fa |
-
|
|
|
4210fa |
if (user_insecure_mode)
|
|
|
4210fa |
return FALSE;
|
|
|
4210fa |
|
|
|
4210fa |
- status = get_variable(L"SecureBoot", &Data, &len, global_var);
|
|
|
4210fa |
- if (status != EFI_SUCCESS) {
|
|
|
4210fa |
+ if (variable_is_secureboot() != 1) {
|
|
|
4210fa |
if (verbose && !in_protocol)
|
|
|
4210fa |
console_notify(L"Secure boot not enabled");
|
|
|
4210fa |
return FALSE;
|
|
|
4210fa |
}
|
|
|
4210fa |
- sb = *Data;
|
|
|
4210fa |
- FreePool(Data);
|
|
|
4210fa |
-
|
|
|
4210fa |
- if (sb != 1) {
|
|
|
4210fa |
- if (verbose && !in_protocol)
|
|
|
4210fa |
- console_notify(L"Secure boot not enabled");
|
|
|
4210fa |
- return FALSE;
|
|
|
4210fa |
- }
|
|
|
4210fa |
-
|
|
|
4210fa |
- /* If we /do/ have "SecureBoot", but /don't/ have "SetupMode",
|
|
|
4210fa |
- * then the implementation is bad, but we assume that secure boot is
|
|
|
4210fa |
- * enabled according to the status of "SecureBoot". If we have both
|
|
|
4210fa |
- * of them, then "SetupMode" may tell us additional data, and we need
|
|
|
4210fa |
- * to consider it.
|
|
|
4210fa |
- */
|
|
|
4210fa |
- status = get_variable(L"SetupMode", &Data, &len, global_var);
|
|
|
4210fa |
- if (status != EFI_SUCCESS)
|
|
|
4210fa |
- return TRUE;
|
|
|
4210fa |
-
|
|
|
4210fa |
- setupmode = *Data;
|
|
|
4210fa |
- FreePool(Data);
|
|
|
4210fa |
|
|
|
4210fa |
- if (setupmode == 1) {
|
|
|
4210fa |
+ if (variable_is_setupmode() == 1) {
|
|
|
4210fa |
if (verbose && !in_protocol)
|
|
|
4210fa |
console_notify(L"Platform is in setup mode");
|
|
|
4210fa |
return FALSE;
|
|
|
4210fa |
--
|
|
|
4210fa |
1.9.3
|
|
|
4210fa |
|