diff options
| author | Steve McIntyre <steve@einval.com> | 2021-04-21 00:25:20 +0100 |
|---|---|---|
| committer | Steve McIntyre <steve@einval.com> | 2021-04-21 00:25:20 +0100 |
| commit | 260b35a29f3aee1d91ada894eb1e69c0468674b0 (patch) | |
| tree | 1a57a94077fbd84db23a6310ea2a89a3e356e7f7 | |
| parent | cf870e72b009106bd3de7227994203f8cf2dbb74 (diff) | |
| download | efi-boot-shim-260b35a29f3aee1d91ada894eb1e69c0468674b0.tar.gz efi-boot-shim-260b35a29f3aee1d91ada894eb1e69c0468674b0.zip | |
Don't call QueryVariableInfo() on EFI 1.10 machines
New patch from upstream, don't break old Macs
| -rw-r--r-- | debian/patches/Don-t-call-QueryVariableInfo-on-EFI-1.10-machines.patch | 62 | ||||
| -rw-r--r-- | debian/patches/series | 1 |
2 files changed, 63 insertions, 0 deletions
diff --git a/debian/patches/Don-t-call-QueryVariableInfo-on-EFI-1.10-machines.patch b/debian/patches/Don-t-call-QueryVariableInfo-on-EFI-1.10-machines.patch new file mode 100644 index 00000000..74ae9eb5 --- /dev/null +++ b/debian/patches/Don-t-call-QueryVariableInfo-on-EFI-1.10-machines.patch @@ -0,0 +1,62 @@ +From 8b59591775a0412863aab9596ab87bdd493a9c1e Mon Sep 17 00:00:00 2001 +From: Peter Jones <pjones@redhat.com> +Date: Sat, 10 Apr 2021 16:05:23 -0400 +Subject: [PATCH] Don't call QueryVariableInfo() on EFI 1.10 machines + +The EFI 1.10 spec (and presumably earlier revisions as well) didn't have +RT->QueryVariableInfo(), and on Chris Murphy's MacBookPro8,2 , that +memory appears to be initialized randomly. + +This patch changes it to not call RT->QueryVariableInfo() if the +EFI_RUNTIME_SERVICES table's major revision is less than two, and +assumes our maximum variable size is 1024 in that case. + +Signed-off-by: Peter Jones <pjones@redhat.com> +--- + mok.c | 23 ++++++++++++++++++----- + 1 file changed, 18 insertions(+), 5 deletions(-) + +diff --git a/mok.c b/mok.c +index 9b8fc2bc..beac0ff6 100644 +--- a/mok.c ++++ b/mok.c +@@ -261,6 +261,9 @@ static const uint8_t null_sha256[32] = { 0, }; + + typedef UINTN SIZE_T; + ++#define EFI_MAJOR_VERSION(tablep) ((UINT16)((((tablep)->Hdr.Revision) >> 16) & 0xfffful)) ++#define EFI_MINOR_VERSION(tablep) ((UINT16)(((tablep)->Hdr.Revision) & 0xfffful)) ++ + static EFI_STATUS + get_max_var_sz(UINT32 attrs, SIZE_T *max_var_szp) + { +@@ -270,11 +273,21 @@ get_max_var_sz(UINT32 attrs, SIZE_T *max_var_szp) + uint64_t max_var_sz = 0; + + *max_var_szp = 0; +- efi_status = gRT->QueryVariableInfo(attrs, &max_storage_sz, +- &remaining_sz, &max_var_sz); +- if (EFI_ERROR(efi_status)) { +- perror(L"Could not get variable storage info: %r\n", efi_status); +- return efi_status; ++ if (EFI_MAJOR_VERSION(gRT) < 2) { ++ dprint(L"EFI %d.%d; no RT->QueryVariableInfo(). Using 1024!\n", ++ EFI_MAJOR_VERSION(gRT), EFI_MINOR_VERSION(gRT)); ++ max_var_sz = remaining_sz = max_storage_sz = 1024; ++ efi_status = EFI_SUCCESS; ++ } else { ++ dprint(L"calling RT->QueryVariableInfo() at 0x%lx\n", ++ gRT->QueryVariableInfo); ++ efi_status = gRT->QueryVariableInfo(attrs, &max_storage_sz, ++ &remaining_sz, &max_var_sz); ++ if (EFI_ERROR(efi_status)) { ++ perror(L"Could not get variable storage info: %r\n", ++ efi_status); ++ return efi_status; ++ } + } + + /* +-- +2.20.1 + diff --git a/debian/patches/series b/debian/patches/series index 0ffe2a27..20e12aa7 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,3 +1,4 @@ fix-import_one_mok_state.patch fix-broken-ia32-reloc.patch MOK-BootServicesData.patch +Don-t-call-QueryVariableInfo-on-EFI-1.10-machines.patch |
