]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
stub: restore random seed update logic
authorVitaly Kuznetsov <vkuznets@redhat.com>
Tue, 27 Aug 2024 10:51:45 +0000 (12:51 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 27 Aug 2024 20:10:06 +0000 (05:10 +0900)
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.

src/boot/efi/stub.c

index bad042c9e0df67a64dc74efe73166fea0ac2ca17..7f8671a9cf743dd3db47fed95e9b2ef62754dd51 100644 (file)
@@ -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;