From: Vitaly Kuznetsov Date: Tue, 27 Aug 2024 10:51:45 +0000 (+0200) Subject: stub: restore random seed update logic X-Git-Tag: v257-rc1~614 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=803a3924715f21ac9d3392793e6ec669349fbac9;p=thirdparty%2Fsystemd.git stub: restore random seed update logic Commit 201e0d53bdd43 ("stub: split out random seed part out of run()") looks like refactoring but apparently it changed the logic when random seed is refreshed in the ESP completely. Previously, process_random_seed() was called when either: - sd-stub was not present (LoaderFeatures var is unset) OR - sd-stub was present but EFI_LOADER_FEATURE_RANDOM_SEED flag was unset. Post-change, refresh_random_seed() bails under the exact same conditions (no sd-stub or EFI_LOADER_FEATURE_RANDOM_SEED is unset) and thus process_random_seed() is NOT called. Restore the original logic. efivar_get_uint64_le()'s return value doesn't require checking: loader_features is initialized to 0 and in case of failure it stays untouched. --- diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c index bad042c9e0d..7f8671a9cf7 100644 --- a/src/boot/efi/stub.c +++ b/src/boot/efi/stub.c @@ -565,13 +565,10 @@ static void refresh_random_seed(EFI_LOADED_IMAGE_PROTOCOL *loaded_image) { if (!loaded_image->DeviceHandle) return; - uint64_t loader_features = 0; - err = efivar_get_uint64_le(MAKE_GUID_PTR(LOADER), u"LoaderFeatures", &loader_features); - if (err != EFI_SUCCESS) - return; - /* Don't measure again, if sd-boot already initialized the random seed */ - if (!FLAGS_SET(loader_features, EFI_LOADER_FEATURE_RANDOM_SEED)) + uint64_t loader_features = 0; + (void) efivar_get_uint64_le(MAKE_GUID_PTR(LOADER), u"LoaderFeatures", &loader_features); + if (FLAGS_SET(loader_features, EFI_LOADER_FEATURE_RANDOM_SEED)) return; _cleanup_(file_closep) EFI_FILE *esp_dir = NULL;