mirror of
https://github.com/reactos/reactos.git
synced 2025-06-06 01:40:36 +00:00
[NTOS:MM] Fix the mess created by the "balancer thread"
When processing: Make sure that the process is not terminating. Make sure that the process WorkingSet is still valid Protect accessing & writing to PTEs by acquiring the working set lock CORE-17595 CORE-17642
This commit is contained in:
parent
676dc4b441
commit
acf28dbc1e
1 changed files with 15 additions and 5 deletions
|
@ -207,16 +207,24 @@ MmTrimUserMemory(ULONG Target, ULONG Priority, PULONG NrFreedPages)
|
||||||
Process = Entry->Process;
|
Process = Entry->Process;
|
||||||
Address = Entry->Address;
|
Address = Entry->Address;
|
||||||
|
|
||||||
|
ObReferenceObject(Process);
|
||||||
|
|
||||||
|
if (!ExAcquireRundownProtection(&Process->RundownProtect))
|
||||||
|
{
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
MiReleasePfnLock(OldIrql);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
MiReleasePfnLock(OldIrql);
|
MiReleasePfnLock(OldIrql);
|
||||||
|
|
||||||
KeStackAttachProcess(&Process->Pcb, &ApcState);
|
KeStackAttachProcess(&Process->Pcb, &ApcState);
|
||||||
|
MiLockProcessWorkingSet(Process, PsGetCurrentThread());
|
||||||
MmLockAddressSpace(&Process->Vm);
|
|
||||||
|
|
||||||
/* Be sure this is still valid. */
|
/* Be sure this is still valid. */
|
||||||
PMMPTE Pte = MiAddressToPte(Address);
|
if (MmIsAddressValid(Address))
|
||||||
if (Pte->u.Hard.Valid)
|
|
||||||
{
|
{
|
||||||
|
PMMPTE Pte = MiAddressToPte(Address);
|
||||||
Accessed = Accessed || Pte->u.Hard.Accessed;
|
Accessed = Accessed || Pte->u.Hard.Accessed;
|
||||||
Pte->u.Hard.Accessed = 0;
|
Pte->u.Hard.Accessed = 0;
|
||||||
|
|
||||||
|
@ -224,9 +232,11 @@ MmTrimUserMemory(ULONG Target, ULONG Priority, PULONG NrFreedPages)
|
||||||
//KeInvalidateTlbEntry(Address);
|
//KeInvalidateTlbEntry(Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
MmUnlockAddressSpace(&Process->Vm);
|
MiUnlockProcessWorkingSet(Process, PsGetCurrentThread());
|
||||||
|
|
||||||
KeUnstackDetachProcess(&ApcState);
|
KeUnstackDetachProcess(&ApcState);
|
||||||
|
ExReleaseRundownProtection(&Process->RundownProtect);
|
||||||
|
ObDereferenceObject(Process);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Accessed)
|
if (!Accessed)
|
||||||
|
|
Loading…
Reference in a new issue