mirror of
https://github.com/reactos/reactos.git
synced 2024-06-29 01:12:06 +00:00
[NTOS:MM] Fix a race condition when unmapping sections views
This commit is contained in:
parent
57ee31ee33
commit
caf89b9582
|
@ -833,12 +833,17 @@ MiUnmapViewOfSection(IN PEPROCESS Process,
|
|||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
||||
PAGED_CODE();
|
||||
|
||||
/* Check if we need to lock the address space */
|
||||
if (!Flags) MmLockAddressSpace(&Process->Vm);
|
||||
|
||||
/* Check for Mm Region */
|
||||
MemoryArea = MmLocateMemoryAreaByAddress(&Process->Vm, BaseAddress);
|
||||
if ((MemoryArea) && (MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3))
|
||||
{
|
||||
/* Call Mm API */
|
||||
return MiRosUnmapViewOfSection(Process, BaseAddress, Process->ProcessExiting);
|
||||
NTSTATUS Status = MiRosUnmapViewOfSection(Process, BaseAddress, Process->ProcessExiting);
|
||||
if (!Flags) MmUnlockAddressSpace(&Process->Vm);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Check if we should attach to the process */
|
||||
|
@ -849,10 +854,7 @@ MiUnmapViewOfSection(IN PEPROCESS Process,
|
|||
Attached = TRUE;
|
||||
}
|
||||
|
||||
/* Check if we need to lock the address space */
|
||||
if (!Flags) MmLockAddressSpace(&Process->Vm);
|
||||
|
||||
/* Check if the process is already daed */
|
||||
/* Check if the process is already dead */
|
||||
if (Process->VmDeleted)
|
||||
{
|
||||
/* Fail the call */
|
||||
|
@ -3116,11 +3118,15 @@ MmUnmapViewInSystemSpace(IN PVOID MappedBase)
|
|||
PAGED_CODE();
|
||||
|
||||
/* Was this mapped by RosMm? */
|
||||
MmLockAddressSpace(MmGetKernelAddressSpace());
|
||||
MemoryArea = MmLocateMemoryAreaByAddress(MmGetKernelAddressSpace(), MappedBase);
|
||||
if ((MemoryArea) && (MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3))
|
||||
{
|
||||
return MiRosUnmapViewInSystemSpace(MappedBase);
|
||||
NTSTATUS Status = MiRosUnmapViewInSystemSpace(MappedBase);
|
||||
MmUnlockAddressSpace(MmGetKernelAddressSpace());
|
||||
return Status;
|
||||
}
|
||||
MmUnlockAddressSpace(MmGetKernelAddressSpace());
|
||||
|
||||
/* It was not, call the ARM3 routine */
|
||||
return MiUnmapViewInSystemSpace(&MmSession, MappedBase);
|
||||
|
|
|
@ -543,9 +543,6 @@ MiRosCleanupMemoryArea(
|
|||
(Process->ActiveThreads == 1)) ||
|
||||
(Process->ActiveThreads == 0));
|
||||
|
||||
/* We are in cleanup, we don't need to synchronize */
|
||||
MmUnlockAddressSpace(&Process->Vm);
|
||||
|
||||
MemoryArea = (PMEMORY_AREA)Vad;
|
||||
BaseAddress = (PVOID)MA_GetStartingAddress(MemoryArea);
|
||||
|
||||
|
@ -567,9 +564,6 @@ MiRosCleanupMemoryArea(
|
|||
|
||||
/* Make sure this worked! */
|
||||
ASSERT(NT_SUCCESS(Status));
|
||||
|
||||
/* Lock the address space again */
|
||||
MmLockAddressSpace(&Process->Vm);
|
||||
}
|
||||
|
||||
VOID
|
||||
|
|
|
@ -3459,6 +3459,7 @@ MmUnmapViewOfSegment(PMMSUPPORT AddressSpace,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
/* This functions must be called with a locked address space */
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
MiRosUnmapViewOfSection(IN PEPROCESS Process,
|
||||
|
@ -3477,7 +3478,6 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process,
|
|||
|
||||
AddressSpace = Process ? &Process->Vm : MmGetKernelAddressSpace();
|
||||
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace,
|
||||
BaseAddress);
|
||||
if (MemoryArea == NULL ||
|
||||
|
@ -3492,7 +3492,6 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process,
|
|||
if (MemoryArea) ASSERT(MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3);
|
||||
|
||||
DPRINT1("Unable to find memory area at address %p.\n", BaseAddress);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
return STATUS_NOT_MAPPED_VIEW;
|
||||
}
|
||||
|
||||
|
@ -3551,8 +3550,6 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process,
|
|||
}
|
||||
}
|
||||
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
|
||||
/* Notify debugger */
|
||||
if (ImageBaseAddress && !SkipDebuggerNotify) DbgkUnMapViewOfSection(ImageBaseAddress);
|
||||
|
||||
|
@ -4248,24 +4245,14 @@ MmMapViewInSystemSpaceEx (
|
|||
return Status;
|
||||
}
|
||||
|
||||
/* This function must be called with adress space lock held */
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
MiRosUnmapViewInSystemSpace(IN PVOID MappedBase)
|
||||
{
|
||||
PMMSUPPORT AddressSpace;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("MmUnmapViewInSystemSpace() called\n");
|
||||
|
||||
AddressSpace = MmGetKernelAddressSpace();
|
||||
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
|
||||
Status = MmUnmapViewOfSegment(AddressSpace, MappedBase);
|
||||
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
|
||||
return Status;
|
||||
return MmUnmapViewOfSegment(MmGetKernelAddressSpace(), MappedBase);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
|
Loading…
Reference in a new issue