mirror of
https://github.com/reactos/reactos.git
synced 2025-04-30 02:58:48 +00:00
[NTOS:MM] Fix MmFreeMemoryArea
- Stay attached while deleting the VAD node - Acquire the appropriate working set lock when deleting a VAD node - Both are needed for locking correctness
This commit is contained in:
parent
de3958dc2b
commit
601bb49c0d
1 changed files with 10 additions and 8 deletions
|
@ -300,8 +300,7 @@ MmFreeMemoryArea(
|
||||||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
||||||
PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
|
PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
|
||||||
|
|
||||||
if (Process != NULL &&
|
if ((Process != NULL) && (Process != CurrentProcess))
|
||||||
Process != CurrentProcess)
|
|
||||||
{
|
{
|
||||||
KeAttachProcess(&Process->Pcb);
|
KeAttachProcess(&Process->Pcb);
|
||||||
}
|
}
|
||||||
|
@ -337,12 +336,6 @@ MmFreeMemoryArea(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Process != NULL &&
|
|
||||||
Process != CurrentProcess)
|
|
||||||
{
|
|
||||||
KeDetachProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (MemoryArea->VadNode.StartingVpn < (ULONG_PTR)MmSystemRangeStart >> PAGE_SHIFT
|
//if (MemoryArea->VadNode.StartingVpn < (ULONG_PTR)MmSystemRangeStart >> PAGE_SHIFT
|
||||||
if (MemoryArea->Vad)
|
if (MemoryArea->Vad)
|
||||||
{
|
{
|
||||||
|
@ -357,14 +350,23 @@ MmFreeMemoryArea(
|
||||||
ASSERT(MemoryArea->VadNode.u.VadFlags.Spare != 0);
|
ASSERT(MemoryArea->VadNode.u.VadFlags.Spare != 0);
|
||||||
if (((PMMVAD)MemoryArea->Vad)->u.VadFlags.Spare == 1)
|
if (((PMMVAD)MemoryArea->Vad)->u.VadFlags.Spare == 1)
|
||||||
{
|
{
|
||||||
|
MiLockProcessWorkingSet(PsGetCurrentProcess(), PsGetCurrentThread());
|
||||||
MiRemoveNode((PMMADDRESS_NODE)&MemoryArea->VadNode, &Process->VadRoot);
|
MiRemoveNode((PMMADDRESS_NODE)&MemoryArea->VadNode, &Process->VadRoot);
|
||||||
|
MiUnlockProcessWorkingSet(PsGetCurrentProcess(), PsGetCurrentThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryArea->Vad = NULL;
|
MemoryArea->Vad = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
MiLockWorkingSet(PsGetCurrentThread(), &MmSystemCacheWs);
|
||||||
MiRemoveNode((PMMADDRESS_NODE)&MemoryArea->VadNode, &MiRosKernelVadRoot);
|
MiRemoveNode((PMMADDRESS_NODE)&MemoryArea->VadNode, &MiRosKernelVadRoot);
|
||||||
|
MiUnlockWorkingSet(PsGetCurrentThread(), &MmSystemCacheWs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Process != NULL) && (Process != CurrentProcess))
|
||||||
|
{
|
||||||
|
KeDetachProcess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue