From: Linn Crosetto <linn@hpe.com>
To: matt@codeblueprint.co.uk, ard.biesheuvel@linaro.org,
roy.franz@linaro.org, mingo@kernel.org, mark.rutland@arm.com
Cc: linux-kernel@vger.kernel.org, Linn Crosetto <linn@hpe.com>
Subject: [PATCH v2 2/2] arm64/efi: check SetupMode when determining Secure Boot status
Date: Thu, 25 Feb 2016 17:18:15 -0700 [thread overview]
Message-ID: <1456445895-97647-3-git-send-email-linn@hpe.com> (raw)
In-Reply-To: <1456445895-97647-1-git-send-email-linn@hpe.com>
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. Minor cleanup, change sizeof to match kernel style guidelines.
Signed-off-by: Linn Crosetto <linn@hpe.com>
---
v2:
- Reformat quote from UEFI specification and note cleanup (Mark Rutland)
- Restructure code on top of changes in patch 1/2
drivers/firmware/efi/libstub/arm-stub.c | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index b1bb133..19e54d4 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -20,21 +20,39 @@
static int efi_get_secureboot(efi_system_table_t *sys_table_arg)
{
- static efi_guid_t const var_guid = EFI_GLOBAL_VARIABLE_GUID;
- static efi_char16_t const var_name[] = {
+ static efi_char16_t const sb_var_name[] = {
'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', 0 };
+ static efi_char16_t const sm_var_name[] = {
+ 'S', 'e', 't', 'u', 'p', 'M', 'o', 'd', 'e', 0 };
+ efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID;
efi_get_variable_t *f_getvar = sys_table_arg->runtime->get_variable;
- unsigned long size = sizeof(u8);
- efi_status_t status;
u8 val;
+ unsigned long size = sizeof(val);
+ efi_status_t status;
- status = f_getvar((efi_char16_t *)var_name, (efi_guid_t *)&var_guid,
+ status = f_getvar((efi_char16_t *)sb_var_name, (efi_guid_t *)&var_guid,
NULL, &size, &val);
+ if (status != EFI_SUCCESS)
+ goto out_efi_err;
+
+ if (val == 0)
+ return 0;
+
+ status = f_getvar((efi_char16_t *)sm_var_name, (efi_guid_t *)&var_guid,
+ NULL, &size, &val);
+
+ if (status != EFI_SUCCESS)
+ goto out_efi_err;
+
+ if (val == 1)
+ return 0;
+
+ return 1;
+
+out_efi_err:
switch (status) {
- case EFI_SUCCESS:
- return val;
case EFI_NOT_FOUND:
return 0;
case EFI_DEVICE_ERROR:
--
2.1.4
next prev parent reply other threads:[~2016-02-26 0:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-24 0:25 [PATCH] arm64/efi: check SetupMode when determining Secure Boot status Linn Crosetto
2016-02-24 11:23 ` Mark Rutland
2016-02-26 0:18 ` [PATCH v2 0/2] arm64/efi: query Secure Boot status according to UEFI spec Linn Crosetto
2016-02-26 0:18 ` [PATCH v2 1/2] arm64/efi: report unexpected errors when determining Secure Boot status Linn Crosetto
2016-03-03 8:03 ` Ard Biesheuvel
2016-02-26 0:18 ` Linn Crosetto [this message]
2016-03-02 13:38 ` [PATCH v2 0/2] arm64/efi: query Secure Boot status according to UEFI spec Matt Fleming
2016-03-03 21:45 ` [PATCH v3 " Linn Crosetto
2016-03-03 21:45 ` [PATCH v3 1/2] arm64/efi: report unexpected errors when determining Secure Boot status Linn Crosetto
2016-03-04 7:57 ` Ard Biesheuvel
2016-03-03 21:45 ` [PATCH v3 2/2] arm64/efi: check SetupMode " Linn Crosetto
2016-03-04 8:01 ` Ard Biesheuvel
2016-03-04 11:08 ` [PATCH v3 0/2] arm64/efi: query Secure Boot status according to UEFI spec Mark Rutland
2016-03-07 14:08 ` Matt Fleming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456445895-97647-3-git-send-email-linn@hpe.com \
--to=linn@hpe.com \
--cc=ard.biesheuvel@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=matt@codeblueprint.co.uk \
--cc=mingo@kernel.org \
--cc=roy.franz@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox