Skip to content

Commit

Permalink
Transition Stack Cookie Libraries
Browse files Browse the repository at this point in the history
Description

This patch transitions the core to use the new stack cookie libraries.
The stack cookie value no longer needs to be initialized before
image execution and can instead be initialized in the library
constructor. This update also allows the cookie value to be
randomized for GCC buids which was previously not possible because
GCC does not use the cookie value from the image PE/COFF header.

- [x] Impacts functionality?
  - **Functionality** - Does the change ultimately impact how firmware functions?
  - Examples: Add a new library, publish a new PPI, update an algorithm, ...
- [x] Impacts security?
  - **Security** - Does the change have a direct security impact on an application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [x] Breaking change?
  - **Breaking change** - Will anyone consuming this change experience a break
    in build or boot behavior?
  - Examples: Add a new library class, move a module to a different repo, call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
  - **Documentation** - Does the change contain explicit documentation additions
    outside direct code modifications (and comments)?
  - Examples: Update readme file, add feature readme file, link to documentation
    on an a separate Web page, ...

How This Was Tested

Tested on GCC and VS builds of Q35

Integration Instructions

StackCheckLib will need to be linked to every module built with /GS
for MSVC and -fstack-protector for GCC. An instance of
StackCheckFailureLib will need to be added to all platform DSC
files which utilize StackCheckLib.

```
[LibraryClasses.X64]
  NULL|MdePkg/Library/StackCheckLib/StackCheckLib.inf
  StackCheckFailureLib|MdePkg/Library/StackCheckFailureLibNull/StackCheckFailureLibNull.inf
```
  • Loading branch information
TaylorBeebe committed Nov 21, 2023
1 parent 0d4cad5 commit 2836657
Show file tree
Hide file tree
Showing 24 changed files with 31 additions and 156 deletions.
5 changes: 0 additions & 5 deletions CryptoPkg/CryptoPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@

##MSCHANGE Begin
FltUsedLib|MdePkg/Library/FltUsedLib/FltUsedLib.inf
BaseBinSecurityLibRng|MdePkg/Library/BaseBinSecurityLibNull/BaseBinSecurityLibNull.inf
UnitTestLib|UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.inf
UnitTestPersistenceLib|UnitTestFrameworkPkg/Library/UnitTestPersistenceLibNull/UnitTestPersistenceLibNull.inf
UnitTestBootLib|UnitTestFrameworkPkg/Library/UnitTestBootLibNull/UnitTestBootLibNull.inf
Expand All @@ -78,10 +77,6 @@
[LibraryClasses.IA32]
NULL|MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.inf
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
[LibraryClasses.X64]
# Provide StackCookie support lib so that we can link to /GS exports for VS builds
NULL|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
[LibraryClasses.X64.DXE_CORE, LibraryClasses.X64.UEFI_DRIVER, LibraryClasses.X64.DXE_DRIVER, LibraryClasses.X64.UEFI_APPLICATION]
# this is currently X64 only because MSVC doesn't support BaseMemoryLibOptDxe for AARCH64
BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf
Expand Down
1 change: 0 additions & 1 deletion MdeModulePkg/Core/Dxe/DxeMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/DxeServicesLib.h>
#include <Library/DebugAgentLib.h>
#include <Library/CpuExceptionHandlerLib.h>
#include <Library/BaseBinSecurityLib.h> // MS_CHANGE_?
#include <Library/DxeMemoryProtectionHobLib.h> // MU_CHANGE

//
Expand Down
1 change: 0 additions & 1 deletion MdeModulePkg/Core/Dxe/DxeMain.inf
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
DebugAgentLib
CpuExceptionHandlerLib
PcdLib
BaseBinSecurityLib ## MS_CHANGE_?
DxeMemoryProtectionHobLib ## MU_CHANGE
MemoryBinOverrideLib ## MU_CHANGE

