[NTOS:MM] Fix locking when paging out

This commit is contained in:
Jérôme Gardou 2021-01-22 09:30:55 +01:00
parent d8cdb89fb0
commit d932bdb950

View file

@ -70,7 +70,7 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page)
if (entry == NULL) if (entry == NULL)
{ {
MiReleasePfnLock(OldIrql); MiReleasePfnLock(OldIrql);
return STATUS_UNSUCCESSFUL; goto WriteSegment;
} }
Process = entry->Process; Process = entry->Process;
@ -176,6 +176,12 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page)
MmSetDirtyPage(Process, Address); MmSetDirtyPage(Process, Address);
MmUnlockAddressSpace(AddressSpace); MmUnlockAddressSpace(AddressSpace);
if (Address < MmSystemRangeStart)
{
ExReleaseRundownProtection(&Process->RundownProtect);
ObDereferenceObject(Process);
}
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
} }
@ -199,6 +205,11 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page)
MmSetDirtyPage(Process, Address); MmSetDirtyPage(Process, Address);
MmUnlockAddressSpace(AddressSpace); MmUnlockAddressSpace(AddressSpace);
if (Address < MmSystemRangeStart)
{
ExReleaseRundownProtection(&Process->RundownProtect);
ObDereferenceObject(Process);
}
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
} }
@ -256,12 +267,7 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page)
KeBugCheck(MEMORY_MANAGEMENT); KeBugCheck(MEMORY_MANAGEMENT);
} }
if (Address < MmSystemRangeStart) WriteSegment:
{
ExReleaseRundownProtection(&Process->RundownProtect);
ObDereferenceObject(Process);
}
/* Now write this page to file, if needed */ /* Now write this page to file, if needed */
Segment = MmGetSectionAssociation(Page, &SegmentOffset); Segment = MmGetSectionAssociation(Page, &SegmentOffset);
if (Segment) if (Segment)