VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/BaseStackCheckLib/BaseStackCheckGcc.c

最後變更 在這個檔案是 105670,由 vboxsync 提交於 5 月 前

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

  • 屬性 svn:eol-style 設為 native
檔案大小: 1.5 KB
 
1/** @file
2 Base Stack Check library for GCC/clang.
3
4 Use -fstack-protector-all compiler flag to make the compiler insert the
5 __stack_chk_guard "canary" value into the stack and check the value prior
6 to exiting the function. If the "canary" is overwritten __stack_chk_fail()
7 is called. This is GCC specific code.
8
9 Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
10 Copyright (c) 2012, Apple Inc. All rights reserved.<BR>
11 SPDX-License-Identifier: BSD-2-Clause-Patent
12
13**/
14
15#include <Base.h>
16#include <Library/BaseLib.h>
17#include <Library/DebugLib.h>
18#include <Library/PcdLib.h>
19
20/// "canary" value that is inserted by the compiler into the stack frame.
21VOID *__stack_chk_guard = (VOID *)0x0AFF;
22
23// If ASLR was enabled we could use
24// void (*__stack_chk_guard)(void) = __stack_chk_fail;
25
26/**
27 Error path for compiler generated stack "canary" value check code. If the
28 stack canary has been overwritten this function gets called on exit of the
29 function.
30**/
31VOID
32__stack_chk_fail (
33 VOID
34 )
35{
36 UINT8 DebugPropertyMask;
37
38 DEBUG ((DEBUG_ERROR, "STACK FAULT: Buffer Overflow at 0x%p.\n", RETURN_ADDRESS (0)));
39
40 //
41 // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings even if
42 // BaseDebugLibNull is in use.
43 //
44 DebugPropertyMask = PcdGet8 (PcdDebugPropertyMask);
45 if ((DebugPropertyMask & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
46 CpuBreakpoint ();
47 } else if ((DebugPropertyMask & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
48 CpuDeadLoop ();
49 }
50}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette