Skip to content

Commit 7a88a62

Browse files
pfentardbiesheuvel
authored andcommitted
efi/libstub: Fix path separator regression
Commit 9302c1b ("efi/libstub: Rewrite file I/O routine") introduced a regression that made a couple of (badly configured) systems fail to boot [1]: Until 5.6, we silently accepted Unix-style file separators in EFI paths, which might violate the EFI standard, but are an easy to make mistake. This fix restores the pre-5.7 behaviour. [1] https://bbs.archlinux.org/viewtopic.php?id=256273 Fixes: 9302c1b ("efi/libstub: Rewrite file I/O routine") Signed-off-by: Philipp Fent <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ardb: rewrite as chained if/else statements] Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 24552d1 commit 7a88a62

File tree

1 file changed

+12
-4
lines changed
  • drivers/firmware/efi/libstub

1 file changed

+12
-4
lines changed

drivers/firmware/efi/libstub/file.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,20 @@ static int find_file_option(const efi_char16_t *cmdline, int cmdline_len,
102102
if (!found)
103103
return 0;
104104

105+
/* Skip any leading slashes */
106+
while (cmdline[i] == L'/' || cmdline[i] == L'\\')
107+
i++;
108+
105109
while (--result_len > 0 && i < cmdline_len) {
106-
if (cmdline[i] == L'\0' ||
107-
cmdline[i] == L'\n' ||
108-
cmdline[i] == L' ')
110+
efi_char16_t c = cmdline[i++];
111+
112+
if (c == L'\0' || c == L'\n' || c == L' ')
109113
break;
110-
*result++ = cmdline[i++];
114+
else if (c == L'/')
115+
/* Replace UNIX dir separators with EFI standard ones */
116+
*result++ = L'\\';
117+
else
118+
*result++ = c;
111119
}
112120
*result = L'\0';
113121
return i;

0 commit comments

Comments
 (0)