[NTOS:MM] Properly handle execution in NX section

This prevents processes from looping forever, thinking the fault was already resolbed, because the page is writable.
This commit is contained in:
Timo Kreuzer 2024-09-09 17:05:53 +03:00
parent fd3c571d36
commit 96c65e94e1

View file

@ -22,7 +22,8 @@ NTSTATUS
NTAPI NTAPI
MmpAccessFault(KPROCESSOR_MODE Mode, MmpAccessFault(KPROCESSOR_MODE Mode,
ULONG_PTR Address, ULONG_PTR Address,
BOOLEAN FromMdl) BOOLEAN FromMdl,
ULONG FaultCode)
{ {
PMMSUPPORT AddressSpace; PMMSUPPORT AddressSpace;
MEMORY_AREA* MemoryArea; MEMORY_AREA* MemoryArea;
@ -36,6 +37,14 @@ MmpAccessFault(KPROCESSOR_MODE Mode,
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
/* Instruction fetch and the page is present.
This means the page is NX and we cannot do anything to "fix" it. */
if (MI_IS_INSTRUCTION_FETCH(FaultCode))
{
DPRINT1("Page fault instruction fetch at %p\n", Address);
return STATUS_ACCESS_VIOLATION;
}
/* /*
* Find the memory area for the faulting address * Find the memory area for the faulting address
*/ */
@ -285,7 +294,7 @@ Retry:
if (!MI_IS_NOT_PRESENT_FAULT(FaultCode)) if (!MI_IS_NOT_PRESENT_FAULT(FaultCode))
{ {
/* Call access fault */ /* Call access fault */
Status = MmpAccessFault(Mode, (ULONG_PTR)Address, TrapInformation ? FALSE : TRUE); Status = MmpAccessFault(Mode, (ULONG_PTR)Address, TrapInformation ? FALSE : TRUE, FaultCode);
} }
else else
{ {