From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: "Yao, Jiewen" <jiewen.yao@intel.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [PATCH] MdeModulePkg/DxeCore: base code protection on permission attributes
Date: Sun, 26 Feb 2017 14:00:31 +0000 [thread overview]
Message-ID: <CAKv+Gu86Aq+u1n8tkE6Bw1BOWR6y+qAC2j_UVEA58iURzTBuOQ@mail.gmail.com> (raw)
In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503A8F5385@shsmsx102.ccr.corp.intel.com>
On 25 February 2017 at 04:04, Yao, Jiewen <jiewen.yao@intel.com> wrote:
> Hi Ard
> I agree with you on this enhancement.
>
> I prefer to adding the description as comment in the code, so that people
> can get clear picture when he/she reads the code.
>
> //
> // Instead of assuming that a PE/COFF section of type EFI_IMAGE_SCN_CNT_CODE
> // can always be mapped read-only, classify a section as a code section only
> // if it has the executable attribute set and the writable attribute
> cleared.
> //
> // This adheres more closely to the PE/COFF spec, and avoids issues with
> // Linux OS loaders that consists of a single read/write/execute section.
> //
> if ((Section[Index].Characteristics & (EFI_IMAGE_SCN_MEM_WRITE |
> EFI_IMAGE_SCN_MEM_EXECUTE)) == EFI_IMAGE_SCN_MEM_EXECUTE) {
>
> With comment update, reviewed-by: Jiewen.yao@intel.com
>
Thanks Jiewen
Pushed as a2ed40c02bf2
>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: Saturday, February 25, 2017 1:51 AM
>> To: edk2-devel@lists.01.org; Yao, Jiewen <jiewen.yao@intel.com>
>> Cc: Gao, Liming <liming.gao@intel.com>; Ard Biesheuvel
>> <ard.biesheuvel@linaro.org>
>> Subject: [PATCH] MdeModulePkg/DxeCore: base code protection on permission
>> attributes
>
>
>>
>> Instead of assuming that a PE/COFF section of type EFI_IMAGE_SCN_CNT_CODE
>> can always be mapped read-only, classify a section as a code section only
>> if it has the executable attribute set and the writable attribute cleared.
>>
>> This adheres more closely to the PE/COFF spec, and avoids issues with
>> Linux OS loaders that consists of a single read/write/execute section.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>> MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
>> b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
>> index 1142dcc5a83d..3e037607a6be 100644
>> --- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
>> +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
>> @@ -533,7 +533,7 @@ ProtectUefiImageCommon (
>> Name[7]
>> ));
>>
>> - if ((Section[Index].Characteristics & EFI_IMAGE_SCN_CNT_CODE) != 0) {
>> + if ((Section[Index].Characteristics & (EFI_IMAGE_SCN_MEM_WRITE |
>> EFI_IMAGE_SCN_MEM_EXECUTE)) == EFI_IMAGE_SCN_MEM_EXECUTE) {
>> DEBUG ((DEBUG_VERBOSE, " VirtualSize - 0x%08x\n",
>> Section[Index].Misc.VirtualSize));
>> DEBUG ((DEBUG_VERBOSE, " VirtualAddress - 0x%08x\n",
>> Section[Index].VirtualAddress));
>> DEBUG ((DEBUG_VERBOSE, " SizeOfRawData - 0x%08x\n",
>> Section[Index].SizeOfRawData));
>> --
>> 2.7.4
next prev parent reply other threads:[~2017-02-26 14:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 17:51 [PATCH] MdeModulePkg/DxeCore: base code protection on permission attributes Ard Biesheuvel
2017-02-25 4:04 ` Yao, Jiewen
2017-02-26 14:00 ` Ard Biesheuvel [this message]
2017-03-17 12:07 ` Laszlo Ersek
2017-03-17 12:11 ` Ard Biesheuvel
2017-03-17 12:35 ` Laszlo Ersek
2017-03-17 13:23 ` Ard Biesheuvel
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=CAKv+Gu86Aq+u1n8tkE6Bw1BOWR6y+qAC2j_UVEA58iURzTBuOQ@mail.gmail.com \
--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