Skip to content

Commit 30d7bf0

Browse files
Linn CrosettoIngo Molnar
authored andcommitted
efi/arm64: Check SetupMode when determining Secure Boot status
According to the UEFI specification (version 2.5 Errata A, page 87): The platform firmware is operating in secure boot mode if the value of the SetupMode variable is 0 and the SecureBoot variable is set to 1. A platform cannot operate in secure boot mode if the SetupMode variable is set to 1. Check the value of the SetupMode variable when determining the state of Secure Boot. Plus also do minor cleanup, change sizeof() use to match kernel style guidelines. Signed-off-by: Linn Crosetto <linn@hpe.com> Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Acked-by: Mark Rutland <mark.rutland@arm.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Roy Franz <roy.franz@linaro.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/1461614832-17633-6-git-send-email-matt@codeblueprint.co.uk Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 73a6492 commit 30d7bf0

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

drivers/firmware/efi/libstub/arm-stub.c

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,39 @@ bool __nokaslr;
2222

2323
static int efi_get_secureboot(efi_system_table_t *sys_table_arg)
2424
{
25-
static efi_guid_t const var_guid = EFI_GLOBAL_VARIABLE_GUID;
26-
static efi_char16_t const var_name[] = {
25+
static efi_char16_t const sb_var_name[] = {
2726
'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', 0 };
27+
static efi_char16_t const sm_var_name[] = {
28+
'S', 'e', 't', 'u', 'p', 'M', 'o', 'd', 'e', 0 };
2829

30+
efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID;
2931
efi_get_variable_t *f_getvar = sys_table_arg->runtime->get_variable;
30-
unsigned long size = sizeof(u8);
31-
efi_status_t status;
3232
u8 val;
33+
unsigned long size = sizeof(val);
34+
efi_status_t status;
3335

34-
status = f_getvar((efi_char16_t *)var_name, (efi_guid_t *)&var_guid,
36+
status = f_getvar((efi_char16_t *)sb_var_name, (efi_guid_t *)&var_guid,
3537
NULL, &size, &val);
3638

39+
if (status != EFI_SUCCESS)
40+
goto out_efi_err;
41+
42+
if (val == 0)
43+
return 0;
44+
45+
status = f_getvar((efi_char16_t *)sm_var_name, (efi_guid_t *)&var_guid,
46+
NULL, &size, &val);
47+
48+
if (status != EFI_SUCCESS)
49+
goto out_efi_err;
50+
51+
if (val == 1)
52+
return 0;
53+
54+
return 1;
55+
56+
out_efi_err:
3757
switch (status) {
38-
case EFI_SUCCESS:
39-
return val;
4058
case EFI_NOT_FOUND:
4159
return 0;
4260
case EFI_DEVICE_ERROR:

0 commit comments

Comments
 (0)