Expand Down
9 changes: 0 additions & 9 deletions MdeModulePkg/Core/Dxe/Image/Image.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ CoreLoadPeImage (
EFI_STATUS Status;
BOOLEAN DstBufAlocated;
UINTN Size;
UINT64 *SecurityCookieAddress; // MS_CHANGE_? - TODO

ZeroMem (&Image->ImageContext, sizeof (Image->ImageContext));

Expand Down Expand Up @@ -921,14 +920,6 @@ CoreLoadPeImage (

// MS_CHANGE_304324
// DEBUG_CODE_END ();
// END
// MS_CHANGE_?
Status = PeCoffLoaderGetSecurityCookieAddress (&Image->ImageContext, &SecurityCookieAddress);
if (!EFI_ERROR (Status)) {
InitializeSecurityCookieAddress (SecurityCookieAddress);
DEBUG ((DEBUG_VERBOSE | DEBUG_LOAD, "SecurityCookie set to %lld\n", (*SecurityCookieAddress)));
}

// END

return EFI_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
DebugAgentLib
CpuExceptionHandlerLib
PcdLib
BaseBinSecurityLib
DxeMemoryProtectionHobLib
MemoryBinOverrideLib

Expand Down
15 changes: 0 additions & 15 deletions MdeModulePkg/Core/PiSmmCore/Dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,6 @@ SmmLoadImage (
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;

UINT64 *SecurityCookieAddress; // MS_CHANGE_?

PERF_LOAD_IMAGE_BEGIN (DriverEntry->ImageHandle);

Buffer = NULL;
Expand Down Expand Up @@ -729,19 +727,6 @@ SmmLoadImage (

DEBUG ((DEBUG_ERROR | DEBUG_LOAD, "\n")); // MS_CHANGE_304324

// MS_CHANGE_304324
// DEBUG_CODE_END ();
// END

// MS_CHANGE_?
Status = PeCoffLoaderGetSecurityCookieAddress (&ImageContext, &SecurityCookieAddress);
if (!EFI_ERROR (Status)) {
InitializeSecurityCookieAddress (SecurityCookieAddress);
DEBUG ((DEBUG_VERBOSE | DEBUG_LOAD, "SMM SecurityCookie set to %lld\n", (*SecurityCookieAddress)));
}

// END

//
// Free buffer allocated by Fv->ReadSection.
//
Expand Down
1 change: 0 additions & 1 deletion MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
#include <Library/HobLib.h>
#include <Library/SmmMemLib.h>
#include <Library/SafeIntLib.h>
#include <Library/BaseBinSecurityLib.h> // MS_CHANGE_?
#include <Library/MmMemoryProtectionHobLib.h> // MU_CHANGE

#include "PiSmmCorePrivateData.h"
Expand Down
1 change: 0 additions & 1 deletion MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
HobLib
SmmMemLib
SafeIntLib
BaseBinSecurityLib ## MS_CHANGE_?
MmMemoryProtectionHobLib ## MU_CHANGE

[Protocols]
Expand Down
13 changes: 0 additions & 13 deletions MdeModulePkg/MdeModulePkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,6 @@

# MU_CHANGE END

##MSCHANGE Begin
[LibraryClasses.common]
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibNull/BaseBinSecurityLibNull.inf
!if $(TOOL_CHAIN_TAG) == VS2019 or $(TOOL_CHAIN_TAG) == VS2022
[LibraryClasses.X64]
# Provide StackCookie support lib so that we can link to /GS exports for VS builds
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
[LibraryClasses.X64]
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
NULL|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
!endif
##MSCHANGE End

[LibraryClasses.EBC.PEIM]
IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf

Expand Down
1 change: 0 additions & 1 deletion MdeModulePkg/Test/MdeModulePkgHostTest.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
CpuExceptionHandlerLib|MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.inf
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibNull/BaseBinSecurityLibNull.inf
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
MemoryBinOverrideLib|MdeModulePkg/Library/MemoryBinOverrideLibNull/MemoryBinOverrideLibNull.inf # MU_CHANGE

Expand Down
7 changes: 7 additions & 0 deletions MdePkg/MdeLibs.dsc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@
RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf
CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
SmmCpuRendezvousLib|MdePkg/Library/SmmCpuRendezvousLibNull/SmmCpuRendezvousLibNull.inf

# MU_CHANGE [BEGIN] - Add Stack Cookie Support
[LibraryClasses.X64]
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
NULL|MdePkg/Library/StackCheckLib/StackCheckLib.inf
StackCheckFailureLib|MdePkg/Library/StackCheckFailureLibNull/StackCheckFailureLibNull.inf
# MU_CHANGE [END] - Add Stack Cookie Support
3 changes: 0 additions & 3 deletions MdePkg/MdePkg.ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@
## options defined ci/Plugin/DscCompleteCheck
"DscCompleteCheck": {
"IgnoreInf": [
# MU_CHANGE Ignore StackCookie libs for toolchains that don't support it.
"MdePkg/Library/BaseBinSecurityLibNull/BaseBinSecurityLibNull.inf",
"MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf",
"MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.inf", # MU_CHANGE - Ignore intrinsics for toolchains that don't support it.
"MdePkg/Library/FltUsedLib/FltUsedLib.inf", # MU_CHANGE this isn't compilable since it has no code
],
Expand Down
10 changes: 6 additions & 4 deletions MdePkg/MdePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@
# All combinations of Unicode and ASCII strings are supported.
##
PrintLib|Include/Library/PrintLib.h
## MSCHANGE BEGIN
## @libraryclass Provides and interface to initialize security cookies
BaseBinSecurityLib|Include/Library/BaseBinSecurityLib.h
## MSCHANGE END

## MU_CHANGE [BEGIN]
## @libraryclass Provides a hook called when a stack cookie check fails.
StackCheckFailureLib|Include/Library/StackCheckFailureLib.h
## MU_CHANGE [END]

## @libraryclass Provides an ordered collection data structure.
OrderedCollectionLib|Include/Library/OrderedCollectionLib.h

Expand Down
16 changes: 0 additions & 16 deletions MdePkg/MdePkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@

[LibraryClasses]
SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
# MU_CHANGE START
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibNull/BaseBinSecurityLibNull.inf
!if $(TOOL_CHAIN_TAG) == VS2019 or $(TOOL_CHAIN_TAG) == VS2022
[LibraryClasses.X64]
# Provide StackCookie support lib so that we can link to /GS exports for VS builds
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
NULL|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
!endif
# MU_CHANGE END

[Components]
MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
Expand Down Expand Up @@ -190,12 +180,6 @@
MdePkg/Library/BaseS3StallLib/BaseS3StallLib.inf
MdePkg/Library/SmmMemLib/SmmMemLib.inf
MdePkg/Library/SmmIoLib/SmmIoLib.inf
##MSCHANGE Begin
!if $(TOOL_CHAIN_TAG) == VS2017 or $(TOOL_CHAIN_TAG) == VS2015 or $(TOOL_CHAIN_TAG) == VS2019 or $(TOOL_CHAIN_TAG) == VS2022
MdePkg/Library/BaseBinSecurityLibNull/BaseBinSecurityLibNull.inf
MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
!endif
##MSCHANGE End
MdePkg/Library/SmmPciExpressLib/SmmPciExpressLib.inf
MdePkg/Library/SmiHandlerProfileLibNull/SmiHandlerProfileLibNull.inf
MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
Expand Down
9 changes: 0 additions & 9 deletions NetworkPkg/NetworkPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@
SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf

##MSCHANGE Begin
!if $(TOOL_CHAIN_TAG) == VS2019 or $(TOOL_CHAIN_TAG) == VS2022
[LibraryClasses.X64]
# Provide StackCookie support lib so that we can link to /GS exports for VS builds
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
NULL|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
!endif
##MSCHANGE End

[LibraryClasses.common.UEFI_DRIVER]
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
Expand Down
13 changes: 5 additions & 8 deletions NetworkPkg/SharedNetworking/SharedNetworkPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
BaseBinSecurityLibRng|MdePkg/Library/BaseBinSecurityLibNull/BaseBinSecurityLibNull.inf

OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
Expand All @@ -83,14 +82,12 @@
BaseCryptLib|CryptoPkg/Library/BaseCryptLibOnProtocolPpi/SmmCryptLib.inf
TlsLib|CryptoPkg/Library/BaseCryptLibOnProtocolPpi/SmmCryptLib.inf

##MSCHANGE Begin
!if $(TOOL_CHAIN_TAG) == VS2019 or $(TOOL_CHAIN_TAG) == VS2022
# MU_CHANGE [BEGIN] - Add Stack Cookie Support
[LibraryClasses.X64]
# Provide StackCookie support lib so that we can link to /GS exports for VS builds
NULL|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
!endif
##MSCHANGE End
NULL|MdePkg/Library/StackCheckLib/StackCheckLib.inf
StackCheckFailureLib|MdePkg/Library/StackCheckFailureLibNull/StackCheckFailureLibNull.inf
# MU_CHANGE [END] - Add Stack Cookie Support

[LibraryClasses.DXE_RUNTIME_DRIVER, LibraryClasses.DXE_CORE]
DebugLib|MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
Expand Down
9 changes: 0 additions & 9 deletions PcAtChipsetPkg/PcAtChipsetPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf # MU_CHANGE

## MS_CHANGE Begin
[LibraryClasses.X64]
!if $(TOOL_CHAIN_TAG) == VS2019 or $(TOOL_CHAIN_TAG) == VS2022
# Provide StackCookie support lib so that we can link to /GS exports for VS builds
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
NULL|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
!endif
## MS_CHANGE End

[Components]
PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
PcAtChipsetPkg/Bus/Pci/IdeControllerDxe/IdeControllerDxe.inf
Expand Down
14 changes: 4 additions & 10 deletions PolicyServicePkg/PolicyServicePkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,12 @@
UnitTestPersistenceLib|UnitTestFrameworkPkg/Library/UnitTestPersistenceLibNull/UnitTestPersistenceLibNull.inf
UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.inf

## MU_CHANGE START
[LibraryClasses.common]
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibNull/BaseBinSecurityLibNull.inf
!if $(TOOL_CHAIN_TAG) == VS2019 or $(TOOL_CHAIN_TAG) == VS2022
# MU_CHANGE [BEGIN] - Add Stack Cookie Support
[LibraryClasses.X64]
# Provide StackCookie support lib so that we can link to /GS exports for VS builds
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
[LibraryClasses.X64]
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
NULL|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
!endif
## MU_CHANGE END
NULL|MdePkg/Library/StackCheckLib/StackCheckLib.inf
StackCheckFailureLib|MdePkg/Library/StackCheckFailureLibNull/StackCheckFailureLibNull.inf
# MU_CHANGE [END] - Add Stack Cookie Support

[LibraryClasses.ARM, LibraryClasses.AARCH64]
NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
Expand Down
13 changes: 0 additions & 13 deletions ShellPkg/ShellPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,6 @@

SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf # MU_CHANGE - CodeQL change

## MU_CHANGE Begin
[LibraryClasses.common]
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibNull/BaseBinSecurityLibNull.inf
!if $(TOOL_CHAIN_TAG) == VS2019 or $(TOOL_CHAIN_TAG) == VS2022
[LibraryClasses.X64]
# Provide StackCookie support lib so that we can link to /GS exports for VS builds
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
[LibraryClasses.X64]
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
NULL|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
!endif
## MU_CHANGE End

[LibraryClasses.ARM,LibraryClasses.AARCH64]
#
# It is not possible to prevent the ARM compiler for generic intrinsic functions.
Expand Down
13 changes: 0 additions & 13 deletions StandaloneMmPkg/StandaloneMmPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,6 @@
VariableMmDependency|StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.inf
MmuLib|MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf # MU_CHANGE

## MU_CHANGE START
[LibraryClasses.common]
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibNull/BaseBinSecurityLibNull.inf
!if $(TOOL_CHAIN_TAG) == VS2019 or $(TOOL_CHAIN_TAG) == VS2022
[LibraryClasses.X64]
# Provide StackCookie support lib so that we can link to /GS exports for VS builds
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
[LibraryClasses.X64]
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
NULL|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
!endif
## MU_CHANGE END

[LibraryClasses.X64] # MU_CHANGE
StandaloneMmCoreEntryPoint|StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf # MU_CHANGE

Expand Down
8 changes: 0 additions & 8 deletions UefiCpuPkg/UefiCpuPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,10 @@
DxeMemoryProtectionHobLib|MdeModulePkg/Library/MemoryProtectionHobLibNull/DxeMemoryProtectionHobLibNull.inf
MmMemoryProtectionHobLib|MdeModulePkg/Library/MemoryProtectionHobLibNull/MmMemoryProtectionHobLibNull.inf
DeviceStateLib|MdeModulePkg/Library/DeviceStateLib/DeviceStateLib.inf
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibNull/BaseBinSecurityLibNull.inf

PanicLib|MdePkg/Library/BasePanicLibNull/BasePanicLibNull.inf # MU_CHANGE
[LibraryClasses.X64, LibraryClasses.IA32]
HwResetSystemLib|MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.inf
!if $(TOOL_CHAIN_TAG) == VS2019 or $(TOOL_CHAIN_TAG) == VS2022
[LibraryClasses.X64]
# Provide StackCookie support lib so that we can link to /GS exports for VS builds
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
NULL|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
!endif
##MSCHANGE End

[LibraryClasses.common.SEC]
Expand Down
13 changes: 0 additions & 13 deletions UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@
[PcdsPatchableInModule]
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17

## MU_CHANGE START
[LibraryClasses.common]
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibNull/BaseBinSecurityLibNull.inf
!if $(TOOL_CHAIN_TAG) == VS2019 or $(TOOL_CHAIN_TAG) == VS2022
[LibraryClasses.X64]
# Provide StackCookie support lib so that we can link to /GS exports for VS builds
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
[LibraryClasses.X64]
BaseBinSecurityLib|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
NULL|MdePkg/Library/BaseBinSecurityLibRng/BaseBinSecurityLibRng.inf
!endif
## MU_CHANGE END

[Components]
UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.inf
UnitTestFrameworkPkg/Library/UnitTestPersistenceLibNull/UnitTestPersistenceLibNull.inf
Expand Down
4 changes: 2 additions & 2 deletions UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

[BuildOptions]
# MU_CHANGE [BEGIN] - Add build flag to detect when building host-based unit tests
MSFT:*_*_*_CC_FLAGS = -D HOST_UNIT_TEST_BUILD=1
GCC:*_*_*_CC_FLAGS = -D HOST_UNIT_TEST_BUILD=1
MSFT:*_*_*_CC_FLAGS = -D HOST_UNIT_TEST_BUILD=1 \GS- # Disable Stack Protection for Host-Based Unit Tests
GCC:*_*_*_CC_FLAGS = -D HOST_UNIT_TEST_BUILD=1 -fno-stack-protector # Disable Stack Protection for Host-Based Unit Tests
XCODE:*_*_*_CC_FLAGS = -D HOST_UNIT_TEST_BUILD=1
# MU_CHANGE [END] - Add build flag to detect when building host-based unit tests
GCC:*_*_*_CC_FLAGS = -fno-pie
Expand Down
7 changes: 7 additions & 0 deletions UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@

UnitTestLib|UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.inf

# MU_CHANGE [BEGIN] - Add Stack Cookie Support
[LibraryClasses.X64]
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
NULL|MdePkg/Library/StackCheckLib/StackCheckLib.inf
StackCheckFailureLib|MdePkg/Library/StackCheckFailureLibNull/StackCheckFailureLibNull.inf
# MU_CHANGE [END] - Add Stack Cookie Support

[LibraryClasses.ARM, LibraryClasses.AARCH64]
#
# It is not possible to prevent ARM compiler calls to generic intrinsic functions.
Expand Down

0 comments on commit 2836657

Please sign in to comment.