mirror of
https://github.com/systemd/systemd.git
synced 2026-08-11 09:36:28 +00:00
boot: restore parent loaded image when initrd registration fails
linux_exec() patches the stub's own EFI_LOADED_IMAGE_PROTOCOL to point at the loaded inner kernel, and restores the saved original only after the entry point returns. The initrd_register() failure path returns without restoring, leaving the firmware's protocol pointing to freed data. Follow-up forf405165065(cherry picked from commitbaad1744bd)
This commit is contained in:
@@ -355,8 +355,12 @@ EFI_STATUS linux_exec(
|
||||
|
||||
_cleanup_(cleanup_initrd) EFI_HANDLE initrd_handle = NULL;
|
||||
err = initrd_register(initrd, &initrd_handle);
|
||||
if (err != EFI_SUCCESS)
|
||||
if (err != EFI_SUCCESS) {
|
||||
/* Restore the patched fields before kernel_file_path and loaded_kernel_pages are freed,
|
||||
* otherwise the stub's own EFI_LOADED_IMAGE_PROTOCOL is left pointing at freed memory. */
|
||||
*parent_loaded_image = original_parent_loaded_image;
|
||||
return log_error_status(err, "Error registering initrd: %m");
|
||||
}
|
||||
|
||||
log_wait();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user