mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
stub: NULL checks for DeviceHandle and FilePath
UKIs may be loaded in a way, that there can not be a device handle to the filesystem, that contains the image, for example when using a bootloader to load the image from a partition with a file system that is not supported by the firmware. With the current systemd stub, this causes a failed assertion, because stub gets passed a NULL DeviceHandle and FilePath. Inserting two explicit checks enables proper boot even in this case. Fixes: #29331
This commit is contained in:
committed by
Lennart Poettering
parent
36d87065f2
commit
c7fda70716
@@ -520,8 +520,9 @@ static EFI_STATUS run(EFI_HANDLE image) {
|
||||
if (err != EFI_SUCCESS)
|
||||
return log_error_status(err, "Error getting a LoadedImageProtocol handle: %m");
|
||||
|
||||
if (efivar_get_uint64_le(MAKE_GUID_PTR(LOADER), u"LoaderFeatures", &loader_features) != EFI_SUCCESS ||
|
||||
!FLAGS_SET(loader_features, EFI_LOADER_FEATURE_RANDOM_SEED)) {
|
||||
if (loaded_image->DeviceHandle && /* Handle case, where bootloader doesn't support DeviceHandle. */
|
||||
(efivar_get_uint64_le(MAKE_GUID_PTR(LOADER), u"LoaderFeatures", &loader_features) != EFI_SUCCESS ||
|
||||
!FLAGS_SET(loader_features, EFI_LOADER_FEATURE_RANDOM_SEED))) {
|
||||
_cleanup_(file_closep) EFI_FILE *esp_dir = NULL;
|
||||
|
||||
err = partition_open(MAKE_GUID_PTR(ESP), loaded_image->DeviceHandle, NULL, &esp_dir);
|
||||
@@ -556,19 +557,22 @@ static EFI_STATUS run(EFI_HANDLE image) {
|
||||
if (err != EFI_SUCCESS)
|
||||
log_error_status(err, "Error loading global addons, ignoring: %m");
|
||||
|
||||
_cleanup_free_ char16_t *dropin_dir = get_extra_dir(loaded_image->FilePath);
|
||||
err = load_addons(
|
||||
image,
|
||||
loaded_image,
|
||||
dropin_dir,
|
||||
uname,
|
||||
&cmdline_addons_uki,
|
||||
&dt_bases_addons_uki,
|
||||
&dt_sizes_addons_uki,
|
||||
&dt_filenames_addons_uki,
|
||||
&n_dts_addons_uki);
|
||||
if (err != EFI_SUCCESS)
|
||||
log_error_status(err, "Error loading UKI-specific addons, ignoring: %m");
|
||||
/* Some bootloaders always pass NULL in FilePath, so we need to check for it here. */
|
||||
if (loaded_image->FilePath) {
|
||||
_cleanup_free_ char16_t *dropin_dir = get_extra_dir(loaded_image->FilePath);
|
||||
err = load_addons(
|
||||
image,
|
||||
loaded_image,
|
||||
dropin_dir,
|
||||
uname,
|
||||
&cmdline_addons_uki,
|
||||
&dt_bases_addons_uki,
|
||||
&dt_sizes_addons_uki,
|
||||
&dt_filenames_addons_uki,
|
||||
&n_dts_addons_uki);
|
||||
if (err != EFI_SUCCESS)
|
||||
log_error_status(err, "Error loading UKI-specific addons, ignoring: %m");
|
||||
}
|
||||
|
||||
/* Measure all "payload" of this PE image into a separate PCR (i.e. where nothing else is written
|
||||
* into so far), so that we have one PCR that we can nicely write policies against because it
|
||||
|
||||
Reference in New Issue
Block a user