[ros-diffs] [cgutman] 54579: [NTOSKRNL] - Release the address space lock before entering SEH because an exception would result in recursive acquisition of the address space lock when the fault handler tries to...

cgutman at svn.reactos.org cgutman at svn.reactos.org
Sun Dec 4 08:25:36 UTC 2011


Author: cgutman
Date: Sun Dec  4 08:25:35 2011
New Revision: 54579

URL: http://svn.reactos.org/svn/reactos?rev=54579&view=rev
Log:
[NTOSKRNL]
- Release the address space lock before entering SEH because an exception would result in recursive acquisition of the address space lock when the fault handler tries to grab it

Modified:
    trunk/reactos/ntoskrnl/mm/anonmem.c

Modified: trunk/reactos/ntoskrnl/mm/anonmem.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/anonmem.c?rev=54579&r1=54578&r2=54579&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/anonmem.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/anonmem.c [iso-8859-1] Sun Dec  4 08:25:35 2011
@@ -1004,8 +1004,8 @@
     NTSTATUS Status;
     PEPROCESS Process;
     PMMSUPPORT AddressSpace;
-    PVOID BaseAddress, PBaseAddress;
-    SIZE_T RegionSize, PRegionSize;
+    PVOID BaseAddress = NULL, PBaseAddress;
+    SIZE_T RegionSize = 0, PRegionSize;
     PEPROCESS CurrentProcess = PsGetCurrentProcess();
     KPROCESSOR_MODE PreviousMode = KeGetPreviousMode();
     KAPC_STATE ApcState;
@@ -1183,22 +1183,26 @@
         goto unlock_deref_and_return;
     }
 
-    /* Enter SEH */
-    _SEH2_TRY
-    {
-        /* Copy rounded values back in success case */
-        *UBaseAddress = BaseAddress;
-        *URegionSize = RegionSize;
-    }
-    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
-    {
-        Status = _SEH2_GetExceptionCode();
-        DPRINT1("Failed to copy values back! (Status: 0x%x)\n", Status);
-    }
-    _SEH2_END;
-
 unlock_deref_and_return:
     MmUnlockAddressSpace(AddressSpace);
+
+    /* Copy rounded values back in success case */
+    if (NT_SUCCESS(Status))
+    {
+        /* Enter SEH */
+        _SEH2_TRY
+        {
+            *UBaseAddress = BaseAddress;
+            *URegionSize = RegionSize;
+        }
+        _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+        {
+            Status = _SEH2_GetExceptionCode();
+            DPRINT1("Failed to copy values back! (Status: 0x%x)\n", Status);
+        }
+        _SEH2_END;
+    }
+
     if (Attached) KeUnstackDetachProcess(&ApcState);
     if (ProcessHandle != NtCurrentProcess()) ObDereferenceObject(Process);
 




More information about the Ros-diffs mailing list