From 5d8674f2bdd536124b1dd026dfa729a1376b3cac Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sat, 30 Nov 2024 12:36:15 -0700 Subject: Import edk2 edk2-stable202411 (hash 0f3867fa6ef0553e26c42f7d71ff6bdb98429742) Bring in the latest stable branch for updated defines (especailly Loongson). Remove ^M as described in sys/contrib/edk2/FREEBSD-upgrade. Not the absolute latest, but aligned to the edk2-stable202411 tag. Sponsored by: Netflix --- .../StackCheckLib/StackCheckLibCommonMsvc.c | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 MdePkg/Library/StackCheckLib/StackCheckLibCommonMsvc.c (limited to 'MdePkg/Library/StackCheckLib/StackCheckLibCommonMsvc.c') diff --git a/MdePkg/Library/StackCheckLib/StackCheckLibCommonMsvc.c b/MdePkg/Library/StackCheckLib/StackCheckLibCommonMsvc.c new file mode 100644 index 000000000000..6018e3790990 --- /dev/null +++ b/MdePkg/Library/StackCheckLib/StackCheckLibCommonMsvc.c @@ -0,0 +1,40 @@ +/** @file + Provides the required functionality for handling stack + cookie check failures for MSVC. + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include + +#include +#include +#include + +/** + Triggers an interrupt using the vector specified by PcdStackCookieExceptionVector +**/ +VOID +TriggerStackCookieInterrupt ( + VOID + ); + +VOID *__security_cookie = (VOID *)(UINTN)STACK_COOKIE_VALUE; + +/** + This function gets called when an MSVC generated stack cookie fails. This implementation calls into a platform + failure hook lib and then triggers the stack cookie interrupt. + + @param[in] ActualCookieValue The value that was written onto the stack, corrupting the stack cookie. + +**/ +VOID +StackCheckFailure ( + VOID *ActualCookieValue + ) +{ + DEBUG ((DEBUG_ERROR, "Stack cookie check failed at address 0x%llx!\n", RETURN_ADDRESS (0))); + StackCheckFailureHook (RETURN_ADDRESS (0)); + TriggerStackCookieInterrupt (); +} -- cgit v1.3