Skip to content

Commit

Permalink
EmbeddedPkg: Mark DMA Memory Allocations XP By Default
Browse files Browse the repository at this point in the history
When allocating memory for a non-coherent DMA device, the current core
code removes the XP attribute, allowing code to execute from that
region. This is a security vulnerability and unneeded. This change
updates to mark the region as XP when allocating memory for the
non-coherent DMA device.

These allocations in this function are limited to `EfiBootServicesData`
and `EfiRuntimeServicesData`, which we expect to be XP.
  • Loading branch information
os-d committed Jul 3, 2024
1 parent 7879110 commit 97bd7ef
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ DmaAllocateAlignedBuffer (
Status = gDS->SetMemorySpaceAttributes (
(PHYSICAL_ADDRESS)(UINTN)Allocation,
EFI_PAGES_TO_SIZE (Pages),
MemType
MemType | EFI_MEMORY_XP // MU_CHANGE: Allocate DMA memory XP by default
);
if (EFI_ERROR (Status)) {
goto FreeAlloc;
Expand Down

0 comments on commit 97bd7ef

Please sign in to comment.