From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org, afish@apple.com,
leif.lindholm@linaro.org, michael.d.kinney@intel.com,
liming.gao@intel.com, jiewen.yao@intel.com
Cc: lersek@redhat.com, feng.tian@intel.com, star.zeng@intel.com,
Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [RFC PATCH 3/4] MdeModulePkg/DxeCore: lift non-exec permissions on loaded images
Date: Wed, 22 Feb 2017 18:24:57 +0000 [thread overview]
Message-ID: <1487787898-5222-4-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1487787898-5222-1-git-send-email-ard.biesheuvel@linaro.org>
To ensure that loaded PE/COFF images are executable regardless of
the protection policy and the section alignment, clear all permission
restrictions when loading PE/COFF images.
Subsequently, permissions may be restricted again if the protection
policy and section alignment allow it.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
MdeModulePkg/Core/Dxe/Image/Image.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c
index 652da8bf1075..cab06e821e39 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.c
+++ b/MdeModulePkg/Core/Dxe/Image/Image.c
@@ -644,6 +644,14 @@ CoreLoadPeImage (
InvalidateInstructionCacheRange ((VOID *)(UINTN)Image->ImageContext.ImageAddress, (UINTN)Image->ImageContext.ImageSize);
//
+ // Remove any permission restrictions.
+ //
+ if (gCpu != NULL) {
+ gCpu->SetMemoryAttributes (gCpu, Image->ImageContext.ImageAddress,
+ Image->ImageContext.ImageSize, 0);
+ }
+
+ //
// Copy the machine type from the context to the image private data. This
// is needed during image unload to know if we should call an EBC protocol
// to unload the image.
--
2.7.4
next prev parent reply other threads:[~2017-02-22 18:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-22 18:24 [RFC PATCH 0/4] RFC: increased memory protection Ard Biesheuvel
2017-02-22 18:24 ` [RFC PATCH 1/4] MdeModulePkg/DxeCore: allow BootServicesData->BootServicesCode conversion Ard Biesheuvel
2017-02-22 18:24 ` [RFC PATCH 2/4] MdeModulePkg/DxeCore: convert the DxeCore memory region to BootServicesCode Ard Biesheuvel
2017-02-22 18:24 ` Ard Biesheuvel [this message]
2017-02-22 18:24 ` [RFC PATCH 4/4] ArmPkg/CpuDxe: remap all data regions non-executable Ard Biesheuvel
2017-02-23 8:52 ` [RFC PATCH 0/4] RFC: increased memory protection Yao, Jiewen
2017-02-23 11:39 ` Ard Biesheuvel
2017-02-23 11:45 ` Yao, Jiewen
2017-02-23 19:32 ` Ard Biesheuvel
2017-02-24 2:25 ` Yao, Jiewen
2017-02-23 10:34 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1487787898-5222-4-git-send-email-ard.biesheuvel@linaro.org \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox