From ada7ff69bd8a95614aa63dd618764daf428f235d Mon Sep 17 00:00:00 2001 From: Gary Lin Date: Fri, 4 Jun 2021 17:02:31 +0800 Subject: [PATCH 22/35] shim: don't fail on the odd LoadOptions length Some firmware feeds the LoadOptions with an odd length when booting from an USB device(*). We should only skip this kind of LoadOptions, not fail it, or the user won't be able to boot the system from USB or CD-ROM. (*) https://bugzilla.suse.com/show_bug.cgi?id=1185232#c62 Signed-off-by: Gary Lin --- load-options.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/load-options.c b/load-options.c index 480832c1..e34aa381 100644 --- a/load-options.c +++ b/load-options.c @@ -310,9 +310,17 @@ parse_load_options(EFI_LOADED_IMAGE *li) UINT32 remaining_size; CHAR16 *loader_str = NULL; - /* Sanity check since we make several assumptions about the length */ + /* + * Sanity check since we make several assumptions about the length + * Some firmware feeds the following load option when booting from + * an USB device: + * + * 0x46 0x4a 0x00 |FJ.| + * + * The string is meaningless for shim and so just ignore it. + */ if (li->LoadOptionsSize % 2 != 0) - return EFI_INVALID_PARAMETER; + return EFI_SUCCESS; /* So, load options are a giant pain in the ass. If we're invoked * from the EFI shell, we get something like this: -- 2.32.0