Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to default loader if parsed one does not exist #393

Merged
merged 2 commits into from
Sep 14, 2021

Conversation

julian-klode
Copy link
Collaborator

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

@julian-klode
Copy link
Collaborator Author

julian-klode commented Jul 26, 2021

Arguably I have not tested this. Seems to make some sense. Might want to reset load_options to NULL though? I guess I should setup a non-existing second stage loader and then see if it falls back. Maybe here it should sleep like 5s so you see the error message.

Though, eek, shouldn't it return "Not found" and not "Invalid parameter".

@julian-klode
Copy link
Collaborator Author

Updated with changes for load_options and EFI_NOT_FOUND. I believe in the bug in question, EFI_INVALID_PARAMETER was returned because the given bytes were simply not valid in filenames, but can't be sure.

@julian-klode julian-klode force-pushed the default-loader-fallback branch 2 times, most recently from 92e355d to 25f4dcd Compare July 26, 2021 08:08
@julian-klode
Copy link
Collaborator Author

julian-klode commented Jul 26, 2021

Moved it out of the wrong if, added the msleep and a message, and tested in qemu by running shimx64.efi in efi shell with non-existing second-stage as argument :)

@julian-klode
Copy link
Collaborator Author

Also added code to dump the load options in debug mode

@haobinnan
Copy link

Exception occurred after using patches 393-1 / 393-2 / 399-1 / 399-2. And I got following messages after replacing \EFI\Microsoft\Boot\bootmgfw.efi with shimx64.efi:
Falled to open \EFI\Microsoft\Boot\S - Invalid Parameter
Failed to load image \EFI\Microsoft\Boot\S: Invalid Parameter
start_image() returned Invalid Parameter, falling back to default loader

@julian-klode

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
Dump the load options before parsing them so that we can
see which things are failing to parse.
@vathpela
Copy link
Contributor

Exception occurred after using patches 393-1 / 393-2 / 399-1 / 399-2. And I got following messages after replacing \EFI\Microsoft\Boot\bootmgfw.efi with shimx64.efi:
Falled to open \EFI\Microsoft\Boot\S - Invalid Parameter
Failed to load image \EFI\Microsoft\Boot\S: Invalid Parameter
start_image() returned Invalid Parameter, falling back to default loader

This is pretty clearly not caused by this change, so I'm going to merge this and let you all discuss that issue in the thread for #399.

@vathpela vathpela merged commit e54e585 into rhboot:main Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants