]> git.ipfire.org Git - thirdparty/grub.git/commit
kern/efi/init: Disable stack smashing protection on grub_efi_init()
authorGlenn Washburn <development@efficientek.com>
Tue, 18 Jul 2023 05:47:14 +0000 (00:47 -0500)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 12 Oct 2023 15:47:28 +0000 (17:47 +0200)
commitc3bdf263f63b57394fee836cde3e582a4576e6fd
treee084b2b08b86203d4446c799d75b3dce244969c0
parent95963d97f8d87f209e2032283c79912e19b1de82
kern/efi/init: Disable stack smashing protection on grub_efi_init()

GCC is electing to instrument grub_efi_init() to give it stack smashing
protection when configuring with --enable-stack-protector on the x86_64-efi
target. In the function prologue, the canary at the top of the stack frame
is set to the value of the stack guard. And in the epilogue, the canary is
checked to verify if it is equal to the guard and if not to call the stack
check fail function. The issue is that grub_efi_init() sets up the guard
by initializing it with random bytes, if the firmware supports the RNG
protocol. So in its prologue the canary will be set with the value of the
uninitialized guard, likely NUL bytes. Then the guard is initialized, and
finally the epilogue checks the canary against the guard, which will almost
certainly be different. This causes the code path for a smashed stack to be
taken, causing the machine to print out a message that stack smashing was
detected, wait 5 seconds, and then reboot. Disable grub_efi_init()
instrumentation so there is no stack smashing false positive generated.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/kern/efi/init.c