[NTOSKRNL]

Merge r62304 and r65253 from kernel-fun branch:
Fix logic in 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!

svn path=/trunk/; revision=65254
This commit is contained in:
Timo Kreuzer 2014-11-04 20:41:10 +00:00
parent 4e41ff66c0
commit afc42dae68

View file

@ -144,8 +144,13 @@ ObSetSecurityDescriptorInfo(IN PVOID Object,
&NewDescriptor,
PoolType,
GenericMapping);
if (NT_SUCCESS(Status))
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,
@ -155,26 +160,28 @@ ObSetSecurityDescriptorInfo(IN PVOID Object,
ExFreePool(NewDescriptor);
/* Check for success */
if (NT_SUCCESS(Status))
if (!NT_SUCCESS(Status))
{
/* We failed, dereference the old one */
ObDereferenceSecurityDescriptor(OldDescriptor, 1);
break;
}
/* Do the swap */
FastRef = (PEX_FAST_REF)OutputSecurityDescriptor;
OldValue = ExCompareSwapFastReference(FastRef,
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;
}
@ -186,20 +193,6 @@ ObSetSecurityDescriptorInfo(IN PVOID Object,
MAX_FAST_REFS + 1);
}
}
else
{
/* We failed, dereference the old one */
ObDereferenceSecurityDescriptor(OldDescriptor, 1);
break;
}
}
else
{
/* We failed, dereference the old one */
if (OldDescriptor) ObDereferenceSecurityDescriptor(OldDescriptor, 1);
break;
}
}
/* Return status */
return Status;