]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Fall back to using image load address for stack guard 28527/head
authorJan Janssen <medhefgo@web.de>
Wed, 26 Jul 2023 13:08:53 +0000 (15:08 +0200)
committerJan Janssen <medhefgo@web.de>
Wed, 26 Jul 2023 13:11:08 +0000 (15:11 +0200)
If we cannot get random data from the RNG protocol we can still use our
load address to make the stack guard a little less static.

src/boot/efi/log.c

index 93631aca942ca6eb61857d8b8f068800c5f65cf9..dd651bf18e83c1c2248717935489c2fa771fbb0f 100644 (file)
@@ -79,6 +79,9 @@ void __stack_chk_guard_init(void) {
         EFI_RNG_PROTOCOL *rng;
         if (BS->LocateProtocol(MAKE_GUID_PTR(EFI_RNG_PROTOCOL), NULL, (void **) &rng) == EFI_SUCCESS)
                 (void) rng->GetRNG(rng, NULL, sizeof(__stack_chk_guard), (void *) &__stack_chk_guard);
+        else
+                /* Better than no extra entropy. */
+                __stack_chk_guard ^= (intptr_t) &__ImageBase;
 }
 #endif