Hello community, here is the log from the commit of package shim for openSUSE:Factory checked in at 2013-12-06 11:48:26 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/shim (Old) and /work/SRC/openSUSE:Factory/.shim.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "shim" Changes: -------- --- /work/SRC/openSUSE:Factory/shim/shim.changes 2013-10-31 16:00:07.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.shim.new/shim.changes 2013-12-06 14:45:40.000000000 +0100 @@ -1,0 +2,33 @@ +Fri Dec 6 06:44:43 UTC 2013 - [email protected] + +- Add shim-mokmanager-handle-keystroke-error.patch to handle the + error status from ReadKeyStroke to avoid unexpected keys + +------------------------------------------------------------------- +Thu Dec 5 02:05:13 UTC 2013 - [email protected] + +- Update to 0.7 +- Add upstream patches: + + shim-fix-verify-mok.patch + + shim-improve-error-messages.patch + + shim-correct-user_insecure-usage.patch + + shim-fix-dhcpv4-path-generation.patch +- Add shim-mokx-support.patch to support the MOK blacklist + (Fate#316531) +- Drop upstreamed patches + + shim-fix-pointer-casting.patch + + shim-merge-lf-loader-code.patch + + shim-fix-simple-file-selector.patch + + shim-mokmanager-support-crypt-hash-method.patch + + shim-bnc804631-fix-broken-bootpath.patch + + shim-bnc798043-no-doulbe-separators.patch + + shim-bnc807760-change-pxe-2nd-loader-name.patch + + shim-bnc808106-correct-certcount.patch + + shim-mokmanager-ui-revamp.patch + + shim-netboot-fixes.patch + + shim-mokmanager-disable-gfx-console.patch +- Drop shim-suse-build.patch: it's not necessary anymore +- Drop shim-bnc841426-silence-shim-protocols.patch: shim is not + verbose by default + +------------------------------------------------------------------- Old: ---- shim-0.4.tar.bz2 shim-bnc798043-no-doulbe-separators.patch shim-bnc804631-fix-broken-bootpath.patch shim-bnc807760-change-pxe-2nd-loader-name.patch shim-bnc808106-correct-certcount.patch shim-bnc841426-silence-shim-protocols.patch shim-fix-pointer-casting.patch shim-fix-simple-file-selector.patch shim-merge-lf-loader-code.patch shim-mokmanager-disable-gfx-console.patch shim-mokmanager-support-crypt-hash-method.patch shim-mokmanager-ui-revamp.patch shim-netboot-fixes.patch shim-suse-build.patch New: ---- shim-0.7.tar.bz2 shim-correct-user_insecure-usage.patch shim-fix-dhcpv4-path-generation.patch shim-fix-verify-mok.patch shim-improve-error-messages.patch shim-mokmanager-handle-keystroke-error.patch shim-mokx-support.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ shim.spec ++++++ --- /var/tmp/diff_new_pack.qXYoka/_old 2013-12-06 14:45:41.000000000 +0100 +++ /var/tmp/diff_new_pack.qXYoka/_new 2013-12-06 14:45:41.000000000 +0100 @@ -19,7 +19,7 @@ # needssslcertforbuild Name: shim -Version: 0.4 +Version: 0.7 Release: 0 Summary: UEFI shim loader License: BSD-2-Clause @@ -38,32 +38,18 @@ Source8: show_signatures.sh Source9: openSUSE-UEFI-CA-Certificate-4096.crt Source10: timestamp.pl -# PATCH-FIX-SUSE shim-suse-build.patch [email protected] -- Adjust Makefile for the build service -Patch0: shim-suse-build.patch -# PATCH-FIX-UPSTREAM shim-fix-pointer-casting.patch [email protected] -- Fix a casting issue and the size of an empty vendor_cert or dbx_cert. -Patch1: shim-fix-pointer-casting.patch -# PATCH-FIX-UPSTREAM shim-merge-lf-loader-code.patch [email protected] -- Merge the Linux Foundation loader UI code -Patch2: shim-merge-lf-loader-code.patch -# PATCH-FIX-UPSTREAM shim-fix-simple-file-selector.patch [email protected] -- Fix the buffer allocation in the simple file selector -Patch3: shim-fix-simple-file-selector.patch -# PATCH-FIX-UPSTREAM shim-mokmanager-support-crypt-hash-method.patch [email protected] -- Support the password hashes from /etc/shadow -Patch4: shim-mokmanager-support-crypt-hash-method.patch -# PATCH-FIX-UPSTREAM shim-bnc804631-fix-broken-bootpath.patch bnc#804631 [email protected] -- Fix the broken bootpath generated in generate_path() -Patch5: shim-bnc804631-fix-broken-bootpath.patch -# PATCH-FIX-UPSTREAM shim-bnc798043-no-doulbe-separators.patch bnc#798043 [email protected] -- Remove all double-separators from the bootpath -Patch6: shim-bnc798043-no-doulbe-separators.patch -# PATCH-FIX-UPSTREAM shim-bnc807760-change-pxe-2nd-loader-name.patch bnc#807760 [email protected] -- Change the PXE 2nd stage loader to match the filename we are using -Patch7: shim-bnc807760-change-pxe-2nd-loader-name.patch -# PATCH-FIX-UPSTREAM shim-bnc808106-correct-certcount.patch bnc#808106 [email protected] -- Correct the certifcate count of the signature list -Patch8: shim-bnc808106-correct-certcount.patch -# PATCH-FIX-UPSTREAM shim-mokmanager-ui-revamp.patch [email protected] -- Revamp the MokManager UI -Patch9: shim-mokmanager-ui-revamp.patch -# PATCH-FIX-UPSTREAM shim-netboot-fixes.patch [email protected] -- Upstream netboot fixes -Patch10: shim-netboot-fixes.patch -# PATCH-FIX-UPSTREAM shim-mokmanager-disable-gfx-console.patch [email protected] -- Disable graphics console to avoid system hang on some machines -Patch11: shim-mokmanager-disable-gfx-console.patch -# PATCH-FIX-UPSTREAM shim-bnc841426-silence-shim-protocols.patch bnc#841426 [email protected] -- Silence the shim protocols to avoid system hang -Patch12: shim-bnc841426-silence-shim-protocols.patch +# PATCH-FIX-UPSTREAM shim-fix-verify-mok.patch [email protected] -- Fix the error handling in verify_mok() +Patch1: shim-fix-verify-mok.patch +# PATCH-FIX-UPSTREAM shim-improve-error-messages.patch [email protected] -- Improve the error messages +Patch2: shim-improve-error-messages.patch +# PATCH-FIX-UPSTREAM shim-correct-user_insecure-usage.patch [email protected] -- Correct the usage of the user insecure mode variable +Patch3: shim-correct-user_insecure-usage.patch +# PATCH-FIX-UPSTREAM shim-fix-dhcpv4-path-generation.patch [email protected] -- Fix path generation for DHCPv4 bootloader +Patch4: shim-fix-dhcpv4-path-generation.patch +# PATCH-FIX-UPSTREAM shim-mokx-support.patch [email protected] -- Support MOK blacklist +Patch5: shim-mokx-support.patch +# PATCH-FIX-UPSTREAM shim-mokmanager-handle-keystroke-error.patch [email protected] -- Handle the error status from ReadKeyStroke to avoid the unexpected keys +Patch6: shim-mokmanager-handle-keystroke-error.patch BuildRequires: gnu-efi >= 3.0t BuildRequires: mozilla-nss-tools BuildRequires: openssl >= 0.9.8 @@ -86,26 +72,17 @@ %prep %setup -q -%patch0 -p1 %patch1 -p1 %patch2 -p1 %patch3 -p1 %patch4 -p1 %patch5 -p1 %patch6 -p1 -%patch7 -p1 -%patch8 -p1 -%patch9 -p1 -%patch10 -p1 -%patch11 -p1 -%patch12 -p1 %build -chmod +x "make-certs" - # first, build MokManager and fallback as they don't depend on a # specific certificate -make MokManager.efi fallback.efi 2>/dev/null +make EFI_PATH=/usr/lib64 MokManager.efi fallback.efi 2>/dev/null # now build variants of shim that embed different certificates default='' @@ -154,7 +131,7 @@ rm -f shim.cer fi # make sure cast warnings don't trigger post build check - make VENDOR_CERT_FILE=shim-$suffix.der shim.efi 2>/dev/null + make EFI_PATH=/usr/lib64 VENDOR_CERT_FILE=shim-$suffix.der shim.efi 2>/dev/null # make VENDOR_CERT_FILE=cert.der VENDOR_DBX_FILE=dbx chmod 755 %{SOURCE6} %{SOURCE7} %{SOURCE10} # alternative: verify signature ++++++ shim-0.4.tar.bz2 -> shim-0.7.tar.bz2 ++++++ ++++ 13487 lines of diff (skipped) ++++++ shim-correct-user_insecure-usage.patch ++++++ commit d95b24bd02cf41cca9adebd95f10609d6424d2b3 Author: Matthew Garrett <[email protected]> Date: Tue Nov 19 10:09:13 2013 -0500 Clarify meaning of insecure_mode insecure_mode was intended to indicate that the user had explicity disabled checks with mokutil, which means it wasn't the opposite of secure_mode(). Change the names to clarify this and don't show the insecure mode message unless the user has explicitly enabled that mode. Signed-off-by: Matthew Garrett <[email protected]> diff --git a/replacements.c b/replacements.c index bac5e5d..5ea5c32 100644 --- a/replacements.c +++ b/replacements.c @@ -64,13 +64,9 @@ static typeof(systab->BootServices->StartImage) system_start_image; static typeof(systab->BootServices->Exit) system_exit; static typeof(systab->BootServices->ExitBootServices) system_exit_boot_services; -extern UINT8 insecure_mode; - void unhook_system_services(void) { - if (insecure_mode) - return; systab->BootServices->Exit = system_exit; systab->BootServices->StartImage = system_start_image; systab->BootServices->ExitBootServices = system_exit_boot_services; @@ -123,8 +119,6 @@ exit(EFI_HANDLE ImageHandle, EFI_STATUS ExitStatus, void hook_system_services(EFI_SYSTEM_TABLE *local_systab) { - if (insecure_mode) - return; systab = local_systab; /* We need to hook various calls to make this work... */ diff --git a/shim.c b/shim.c index 9ae1936..524f5fc 100644 --- a/shim.c +++ b/shim.c @@ -85,7 +85,7 @@ int loader_is_participating; #define EFI_IMAGE_SECURITY_DATABASE_GUID { 0xd719b2cb, 0x3d3a, 0x4596, { 0xa3, 0xbc, 0xda, 0xd0, 0x0e, 0x67, 0x65, 0x6f }} -UINT8 insecure_mode; +UINT8 user_insecure_mode; UINT8 ignore_db; typedef enum { @@ -456,7 +456,7 @@ static BOOLEAN secure_mode (void) UINT8 *Data; UINT8 sb, setupmode; - if (insecure_mode) + if (user_insecure_mode) return FALSE; status = get_variable(L"SecureBoot", &Data, &len, global_var); @@ -1534,7 +1534,7 @@ static EFI_STATUS check_mok_sb (void) UINTN MokSBStateSize = 0; UINT32 attributes; - insecure_mode = 0; + user_insecure_mode = 0; ignore_db = 0; status = get_variable_attr(L"MokSBState", &MokSBState, &MokSBStateSize, @@ -1555,7 +1555,7 @@ static EFI_STATUS check_mok_sb (void) status = EFI_ACCESS_DENIED; } else { if (*(UINT8 *)MokSBState == 1) { - insecure_mode = 1; + user_insecure_mode = 1; } } @@ -1753,10 +1753,10 @@ EFI_STATUS efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *passed_systab) /* * Tell the user that we're in insecure mode if necessary */ - if (!secure_mode()) { + if (user_insecure_mode) { Print(L"Booting in insecure mode\n"); uefi_call_wrapper(BS->Stall, 1, 2000000); - } else { + } else if (secure_mode()) { /* * Install our hooks for ExitBootServices() and StartImage() */ ++++++ shim-fix-dhcpv4-path-generation.patch ++++++ >From e62b69a5b0b87c6df7a4fc23906134945309e927 Mon Sep 17 00:00:00 2001 From: Peter Jones <[email protected]> Date: Wed, 20 Nov 2013 12:20:23 -0500 Subject: [PATCH 1/2] Fix path generation for Dhcpv4 bootloader. Right now we always look for e.g. "\grubx64.efi", which is completely wrong. This makes it look for the path shim was loaded from and modify that to end in a sanitized version of our default loader name. Resolves: rhbz#1032583 Signed-off-by: Peter Jones <[email protected]> --- include/str.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ netboot.c | 28 +++++++++++++++++++++------- 2 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 include/str.h diff --git a/include/str.h b/include/str.h new file mode 100644 index 0000000..0f3e003 --- /dev/null +++ b/include/str.h @@ -0,0 +1,45 @@ +#ifndef SHIM_STR_H +#define SHIM_STR_H + +static inline +__attribute__((unused)) +unsigned long strnlena(const CHAR8 *s, unsigned long n) +{ + unsigned long i; + for (i = 0; i <= n; i++) + if (s[i] == '\0') + break; + return i; +} + +static inline +__attribute__((unused)) +CHAR8 * +strncpya(CHAR8 *dest, const CHAR8 *src, unsigned long n) +{ + unsigned long i; + + for (i = 0; i < n && src[i] != '\0'; i++) + dest[i] = src[i]; + for (; i < n; i++) + dest[i] = '\0'; + + return dest; +} + +static inline +__attribute__((unused)) +CHAR8 * +strcata(CHAR8 *dest, const CHAR8 *src) +{ + unsigned long dest_len = strlena(dest); + unsigned long i; + + for (i = 0; src[i] != '\0'; i++) + dest[dest_len + i] = src[i]; + dest[dest_len + i] = '\0'; + + return dest; +} + +#endif /* SHIM_STR_H */ diff --git a/netboot.c b/netboot.c index a83c82a..1732dc7 100644 --- a/netboot.c +++ b/netboot.c @@ -38,6 +38,7 @@ #include <string.h> #include "shim.h" #include "netboot.h" +#include "str.h" static inline unsigned short int __swap16(unsigned short int x) { @@ -305,19 +306,32 @@ static EFI_STATUS parseDhcp6() static EFI_STATUS parseDhcp4() { - CHAR8 *template = (CHAR8 *)DEFAULT_LOADER_CHAR; - full_path = AllocateZeroPool(strlen(template)+1); + CHAR8 *template = (CHAR8 *)translate_slashes(DEFAULT_LOADER_CHAR); + UINTN template_len = strlen(template) + 1; + + UINTN dir_len = strnlena(pxe->Mode->DhcpAck.Dhcpv4.BootpBootFile, 127); + UINTN i; + UINT8 *dir = pxe->Mode->DhcpAck.Dhcpv4.BootpBootFile; + + for (i = dir_len; i >= 0; i--) { + if (dir[i] == '/') + break; + } + dir_len = (i >= 0) ? i + 1 : 0; + + full_path = AllocateZeroPool(dir_len + template_len); if (!full_path) return EFI_OUT_OF_RESOURCES; + if (dir_len > 0) { + strncpya(full_path, dir, dir_len); + if (full_path[dir_len-1] == '/' && template[0] == '/') + full_path[dir_len-1] = '\0'; + } + strcata(full_path, template); memcpy(&tftp_addr.v4, pxe->Mode->DhcpAck.Dhcpv4.BootpSiAddr, 4); - memcpy(full_path, template, strlen(template)); - - /* Note we don't capture the filename option here because we know its shim.efi - * We instead assume the filename at the end of the path is going to be grubx64.efi - */ return EFI_SUCCESS; } -- 1.8.1.4 >From 27129a5a05d1947e6f7479766e8281d50d6031f6 Mon Sep 17 00:00:00 2001 From: Peter Jones <[email protected]> Date: Thu, 21 Nov 2013 11:26:08 -0500 Subject: [PATCH 2/2] Lengths that might be -1 can't be unsigned, Peter. Signed-off-by: Peter Jones <[email protected]> --- netboot.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/netboot.c b/netboot.c index 1732dc7..07e2773 100644 --- a/netboot.c +++ b/netboot.c @@ -307,10 +307,10 @@ static EFI_STATUS parseDhcp6() static EFI_STATUS parseDhcp4() { CHAR8 *template = (CHAR8 *)translate_slashes(DEFAULT_LOADER_CHAR); - UINTN template_len = strlen(template) + 1; + INTN template_len = strlen(template) + 1; - UINTN dir_len = strnlena(pxe->Mode->DhcpAck.Dhcpv4.BootpBootFile, 127); - UINTN i; + INTN dir_len = strnlena(pxe->Mode->DhcpAck.Dhcpv4.BootpBootFile, 127); + INTN i; UINT8 *dir = pxe->Mode->DhcpAck.Dhcpv4.BootpBootFile; for (i = dir_len; i >= 0; i--) { @@ -329,6 +329,8 @@ static EFI_STATUS parseDhcp4() if (full_path[dir_len-1] == '/' && template[0] == '/') full_path[dir_len-1] = '\0'; } + if (dir_len == 0 && dir[0] != '/' && template[0] == '/') + template++; strcata(full_path, template); memcpy(&tftp_addr.v4, pxe->Mode->DhcpAck.Dhcpv4.BootpSiAddr, 4); -- 1.8.1.4 ++++++ shim-fix-verify-mok.patch ++++++ commit 11495d4019d44dce1487939f91f7d751ffbb9730 Author: Andrew Boie <[email protected]> Date: Mon Apr 15 14:11:17 2013 -0700 fix verify_mok() () Fix the return value semantics. If the MokList doesn't exist, we are OK. If the MokList was compromised but we were able to erase it, that is OK too. Only if the list can't be nuked do we return an error. () Fix use of potentially uninitialized attribute variable () Actually use the return value when called from verify_buffer. Change-Id: If16df21d79c52a1726928df96d133390cde4cb7e Signed-off-by: Andrew Boie <[email protected]> diff --git a/shim.c b/shim.c index 23dd0ee..dcb36d0 100644 --- a/shim.c +++ b/shim.c @@ -670,13 +670,12 @@ static EFI_STATUS verify_mok (void) { status = get_variable_attr(L"MokList", &MokListData, &MokListDataSize, shim_lock_guid, &attributes); - if (attributes & EFI_VARIABLE_RUNTIME_ACCESS) { + if (!EFI_ERROR(status) && attributes & EFI_VARIABLE_RUNTIME_ACCESS) { Print(L"MokList is compromised!\nErase all keys in MokList!\n"); if (LibDeleteVariable(L"MokList", &shim_lock_guid) != EFI_SUCCESS) { Print(L"Failed to erase MokList\n"); + return EFI_ACCESS_DENIED; } - status = EFI_ACCESS_DENIED; - return status; } if (MokListData) @@ -722,7 +721,9 @@ static EFI_STATUS verify_buffer (char *data, int datasize, /* * Check that the MOK database hasn't been modified */ - verify_mok(); + status = verify_mok(); + if (status != EFI_SUCCESS) + return status; /* * Ensure that the binary isn't blacklisted ++++++ shim-improve-error-messages.patch ++++++ commit 2f09d0ab290d9b0d8aa14c3243f1d85a20bc34e6 Author: Andrew Boie <[email protected]> Date: Mon Nov 11 17:29:06 2013 -0800 shim: improve error messages %r when used in Print() will show a string representation of an EFI_STATUS code. Change-Id: I6db47f5213454603bd66177aca378ad01e9f0bd4 Signed-off-by: Andrew Boie <[email protected]> diff --git a/shim.c b/shim.c index a043779..9ae1936 100644 --- a/shim.c +++ b/shim.c @@ -914,7 +914,7 @@ static EFI_STATUS handle_image (void *data, unsigned int datasize, */ efi_status = read_header(data, datasize, &context); if (efi_status != EFI_SUCCESS) { - Print(L"Failed to read header\n"); + Print(L"Failed to read header: %r\n", efi_status); return efi_status; } @@ -981,7 +981,7 @@ static EFI_STATUS handle_image (void *data, unsigned int datasize, efi_status = relocate_coff(&context, buffer); if (efi_status != EFI_SUCCESS) { - Print(L"Relocation failed\n"); + Print(L"Relocation failed: %r\n", efi_status); FreePool(buffer); return efi_status; } @@ -1022,7 +1022,7 @@ should_use_fallback(EFI_HANDLE image_handle) rc = uefi_call_wrapper(BS->HandleProtocol, 3, image_handle, &loaded_image_protocol, (void **)&li); if (EFI_ERROR(rc)) { - Print(L"Could not get image for bootx64.efi: %d\n", rc); + Print(L"Could not get image for bootx64.efi: %r\n", rc); return 0; } @@ -1044,13 +1044,13 @@ should_use_fallback(EFI_HANDLE image_handle) rc = uefi_call_wrapper(BS->HandleProtocol, 3, li->DeviceHandle, &FileSystemProtocol, (void **)&fio); if (EFI_ERROR(rc)) { - Print(L"Could not get fio for li->DeviceHandle: %d\n", rc); + Print(L"Could not get fio for li->DeviceHandle: %r\n", rc); return 0; } rc = uefi_call_wrapper(fio->OpenVolume, 2, fio, &vh); if (EFI_ERROR(rc)) { - Print(L"Could not open fio volume: %d\n", rc); + Print(L"Could not open fio volume: %r\n", rc); return 0; } @@ -1172,14 +1172,14 @@ static EFI_STATUS load_image (EFI_LOADED_IMAGE *li, void **data, (void **)&drive); if (efi_status != EFI_SUCCESS) { - Print(L"Failed to find fs\n"); + Print(L"Failed to find fs: %r\n", efi_status); goto error; } efi_status = uefi_call_wrapper(drive->OpenVolume, 2, drive, &root); if (efi_status != EFI_SUCCESS) { - Print(L"Failed to open fs\n"); + Print(L"Failed to open fs: %r\n", efi_status); goto error; } @@ -1190,7 +1190,7 @@ static EFI_STATUS load_image (EFI_LOADED_IMAGE *li, void **data, EFI_FILE_MODE_READ, 0); if (efi_status != EFI_SUCCESS) { - Print(L"Failed to open %s - %lx\n", PathName, efi_status); + Print(L"Failed to open %s - %r\n", PathName, efi_status); goto error; } @@ -1223,7 +1223,7 @@ static EFI_STATUS load_image (EFI_LOADED_IMAGE *li, void **data, } if (efi_status != EFI_SUCCESS) { - Print(L"Unable to get file info\n"); + Print(L"Unable to get file info: %r\n", efi_status); goto error; } @@ -1251,7 +1251,7 @@ static EFI_STATUS load_image (EFI_LOADED_IMAGE *li, void **data, } if (efi_status != EFI_SUCCESS) { - Print(L"Unexpected return from initial read: %x, buffersize %x\n", efi_status, buffersize); + Print(L"Unexpected return from initial read: %r, buffersize %x\n", efi_status, buffersize); goto error; } @@ -1328,20 +1328,20 @@ EFI_STATUS start_image(EFI_HANDLE image_handle, CHAR16 *ImagePath) efi_status = generate_path(li, ImagePath, &path, &PathName); if (efi_status != EFI_SUCCESS) { - Print(L"Unable to generate path: %s\n", ImagePath); + Print(L"Unable to generate path %s: %r\n", ImagePath, efi_status); goto done; } if (findNetboot(image_handle)) { efi_status = parseNetbootinfo(image_handle); if (efi_status != EFI_SUCCESS) { - Print(L"Netboot parsing failed: %d\n", efi_status); + Print(L"Netboot parsing failed: %r\n", efi_status); return EFI_PROTOCOL_ERROR; } efi_status = FetchNetbootimage(image_handle, &sourcebuffer, &sourcesize); if (efi_status != EFI_SUCCESS) { - Print(L"Unable to fetch TFTP image\n"); + Print(L"Unable to fetch TFTP image: %r\n", efi_status); return efi_status; } data = sourcebuffer; @@ -1353,7 +1353,7 @@ EFI_STATUS start_image(EFI_HANDLE image_handle, CHAR16 *ImagePath) efi_status = load_image(li, &data, &datasize, PathName); if (efi_status != EFI_SUCCESS) { - Print(L"Failed to load image\n"); + Print(L"Failed to load image %s: %r\n", PathName, efi_status); goto done; } } @@ -1370,7 +1370,7 @@ EFI_STATUS start_image(EFI_HANDLE image_handle, CHAR16 *ImagePath) efi_status = handle_image(data, datasize, li); if (efi_status != EFI_SUCCESS) { - Print(L"Failed to load image\n"); + Print(L"Failed to load image: %r\n", efi_status); CopyMem(li, &li_bak, sizeof(li_bak)); goto done; } @@ -1473,7 +1473,7 @@ EFI_STATUS mirror_mok_list() | EFI_VARIABLE_RUNTIME_ACCESS, FullDataSize, FullData); if (efi_status != EFI_SUCCESS) { - Print(L"Failed to set MokListRT %d\n", efi_status); + Print(L"Failed to set MokListRT: %r\n", efi_status); } return efi_status; @@ -1514,7 +1514,7 @@ EFI_STATUS check_mok_request(EFI_HANDLE image_handle) efi_status = start_image(image_handle, MOK_MANAGER); if (efi_status != EFI_SUCCESS) { - Print(L"Failed to start MokManager\n"); + Print(L"Failed to start MokManager: %r\n", efi_status); return efi_status; } } @@ -1621,7 +1621,7 @@ static EFI_STATUS mok_ignore_db() | EFI_VARIABLE_RUNTIME_ACCESS, DataSize, (void *)&Data); if (efi_status != EFI_SUCCESS) { - Print(L"Failed to set MokIgnoreDB %d\n", efi_status); + Print(L"Failed to set MokIgnoreDB: %r\n", efi_status); } } @@ -1648,7 +1648,7 @@ EFI_STATUS set_second_stage (EFI_HANDLE image_handle) status = uefi_call_wrapper(BS->HandleProtocol, 3, image_handle, &LoadedImageProtocol, (void **) &li); if (status != EFI_SUCCESS) { - Print (L"Failed to get load options\n"); + Print (L"Failed to get load options: %r\n", status); return status; } ++++++ shim-mokmanager-handle-keystroke-error.patch ++++++ >From 7edfcaa6e03c8aa1ce39e8eb193d2064f4119342 Mon Sep 17 00:00:00 2001 From: Gary Ching-Pang Lin <[email protected]> Date: Tue, 3 Dec 2013 15:52:02 +0800 Subject: [PATCH] MokManager: handle the error status from ReadKeyStroke On some machines, even though the key event was signaled, ReadKeyStroke still got EFI_NOT_READY. This commit handles the error status to avoid console_get_keystroke from returning unexpected keys. Signed-off-by: Gary Ching-Pang Lin <[email protected]> --- MokManager.c | 17 +++++++++++++---- include/console.h | 4 ++-- lib/console.c | 26 ++++++++++++++++++-------- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/MokManager.c b/MokManager.c index f5ed379..d700fa8 100644 --- a/MokManager.c +++ b/MokManager.c @@ -488,13 +488,19 @@ static EFI_STATUS list_keys (void *KeyList, UINTN KeyListSize, CHAR16 *title) return EFI_SUCCESS; } -static UINT8 get_line (UINT32 *length, CHAR16 *line, UINT32 line_max, UINT8 show) +static EFI_STATUS get_line (UINT32 *length, CHAR16 *line, UINT32 line_max, UINT8 show) { EFI_INPUT_KEY key; + EFI_STATUS status; int count = 0; do { - key = console_get_keystroke(); + status = console_get_keystroke(&key); + if (EFI_ERROR (status)) { + console_error(L"Failed to read the keystroke", status); + *length = 0; + return status; + } if ((count >= line_max && key.UnicodeChar != CHAR_BACKSPACE) || @@ -525,7 +531,7 @@ static UINT8 get_line (UINT32 *length, CHAR16 *line, UINT32 line_max, UINT8 show *length = count; - return 1; + return EFI_SUCCESS; } static EFI_STATUS compute_pw_hash (void *Data, UINTN DataSize, UINT8 *password, @@ -989,6 +995,7 @@ static INTN mok_deletion_prompt (void *MokDel, UINTN MokDelSize) static CHAR16 get_password_charater (CHAR16 *prompt) { SIMPLE_TEXT_OUTPUT_MODE SavedMode; + EFI_STATUS status; CHAR16 *message[2]; CHAR16 character; UINTN length; @@ -1003,7 +1010,9 @@ static CHAR16 get_password_charater (CHAR16 *prompt) message[1] = NULL; length = StrLen(message[0]); console_print_box_at(message, -1, -length-4, -5, length+4, 3, 0, 1); - get_line(&pw_length, &character, 1, 0); + status = get_line(&pw_length, &character, 1, 0); + if (EFI_ERROR(status)) + character = 0; console_restore_mode(&SavedMode); diff --git a/include/console.h b/include/console.h index e6c2818..9c793ea 100644 --- a/include/console.h +++ b/include/console.h @@ -1,8 +1,8 @@ #ifndef _SHIM_LIB_CONSOLE_H #define _SHIM_LIB_CONSOLE_H 1 -EFI_INPUT_KEY -console_get_keystroke(void); +EFI_STATUS +console_get_keystroke(EFI_INPUT_KEY *key); void console_print_box_at(CHAR16 *str_arr[], int highlight, int start_col, int start_row, int size_cols, int size_rows, int offset, int lines); void diff --git a/lib/console.c b/lib/console.c index 2fc8db3..41ed83a 100644 --- a/lib/console.c +++ b/lib/console.c @@ -40,16 +40,18 @@ SetMem16(CHAR16 *dst, UINT32 n, CHAR16 c) } } -EFI_INPUT_KEY -console_get_keystroke(void) +EFI_STATUS +console_get_keystroke(EFI_INPUT_KEY *key) { - EFI_INPUT_KEY key; UINTN EventIndex; + EFI_STATUS status; - uefi_call_wrapper(BS->WaitForEvent, 3, 1, &ST->ConIn->WaitForKey, &EventIndex); - uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &key); + do { + uefi_call_wrapper(BS->WaitForEvent, 3, 1, &ST->ConIn->WaitForKey, &EventIndex); + status = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, key); + } while (status == EFI_NOT_READY); - return key; + return status; } void @@ -162,6 +164,8 @@ console_print_box(CHAR16 *str_arr[], int highlight) { SIMPLE_TEXT_OUTPUT_MODE SavedConsoleMode; SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut; + EFI_INPUT_KEY key; + CopyMem(&SavedConsoleMode, co->Mode, sizeof(SavedConsoleMode)); uefi_call_wrapper(co->EnableCursor, 2, co, FALSE); uefi_call_wrapper(co->SetAttribute, 2, co, EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE); @@ -169,7 +173,7 @@ console_print_box(CHAR16 *str_arr[], int highlight) console_print_box_at(str_arr, highlight, 0, 0, -1, -1, 0, count_lines(str_arr)); - console_get_keystroke(); + console_get_keystroke(&key); uefi_call_wrapper(co->EnableCursor, 2, co, SavedConsoleMode.CursorVisible); @@ -184,6 +188,7 @@ console_select(CHAR16 *title[], CHAR16* selectors[], int start) SIMPLE_TEXT_OUTPUT_MODE SavedConsoleMode; SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut; EFI_INPUT_KEY k; + EFI_STATUS status; int selector; int selector_lines = count_lines(selectors); int selector_max_cols = 0; @@ -237,7 +242,12 @@ console_select(CHAR16 *title[], CHAR16* selectors[], int start) size_cols, size_rows, 0, lines); do { - k = console_get_keystroke(); + status = console_get_keystroke(&k); + if (EFI_ERROR (status)) { + Print(L"Failed to read the keystroke: %r", status); + selector = -1; + break; + } if (k.ScanCode == SCAN_ESC) { selector = -1; -- 1.8.4 ++++++ shim-mokx-support.patch ++++++ ++++ 1162 lines (skipped) -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
