From 79d198341eca017751f78e9d2ab5927d5a8528e8 Mon Sep 17 00:00:00 2001 From: Aaron Pop Date: Wed, 13 Nov 2024 13:29:42 -0800 Subject: [PATCH] Inital StackCookie implementation for MSVC AARCH64 --- .../AARCH64/StackCheckFunctionsMsvc.asm | 80 +++++++++++++++++++ .../StackCheckLibNull/StackCheckLibNull.inf | 3 + 2 files changed, 83 insertions(+) create mode 100644 MdePkg/Library/StackCheckLibNull/AARCH64/StackCheckFunctionsMsvc.asm diff --git a/MdePkg/Library/StackCheckLibNull/AARCH64/StackCheckFunctionsMsvc.asm b/MdePkg/Library/StackCheckLibNull/AARCH64/StackCheckFunctionsMsvc.asm new file mode 100644 index 0000000000..bed8492bbb --- /dev/null +++ b/MdePkg/Library/StackCheckLibNull/AARCH64/StackCheckFunctionsMsvc.asm @@ -0,0 +1,80 @@ +;------------------------------------------------------------------------------ +; AARCH64/StackCheckFunctionsMsvc.nasm +; +; Copyright (c) Microsoft Corporation. +; SPDX-License-Identifier: BSD-2-Clause-Patent +;------------------------------------------------------------------------------ + + EXPORT __report_rangecheckfailure + EXPORT __GSHandlerCheck + EXPORT __security_check_cookie + EXPORT __security_push_cookie + EXPORT __security_pop_cookie + + AREA |.text|, CODE, READONLY + +;------------------------------------------------------------------------------ +; Calls an interrupt using the vector specified by PcdStackCookieExceptionVector +; +; VOID +; TriggerStackCookieInterrupt ( +; VOID +; ); +;------------------------------------------------------------------------------ +__report_rangecheckfailure PROC + RET +__report_rangecheckfailure ENDP + +;------------------------------------------------------------------------------ +; Calls an interrupt using the vector specified by PcdStackCookieExceptionVector +; +; VOID +; __GSHandlerCheck ( +; VOID +; ); +;------------------------------------------------------------------------------ +__GSHandlerCheck PROC + RET +__GSHandlerCheck ENDP + +;------------------------------------------------------------------------------ +; Checks the stack cookie value against passed __security_cookie. Take +; appropiate action on a mismatch (stack smashed case) +; +; VOID +; EFIAPI +; __security_check_cookie ( +; IN UINTN CheckValue +; ); +;------------------------------------------------------------------------------ +__security_check_cookie PROC + RET +__security_check_cookie ENDP + + +;------------------------------------------------------------------------------ +; Pop the cookie off the stack (recommended in 16 bytes) +; +; VOID +; __security_push_cookie ( +; VOID +; ); +;------------------------------------------------------------------------------ +__security_pop_cookie PROC + RET +__security_pop_cookie ENDP + + +;------------------------------------------------------------------------------ +; Push a Security Cookie onto the stack (recommended is 16 bytes) +; +; VOID +; __security_push_cookie ( +; VOID +; ); +;------------------------------------------------------------------------------ +__security_push_cookie PROC + RET +__security_push_cookie ENDP + + END diff --git a/MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf b/MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf index 507f7f305b..68e7cd9855 100644 --- a/MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf +++ b/MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf @@ -24,6 +24,9 @@ [Sources.X64] X64/StackCheckFunctionsMsvc.nasm | MSFT +[Sources.AARCH64] + AARCH64/StackCheckFunctionsMsvc.asm | MSFT + [Packages] MdePkg/MdePkg.dec