summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/StackCheckFailureHookLibNull
diff options
context:
space:
mode:
authorTaylor Beebe <taylor.d.beebe@gmail.com>2024-08-27 14:31:48 -0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-09-13 03:58:46 +0000
commitac43bbacdef18a6fea6d978e096326ec0805885d (patch)
treeb7df070aa9c31205f5d123eff6542680094f968f /MdePkg/Library/StackCheckFailureHookLibNull
parent3a9da5f329ab9683bffc451502a2f0680568a71f (diff)
downloadedk2-ac43bbacdef18a6fea6d978e096326ec0805885d.tar.gz
MdePkg: Create Stack Check Null Libs
Add Null libs for Stack Check and Stack Check Failure Hook Lib that allow a platform to opt out of stack checks and the stack check failure hook lib. StackCheckLib allows implementation (or in this case null implementation) of stack checks on binaries. There is a Host Application specific version of this null lib because MSVC host applications must not be linked against our lib (so the file here is a no-op but that doesn't cause the build system to fail the build for not building a file for MSVC) as it links against the MSVC C runtime lib that provides the stack cookie definitions. GCC host applications do not link against such a C runtime lib and must be linked against our version. StackCheckFailureHookLib lets a platform do custom functionality when a stack check failure occurs (such as log it to a platform defined mechanism). The null lib simply returns. Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
Diffstat (limited to 'MdePkg/Library/StackCheckFailureHookLibNull')
-rw-r--r--MdePkg/Library/StackCheckFailureHookLibNull/StackCheckFailureHook.c25
-rw-r--r--MdePkg/Library/StackCheckFailureHookLibNull/StackCheckFailureHookLibNull.inf20
2 files changed, 45 insertions, 0 deletions
diff --git a/MdePkg/Library/StackCheckFailureHookLibNull/StackCheckFailureHook.c b/MdePkg/Library/StackCheckFailureHookLibNull/StackCheckFailureHook.c
new file mode 100644
index 0000000000..0a258e4773
--- /dev/null
+++ b/MdePkg/Library/StackCheckFailureHookLibNull/StackCheckFailureHook.c
@@ -0,0 +1,25 @@
+/** @file
+ Library provides a hook called when a stack cookie check fails.
+
+ Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Base.h>
+#include <Uefi.h>
+
+/**
+ This function gets called when a compiler generated stack cookie fails. This allows a platform to hook this
+ call and perform any required actions/telemetry at that time.
+
+ @param FailureAddress The address of the function that failed the stack cookie check.
+
+**/
+VOID
+EFIAPI
+StackCheckFailureHook (
+ VOID *FailureAddress
+ )
+{
+ return;
+}
diff --git a/MdePkg/Library/StackCheckFailureHookLibNull/StackCheckFailureHookLibNull.inf b/MdePkg/Library/StackCheckFailureHookLibNull/StackCheckFailureHookLibNull.inf
new file mode 100644
index 0000000000..300073a7e7
--- /dev/null
+++ b/MdePkg/Library/StackCheckFailureHookLibNull/StackCheckFailureHookLibNull.inf
@@ -0,0 +1,20 @@
+## @file
+# Library provides a hook called when a stack cookie check fails.
+#
+# Copyright (c) Microsoft Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ INF_VERSION = 1.29
+ BASE_NAME = StackCheckFailureHookLibNull
+ FILE_GUID = 9ca2587c-d1f2-451a-989a-d49a9a0a613e
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = StackCheckFailureHookLib
+
+[Sources]
+ StackCheckFailureHook.c
+
+[Packages]
+ MdePkg/MdePkg.dec