Author: tkreuzer
Date: Tue Nov  4 20:37:54 2014
New Revision: 65253

URL: http://svn.reactos.org/svn/reactos?rev=65253&view=rev
Log:
[NTOSKRNL]
Fix the fix to ObSetSecurityDescriptorInfo. To understand the change: it is not 
only style change! The old code modified SecurityDescriptor, which must always 
stay the same in the loop!

Modified:
    branches/kernel-fun/reactos/ntoskrnl/ob/obsecure.c

Modified: branches/kernel-fun/reactos/ntoskrnl/ob/obsecure.c
URL: 
http://svn.reactos.org/svn/reactos/branches/kernel-fun/reactos/ntoskrnl/ob/obsecure.c?rev=65253&r1=65252&r2=65253&view=diff
==============================================================================
--- branches/kernel-fun/reactos/ntoskrnl/ob/obsecure.c  [iso-8859-1] (original)
+++ branches/kernel-fun/reactos/ntoskrnl/ob/obsecure.c  [iso-8859-1] Tue Nov  4 
20:37:54 2014
@@ -131,27 +131,26 @@
 
     /* Get the object header */
     ObjectHeader = OBJECT_TO_OBJECT_HEADER(Object);
-
-    /* Reference the old descriptor */
-    OldDescriptor = ObpReferenceSecurityDescriptor(ObjectHeader);
-    NewDescriptor = OldDescriptor;
-
-    /* Set the SD information */
-    Status = SeSetSecurityDescriptorInfo(Object,
-                                         SecurityInformation,
-                                         SecurityDescriptor,
-                                         &NewDescriptor,
-                                         PoolType,
-                                         GenericMapping);
-    if (!NT_SUCCESS(Status))
-    {
-        /* We failed, dereference the old one */
-        if (OldDescriptor) ObDereferenceSecurityDescriptor(OldDescriptor, 1);
-        return Status;
-    }
-
     while (TRUE)
     {
+        /* Reference the old descriptor */
+        OldDescriptor = ObpReferenceSecurityDescriptor(ObjectHeader);
+        NewDescriptor = OldDescriptor;
+
+        /* Set the SD information */
+        Status = SeSetSecurityDescriptorInfo(Object,
+                                             SecurityInformation,
+                                             SecurityDescriptor,
+                                             &NewDescriptor,
+                                             PoolType,
+                                             GenericMapping);
+        if (!NT_SUCCESS(Status))
+        {
+            /* We failed, dereference the old one */
+            if (OldDescriptor) ObDereferenceSecurityDescriptor(OldDescriptor, 
1);
+            break;
+        }
+
         /* Now add this to the cache */
         Status = ObLogSecurityDescriptor(NewDescriptor,
                                          &CachedDescriptor,
@@ -174,18 +173,15 @@
                                               CachedDescriptor,
                                               OldDescriptor);
 
-        /* Get the security descriptor */
-        SecurityDescriptor = ExGetObjectFastReference(OldValue);
-        Count = ExGetCountFastReference(OldValue);
-
         /* Make sure the swap worked */
-        if (SecurityDescriptor == OldDescriptor)
+        if (ExGetObjectFastReference(OldValue) == OldDescriptor)
         {
             /* Flush waiters */
             ObpAcquireObjectLock(ObjectHeader);
             ObpReleaseObjectLock(ObjectHeader);
 
             /* And dereference the old one */
+            Count = ExGetCountFastReference(OldValue);
             ObDereferenceSecurityDescriptor(OldDescriptor, Count + 2);
             break;
         }


Reply via email to