Re: [edk2] [PATCH] MdeModulePkg/Core: fix feature conflict between NX and NULL detection

2018-01-31 Thread Wang, Jian J
.d...@intel.com>; > Zeng, Star <star.z...@intel.com> > Subject: Re: [edk2] [PATCH] MdeModulePkg/Core: fix feature conflict between > NX and NULL detection > > On 2/1/2018 1:33 PM, Ni, Ruiyu wrote: > > On 2/1/2018 9:17 AM, Wang, Jian J wrote: > >> You're right.

Re: [edk2] [PATCH] MdeModulePkg/Core: fix feature conflict between NX and NULL detection

2018-01-31 Thread Ni, Ruiyu
On 2/1/2018 1:33 PM, Ni, Ruiyu wrote: On 2/1/2018 9:17 AM, Wang, Jian J wrote: You're right. Using a mask or separating the API into two (SetMemoryAttributes/ClearMemoryAttributes) is much better and can avoid many potential issues. Regards, Jian For now the patch is good enough to leave

Re: [edk2] [PATCH] MdeModulePkg/Core: fix feature conflict between NX and NULL detection

2018-01-31 Thread Ni, Ruiyu
On 2/1/2018 9:17 AM, Wang, Jian J wrote: You're right. Using a mask or separating the API into two (SetMemoryAttributes/ClearMemoryAttributes) is much better and can avoid many potential issues. Regards, Jian For now the patch is good enough to leave NULL pointer detection feature enabled.

Re: [edk2] [PATCH] MdeModulePkg/Core: fix feature conflict between NX and NULL detection

2018-01-31 Thread Wang, Jian J
gCpu->SetMemoryAttributes() called by SetUefiImageMemoryAttributes() will return without any problem if Length is 0. Regards, Jian > -Original Message- > From: Yao, Jiewen > Sent: Tuesday, January 30, 2018 10:09 AM > To: Wang, Jian J ; edk2-devel@lists.01.org >

Re: [edk2] [PATCH] MdeModulePkg/Core: fix feature conflict between NX and NULL detection

2018-01-29 Thread Ni, Ruiyu
On 1/29/2018 7:09 PM, Jian J Wang wrote: If enabled, NX memory protection feature will mark all free memory as NX (non-executable), including page 0. This will overwrite the attributes of page 0 if NULL pointer detection feature is also enabled and then compromise the functionality of it. The

Re: [edk2] [PATCH] MdeModulePkg/Core: fix feature conflict between NX and NULL detection

2018-01-29 Thread Yao, Jiewen
Hi Jian May I know how we handle MemoryMapEntry->NumberOfPages is 1? The lengh will be 0 in that case. Should we add additional check? > +SetUefiImageMemoryAttributes ( > + MemoryMapEntry->PhysicalStart + EFI_PAGE_SIZE, > + LShiftU64 (MemoryMapEntry->NumberOfPages - 1, >

[edk2] [PATCH] MdeModulePkg/Core: fix feature conflict between NX and NULL detection

2018-01-29 Thread Jian J Wang
If enabled, NX memory protection feature will mark all free memory as NX (non-executable), including page 0. This will overwrite the attributes of page 0 if NULL pointer detection feature is also enabled and then compromise the functionality of it. The solution is skipping the NX attributes