From bc32a9fdfd28886e4a037e97984b7a3bb230b224 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Wed, 26 Jul 2023 15:08:53 +0200 Subject: [PATCH] boot: Fall back to using image load address for stack guard 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/boot/efi/log.c b/src/boot/efi/log.c index 93631aca942..dd651bf18e8 100644 --- a/src/boot/efi/log.c +++ b/src/boot/efi/log.c @@ -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 -- 2.47.3