Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From 25f4dcd2c7d3a989ef355e287f1feaca66fd33dd Mon Sep 17 00:00:00 2001
From: Julian Andres Klode <julian.klode@canonical.com>
Date: Mon, 26 Jul 2021 09:38:28 +0200
Subject: [PATCH] Fallback to default loader if parsed one does not exist
If the specified second stage loader does not exist (invalid
parameter), fall back to the DEFAULT_LOADER. This avoids failing
the boot on any garbage that made it through the load option parser
as a second stage loader name.
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1937115
---
shim.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/shim.c b/shim.c
index 94a51768..658b0a10 100644
--- a/shim.c
+++ b/shim.c
@@ -1136,6 +1136,19 @@ EFI_STATUS init_grub(EFI_HANDLE image_handle)
use_fb ? FALLBACK : second_stage);
}
+ // If the filename is invalid, or the file does not exist,
+ // just fallback to the default loader.
+ if (!use_fb && (efi_status == EFI_INVALID_PARAMETER ||
+ efi_status == EFI_NOT_FOUND)) {
+ console_print(
+ L"start_image() returned %r, falling back to default loader\n",
+ efi_status);
+ msleep(2000000);
+ load_options = NULL;
+ load_options_size = 0;
+ efi_status = start_image(image_handle, DEFAULT_LOADER);
+ }
+
if (EFI_ERROR(efi_status)) {
console_print(L"start_image() returned %r\n", efi_status);
msleep(2000000);