mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
cm/regfile.c, ldr/init.c, ldr/loader.c: OBJ_CASE_INSENSITIVE patch I proposed
on the list. This makes the registry, and dll loading case insensitive when we are on a case preserving filesystem. ntoskrnl/ex/power.c: My own contributions to the poweroff message list. ntoskrnl/mm/npool.c: Fixed bit-rot in whole page alloc. That's how i found the bug below. se/semgr.c, lib/rtl/sd.c: semgr, when creating a SECURITY_DESCRIPTOR, anded the PRESENT and DEFAULT flags rather than oring them for group, dacl, and sacl, leading to RtlLengthSecurityDescriptor giving the wrong length to sdcache. When sdcache would copy the security descriptor, it would be too short, and the bound check from the whole-page allocator would go off. I fixed this and made rtl/sd.c use the ROUND_UP macro and RtlLengthSid. This is cleaner. It may not be completely correct yet but it no-longer truncates security descriptors into the cache, which means that the Owner, Group and etc SIDs should now actually work right when coming from the cache, no matter what happens in the heap. They probably seemed to work before simply because they trashed the ends of their blocks and never moved in the cache. svn path=/trunk/; revision=11040
This commit is contained in:
parent
906e734ab4
commit
0089446cc6
7 changed files with 76 additions and 40 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: sd.c,v 1.5 2004/09/22 20:16:02 weiden Exp $
|
||||
/* $Id: sd.c,v 1.6 2004/09/25 06:41:16 arty Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -53,11 +53,10 @@ RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
|
|||
PSID Owner = SecurityDescriptor->Owner;
|
||||
if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
|
||||
{
|
||||
Owner = (PSID)((ULONG_PTR)Owner +
|
||||
(ULONG_PTR)SecurityDescriptor);
|
||||
Owner = (PSID)((ULONG_PTR)Owner +
|
||||
(ULONG_PTR)SecurityDescriptor);
|
||||
}
|
||||
Length = Length + ((sizeof(SID) + (Owner->SubAuthorityCount - 1) *
|
||||
sizeof(ULONG) + 3) & 0xfc);
|
||||
Length = Length + ROUND_UP(RtlLengthSid( Owner ), 4);
|
||||
}
|
||||
|
||||
if (SecurityDescriptor->Group != NULL)
|
||||
|
@ -67,8 +66,7 @@ RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
|
|||
{
|
||||
Group = (PSID)((ULONG_PTR)Group + (ULONG_PTR)SecurityDescriptor);
|
||||
}
|
||||
Length = Length + ((sizeof(SID) + (Group->SubAuthorityCount - 1) *
|
||||
sizeof(ULONG_PTR) + 3) & 0xfc);
|
||||
Length = Length + ROUND_UP(RtlLengthSid( Group ), 4);
|
||||
}
|
||||
|
||||
if (SecurityDescriptor->Control & SE_DACL_PRESENT &&
|
||||
|
@ -79,7 +77,7 @@ RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
|
|||
{
|
||||
Dacl = (PACL)((ULONG_PTR)Dacl + (ULONG_PTR)SecurityDescriptor);
|
||||
}
|
||||
Length = Length + ((Dacl->AclSize + 3) & 0xfc);
|
||||
Length = Length + ROUND_UP(Dacl->AclSize, 4);
|
||||
}
|
||||
|
||||
if (SecurityDescriptor->Control & SE_SACL_PRESENT &&
|
||||
|
@ -90,7 +88,7 @@ RtlLengthSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor)
|
|||
{
|
||||
Sacl = (PACL)((ULONG_PTR)Sacl + (ULONG_PTR)SecurityDescriptor);
|
||||
}
|
||||
Length = Length + ((Sacl->AclSize + 3) & 0xfc);
|
||||
Length = Length + ROUND_UP(Sacl->AclSize, 4);
|
||||
}
|
||||
|
||||
return(Length);
|
||||
|
|
|
@ -433,7 +433,7 @@ CmiCheckAndFixHive(PREGISTRY_HIVE RegistryHive)
|
|||
/* Try to open the hive file */
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&RegistryHive->HiveFileName,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
@ -461,7 +461,7 @@ CmiCheckAndFixHive(PREGISTRY_HIVE RegistryHive)
|
|||
/* Try to open the log file */
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&RegistryHive->LogFileName,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
@ -899,7 +899,7 @@ CmiInitNonVolatileRegistryHive (PREGISTRY_HIVE RegistryHive,
|
|||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&RegistryHive->HiveFileName,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
@ -1423,7 +1423,7 @@ CmiStartLogUpdate(PREGISTRY_HIVE RegistryHive)
|
|||
/* Open log file for writing */
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&RegistryHive->LogFileName,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
@ -1600,7 +1600,7 @@ CmiFinishLogUpdate(PREGISTRY_HIVE RegistryHive)
|
|||
/* Open log file for writing */
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&RegistryHive->LogFileName,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
@ -1701,7 +1701,7 @@ CmiCleanupLogUpdate(PREGISTRY_HIVE RegistryHive)
|
|||
/* Open log file for writing */
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&RegistryHive->LogFileName,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
@ -1779,7 +1779,7 @@ CmiStartHiveUpdate(PREGISTRY_HIVE RegistryHive)
|
|||
/* Open hive for writing */
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&RegistryHive->HiveFileName,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
@ -1890,7 +1890,7 @@ CmiFinishHiveUpdate(PREGISTRY_HIVE RegistryHive)
|
|||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&RegistryHive->HiveFileName,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
|
|
@ -35,7 +35,16 @@ NtShutdownSystem(IN SHUTDOWN_ACTION Action)
|
|||
{
|
||||
"Oh my God, they killed Kenny! Those bastards!\n",
|
||||
"Goodbye, and thanks for all the fish\n",
|
||||
"I'll be back\n"
|
||||
"I think you ought to know I'm feeling very depressed\n",
|
||||
"I'm not getting you down at all am I?\n",
|
||||
"I'll be back\n",
|
||||
"It's the same series of signal over and over again!\n",
|
||||
"Pie Iesu Domine, dona eis requiem\n",
|
||||
"Wandering stars, for whom it is reserved;\n"
|
||||
"the blackness and darkness forever.\n",
|
||||
"Your knees start shakin' and your fingers pop\n"
|
||||
"Like a pinch on the neck from Mr. Spock!\n",
|
||||
"It's worse than that ... He's dead, Jim\n"
|
||||
};
|
||||
LARGE_INTEGER Now;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: init.c,v 1.46 2004/08/15 16:39:06 chorns Exp $
|
||||
/* $Id: init.c,v 1.47 2004/09/25 06:41:16 arty Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ldr/init.c
|
||||
|
@ -62,7 +62,7 @@ LdrpMapProcessImage(PHANDLE SectionHandle,
|
|||
/* Open image file */
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
ImagePath,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: loader.c,v 1.143 2004/08/15 16:39:06 chorns Exp $
|
||||
/* $Id: loader.c,v 1.144 2004/09/25 06:41:16 arty Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -322,7 +322,7 @@ LdrLoadModule(PUNICODE_STRING Filename,
|
|||
/* Open the Module */
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
Filename,
|
||||
0,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
CHECKPOINT;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: npool.c,v 1.89 2004/08/15 16:39:08 chorns Exp $
|
||||
/* $Id: npool.c,v 1.90 2004/09/25 06:41:16 arty Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -24,7 +24,7 @@
|
|||
/*#define ENABLE_VALIDATE_POOL*/
|
||||
|
||||
/* Enable tracking of statistics about the tagged blocks in the pool */
|
||||
#define TAG_STATISTICS_TRACKING
|
||||
/*#define TAG_STATISTICS_TRACKING*/
|
||||
|
||||
/*
|
||||
* Put each block in its own range of pages and position the block at the
|
||||
|
@ -1490,7 +1490,7 @@ VOID STDCALL ExFreeNonPagedPool (PVOID block)
|
|||
return;
|
||||
}
|
||||
|
||||
DPRINT("freeing block %x\n",blk);
|
||||
DPRINT("freeing block %x\n",block);
|
||||
|
||||
POOL_TRACE("ExFreePool(block %x), size %d, caller %x\n",block,blk->size,
|
||||
((PULONG)&block)[-1]);
|
||||
|
@ -1663,7 +1663,7 @@ PVOID STDCALL
|
|||
ExAllocateWholePageBlock(ULONG Size)
|
||||
{
|
||||
PVOID Address;
|
||||
PHYSICAL_ADDRESS Page;
|
||||
PFN_TYPE Page;
|
||||
ULONG i;
|
||||
ULONG NrPages;
|
||||
ULONG Base;
|
||||
|
@ -1680,25 +1680,30 @@ ExAllocateWholePageBlock(ULONG Size)
|
|||
{
|
||||
NonPagedPoolAllocMapHint += (NrPages + 1);
|
||||
}
|
||||
|
||||
Address = MiNonPagedPoolStart + Base * PAGE_SIZE;
|
||||
|
||||
for (i = 0; i < NrPages; i++)
|
||||
{
|
||||
Page = MmAllocPage(MC_NPPOOL, 0);
|
||||
if (Page.QuadPart == 0LL)
|
||||
Page = MmAllocPage(MC_NPPOOL, 0);
|
||||
if (Page == 0)
|
||||
{
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
MmCreateVirtualMapping(NULL,
|
||||
Address + (i * PAGE_SIZE),
|
||||
PAGE_READWRITE | PAGE_SYSTEM,
|
||||
Page,
|
||||
&Page,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
MiCurrentNonPagedPoolLength = max(MiCurrentNonPagedPoolLength, (Base + NrPages) * PAGE_SIZE);
|
||||
Size = (Size + 7) & ~7;
|
||||
return((PVOID)((PUCHAR)Address + (NrPages * PAGE_SIZE) - Size));
|
||||
Address = ((PVOID)((PUCHAR)Address + (NrPages * PAGE_SIZE) - Size));
|
||||
|
||||
DPRINT("WPALLOC: %x (%d)\n", Address, Size);
|
||||
|
||||
return Address;
|
||||
}
|
||||
|
||||
VOID STDCALL
|
||||
|
@ -1729,6 +1734,15 @@ ExFreeWholePageBlock(PVOID Addr)
|
|||
|
||||
#endif /* WHOLE_PAGE_ALLOCATIONS */
|
||||
|
||||
/* Whole Page Allocations note:
|
||||
*
|
||||
* We need enough pages for these things:
|
||||
*
|
||||
* 1) bitmap buffer
|
||||
* 2) hdr
|
||||
* 3) actual pages
|
||||
*
|
||||
*/
|
||||
VOID INIT_FUNCTION
|
||||
MiInitializeNonPagedPool(VOID)
|
||||
{
|
||||
|
@ -1754,7 +1768,7 @@ MiInitializeNonPagedPool(VOID)
|
|||
FreeBlockListRoot = NULL;
|
||||
#ifdef WHOLE_PAGE_ALLOCATIONS
|
||||
|
||||
NonPagedPoolAllocMapHint = PAGE_ROUND_UP(MiNonPagedPoolLength / PAGE_SIZE / 8) / PAGE_SIZE;
|
||||
NonPagedPoolAllocMapHint = PAGE_ROUND_UP(MiNonPagedPoolLength / PAGE_SIZE / 8) / PAGE_SIZE; /* Pages of bitmap buffer */
|
||||
MiCurrentNonPagedPoolLength = NonPagedPoolAllocMapHint * PAGE_SIZE;
|
||||
Address = MiNonPagedPoolStart;
|
||||
for (i = 0; i < NonPagedPoolAllocMapHint; i++)
|
||||
|
@ -1768,8 +1782,8 @@ MiInitializeNonPagedPool(VOID)
|
|||
Status = MmCreateVirtualMapping(NULL,
|
||||
Address,
|
||||
PAGE_READWRITE|PAGE_SYSTEM,
|
||||
Page,
|
||||
FALSE);
|
||||
&Page,
|
||||
1);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("Unable to create virtual mapping\n");
|
||||
|
@ -1777,7 +1791,8 @@ MiInitializeNonPagedPool(VOID)
|
|||
}
|
||||
Address += PAGE_SIZE;
|
||||
}
|
||||
RtlInitializeBitMap(&NonPagedPoolAllocMap, MiNonPagedPoolStart, MM_NONPAGED_POOL_SIZE / PAGE_SIZE);
|
||||
RtlInitializeBitMap(&NonPagedPoolAllocMap, MiNonPagedPoolStart,
|
||||
MiNonPagedPoolLength / PAGE_SIZE);
|
||||
RtlClearAllBits(&NonPagedPoolAllocMap);
|
||||
RtlSetBits(&NonPagedPoolAllocMap, 0, NonPagedPoolAllocMapHint);
|
||||
#else
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: semgr.c,v 1.44 2004/09/14 11:04:48 ekohl Exp $
|
||||
/* $Id: semgr.c,v 1.45 2004/09/25 06:41:16 arty Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -440,20 +440,20 @@ SeAssignSecurity(PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
|
|||
{
|
||||
Dacl = (PACL)(((ULONG_PTR)Dacl) + (ULONG_PTR)ParentDescriptor);
|
||||
}
|
||||
Control |= (SE_DACL_PRESENT & SE_DACL_DEFAULTED);
|
||||
Control |= (SE_DACL_PRESENT | SE_DACL_DEFAULTED);
|
||||
}
|
||||
else if (Token != NULL && Token->DefaultDacl != NULL)
|
||||
{
|
||||
DPRINT("Use token default DACL!\n");
|
||||
/* FIXME: Inherit */
|
||||
Dacl = Token->DefaultDacl;
|
||||
Control |= (SE_DACL_PRESENT & SE_DACL_DEFAULTED);
|
||||
Control |= (SE_DACL_PRESENT | SE_DACL_DEFAULTED);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT("Use NULL DACL!\n");
|
||||
Dacl = NULL;
|
||||
Control |= (SE_DACL_PRESENT & SE_DACL_DEFAULTED);
|
||||
Control |= (SE_DACL_PRESENT | SE_DACL_DEFAULTED);
|
||||
}
|
||||
|
||||
DaclLength = (Dacl != NULL) ? ROUND_UP(Dacl->AclSize, 4) : 0;
|
||||
|
@ -483,14 +483,22 @@ SeAssignSecurity(PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
|
|||
{
|
||||
Sacl = (PACL)(((ULONG_PTR)Sacl) + (ULONG_PTR)ParentDescriptor);
|
||||
}
|
||||
Control |= (SE_SACL_PRESENT & SE_SACL_DEFAULTED);
|
||||
Control |= (SE_SACL_PRESENT | SE_SACL_DEFAULTED);
|
||||
}
|
||||
|
||||
SaclLength = (Sacl != NULL) ? ROUND_UP(Sacl->AclSize, 4) : 0;
|
||||
|
||||
|
||||
/* Allocate and initialize the new security descriptor */
|
||||
Length = sizeof(SECURITY_DESCRIPTOR) + OwnerLength + GroupLength + DaclLength + SaclLength;
|
||||
Length = sizeof(SECURITY_DESCRIPTOR) +
|
||||
OwnerLength + GroupLength + DaclLength + SaclLength;
|
||||
|
||||
DPRINT("L: sizeof(SECURITY_DESCRIPTOR) %d OwnerLength %d GroupLength %d DaclLength %d SaclLength %d\n",
|
||||
sizeof(SECURITY_DESCRIPTOR),
|
||||
OwnerLength,
|
||||
GroupLength,
|
||||
DaclLength,
|
||||
SaclLength);
|
||||
|
||||
Descriptor = ExAllocatePool(NonPagedPool,
|
||||
Length);
|
||||
|
@ -533,7 +541,10 @@ SeAssignSecurity(PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
|
|||
OwnerLength);
|
||||
Descriptor->Owner = (PSID)((ULONG_PTR)Current - (ULONG_PTR)Descriptor);
|
||||
Current += OwnerLength;
|
||||
DPRINT("Owner of %x at %x\n", Descriptor, Descriptor->Owner);
|
||||
}
|
||||
else
|
||||
DPRINT("Owner of %x is zero length\n", Descriptor);
|
||||
|
||||
if (GroupLength != 0)
|
||||
{
|
||||
|
@ -548,6 +559,9 @@ SeAssignSecurity(PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL,
|
|||
|
||||
*NewDescriptor = Descriptor;
|
||||
|
||||
DPRINT("Descrptor %x\n", Descriptor);
|
||||
assert( RtlLengthSecurityDescriptor( Descriptor ) );
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue