[NTOSKRNL]

- More pool tagging!

svn path=/trunk/; revision=66948
This commit is contained in:
Thomas Faber 2015-03-29 06:04:19 +00:00
parent 1a06e54fa5
commit 9a56808986
9 changed files with 60 additions and 46 deletions

View file

@ -164,16 +164,14 @@
/* formerly located in rtl/handle.c */
#define TAG_HDTB 'BTDH'
/* formerly located in se/acl.c */
#define TAG_ACL 'cAeS'
/* formerly located in se/sid.c */
#define TAG_SID 'iSeS'
/* formerly located in se/sd.c */
#define TAG_SD 'dSeS'
/* formerly located in se/token.c */
/* Security Manager Tags */
#define TAG_SE ' eS'
#define TAG_ACL 'cAeS'
#define TAG_SID 'iSeS'
#define TAG_SD 'dSeS'
#define TAG_QOS 'sQeS'
#define TAG_LUID 'uLeS'
#define TAG_PRIVILEGE_SET 'rPeS'
#define TAG_TOKEN_USERS 'uKOT'
#define TAG_TOKEN_PRIVILAGES 'pKOT'
#define TAG_TOKEN_ACL 'kDOT'

View file

@ -164,7 +164,7 @@ NtSecureConnectPort(OUT PHANDLE PortHandle,
//Status = SeQueryInformationToken(Token, TokenUser, (PVOID*)&TokenUserInfo);
// FIXME: Need SeQueryInformationToken
Status = STATUS_SUCCESS;
TokenUserInfo = ExAllocatePool(PagedPool, sizeof(TOKEN_USER));
TokenUserInfo = ExAllocatePoolWithTag(PagedPool, sizeof(TOKEN_USER), TAG_SE);
TokenUserInfo->User.Sid = ServerSid;
PsDereferencePrimaryToken(Token);
@ -179,7 +179,7 @@ NtSecureConnectPort(OUT PHANDLE PortHandle,
}
/* Free token information */
ExFreePool(TokenUserInfo);
ExFreePoolWithTag(TokenUserInfo, TAG_SE);
}
}
else

View file

@ -91,7 +91,7 @@ PopGetSysButtonCompletion(
if (!SysButtonContext->WorkItem)
{
DPRINT("IoAllocateWorkItem() failed\n");
ExFreePool(SysButtonContext);
ExFreePoolWithTag(SysButtonContext, 'IWOP');
return STATUS_SUCCESS;
}
IoQueueWorkItem(
@ -139,7 +139,7 @@ PopGetSysButton(
else
{
DPRINT1("IoBuildDeviceIoControlRequest() failed\n");
ExFreePool(SysButtonContext);
ExFreePoolWithTag(SysButtonContext, 'IWOP');
}
IoFreeWorkItem(CurrentWorkItem);
@ -258,10 +258,12 @@ PopAddRemoveSysCapsCallback(IN PVOID NotificationStructure,
DPRINT(" )\n");
}
SysButtonContext = ExAllocatePool(NonPagedPool, sizeof(SYS_BUTTON_CONTEXT));
SysButtonContext = ExAllocatePoolWithTag(NonPagedPool,
sizeof(SYS_BUTTON_CONTEXT),
'IWOP');
if (!SysButtonContext)
{
DPRINT1("ExAllocatePool() failed\n");
DPRINT1("ExAllocatePoolWithTag() failed\n");
ZwClose(FileHandle);
return STATUS_INSUFFICIENT_RESOURCES;
}
@ -273,7 +275,7 @@ PopAddRemoveSysCapsCallback(IN PVOID NotificationStructure,
{
DPRINT1("IoAllocateWorkItem() failed\n");
ZwClose(FileHandle);
ExFreePool(SysButtonContext);
ExFreePoolWithTag(SysButtonContext, 'IWOP');
return STATUS_INSUFFICIENT_RESOURCES;
}
IoQueueWorkItem(

View file

@ -59,7 +59,7 @@ PopRequestPowerIrpCompletion(IN PDEVICE_OBJECT DeviceObject,
IoFreeIrp(Irp);
ObDereferenceObject(RequestPowerItem->TopDeviceObject);
ExFreePool(Context);
ExFreePoolWithTag(Context, 'IRoP');
return STATUS_MORE_PROCESSING_REQUIRED;
}
@ -528,7 +528,9 @@ PoRequestPowerIrp(IN PDEVICE_OBJECT DeviceObject,
&& MinorFunction != IRP_MN_WAIT_WAKE)
return STATUS_INVALID_PARAMETER_2;
RequestPowerItem = ExAllocatePool(NonPagedPool, sizeof(REQUEST_POWER_ITEM));
RequestPowerItem = ExAllocatePoolWithTag(NonPagedPool,
sizeof(REQUEST_POWER_ITEM),
'IRoP');
if (!RequestPowerItem)
return STATUS_INSUFFICIENT_RESOURCES;
@ -544,7 +546,7 @@ PoRequestPowerIrp(IN PDEVICE_OBJECT DeviceObject,
if (!Irp)
{
ObDereferenceObject(TopDeviceObject);
ExFreePool(RequestPowerItem);
ExFreePoolWithTag(RequestPowerItem, 'IRoP');
return STATUS_INSUFFICIENT_RESOURCES;
}

View file

@ -14,6 +14,7 @@
#include <debug.h>
#define TAG_ATMT 'TotA' /* Atom table */
#define TAG_RTHL 'LHtR' /* Heap Lock */
extern ULONG NtGlobalFlag;
@ -159,7 +160,7 @@ NTAPI
RtlDeleteHeapLock(IN OUT PHEAP_LOCK Lock)
{
ExDeleteResourceLite(&Lock->Resource);
ExFreePool(Lock);
ExFreePoolWithTag(Lock, TAG_RTHL);
return STATUS_SUCCESS;
}
@ -200,7 +201,9 @@ NTSTATUS
NTAPI
RtlInitializeHeapLock(IN OUT PHEAP_LOCK *Lock)
{
PHEAP_LOCK HeapLock = ExAllocatePool(NonPagedPool, sizeof(HEAP_LOCK));
PHEAP_LOCK HeapLock = ExAllocatePoolWithTag(NonPagedPool,
sizeof(HEAP_LOCK),
TAG_RTHL);
if (HeapLock == NULL)
return STATUS_NO_MEMORY;
@ -580,8 +583,9 @@ RtlpDestroyAtomHandleTable(PRTL_ATOM_TABLE AtomTable)
PRTL_ATOM_TABLE
RtlpAllocAtomTable(ULONG Size)
{
PRTL_ATOM_TABLE Table = ExAllocatePool(NonPagedPool,
Size);
PRTL_ATOM_TABLE Table = ExAllocatePoolWithTag(NonPagedPool,
Size,
TAG_ATMT);
if (Table != NULL)
{
RtlZeroMemory(Table,
@ -594,7 +598,7 @@ RtlpAllocAtomTable(ULONG Size)
VOID
RtlpFreeAtomTable(PRTL_ATOM_TABLE AtomTable)
{
ExFreePool(AtomTable);
ExFreePoolWithTag(AtomTable, TAG_ATMT);
}
PRTL_ATOM_TABLE_ENTRY

View file

@ -460,7 +460,8 @@ SeDeleteAccessState(IN PACCESS_STATE AccessState)
AuxData = AccessState->AuxData;
/* Deallocate Privileges */
if (AccessState->PrivilegesAllocated) ExFreePool(AuxData->PrivilegeSet);
if (AccessState->PrivilegesAllocated)
ExFreePoolWithTag(AuxData->PrivilegeSet, TAG_PRIVILEGE_SET);
/* Deallocate Name and Type Name */
if (AccessState->ObjectName.Buffer)

View file

@ -1113,7 +1113,7 @@ NtOpenObjectAuditAlarm(
/* Allocate a temp buffer */
CapturedPrivilegeSet = ExAllocatePoolWithTag(PagedPool,
PrivilegeSetSize,
'rPeS');
TAG_PRIVILEGE_SET);
if (CapturedPrivilegeSet == NULL)
{
DPRINT1("Failed to allocate %u bytes\n", PrivilegeSetSize);
@ -1215,7 +1215,7 @@ Cleanup:
SeReleaseSecurityDescriptor(CapturedSecurityDescriptor, UserMode, FALSE);
if (CapturedPrivilegeSet != NULL)
ExFreePoolWithTag(CapturedPrivilegeSet, 'rPeS');
ExFreePoolWithTag(CapturedPrivilegeSet, TAG_PRIVILEGE_SET);
/* Release the security subject context */
SeReleaseSubjectContext(&SubjectContext);
@ -1336,7 +1336,7 @@ NtPrivilegedServiceAuditAlarm(
/* Allocate a temp buffer */
CapturedPrivileges = ExAllocatePoolWithTag(PagedPool,
PrivilegesSize,
'rPeS');
TAG_PRIVILEGE_SET);
if (CapturedPrivileges == NULL)
{
DPRINT1("Failed to allocate %u bytes\n", PrivilegesSize);
@ -1375,7 +1375,7 @@ Cleanup:
ReleaseCapturedUnicodeString(&CapturedServiceName, PreviousMode);
if (CapturedPrivileges != NULL)
ExFreePoolWithTag(CapturedPrivileges, 'rPeS');
ExFreePoolWithTag(CapturedPrivileges, TAG_PRIVILEGE_SET);
/* Release the security subject context */
SeReleaseSubjectContext(&SubjectContext);

View file

@ -219,7 +219,7 @@ SePrivilegePolicyCheck(
{
/* Calculate size and allocate the structure */
PrivilegeSize = FIELD_OFFSET(PRIVILEGE_SET, Privilege[PrivilegeCount]);
PrivilegeSet = ExAllocatePoolWithTag(PagedPool, PrivilegeSize, 'rPeS');
PrivilegeSet = ExAllocatePoolWithTag(PagedPool, PrivilegeSize, TAG_PRIVILEGE_SET);
*OutPrivilegeSet = PrivilegeSet;
if (PrivilegeSet == NULL)
{
@ -352,8 +352,9 @@ SeCaptureLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Src,
}
else
{
*Dest = ExAllocatePool(PoolType,
BufferSize);
*Dest = ExAllocatePoolWithTag(PoolType,
BufferSize,
TAG_LUID);
if (*Dest == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
@ -375,7 +376,7 @@ SeCaptureLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Src,
if (!NT_SUCCESS(Status) && AllocatedMem == NULL)
{
ExFreePool(*Dest);
ExFreePoolWithTag(*Dest, TAG_LUID);
}
return Status;
@ -392,7 +393,7 @@ SeReleaseLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Privilege,
if (Privilege != NULL &&
(PreviousMode != KernelMode || CaptureIfKernel))
{
ExFreePool(Privilege);
ExFreePoolWithTag(Privilege, TAG_LUID);
}
}
@ -428,7 +429,9 @@ SeAppendPrivileges(IN OUT PACCESS_STATE AccessState,
Privileges->PrivilegeCount * sizeof(LUID_AND_ATTRIBUTES);
/* Allocate a new privilege set */
PrivilegeSet = ExAllocatePool(PagedPool, NewPrivilegeSetSize);
PrivilegeSet = ExAllocatePoolWithTag(PagedPool,
NewPrivilegeSetSize,
TAG_PRIVILEGE_SET);
if (PrivilegeSet == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
@ -447,7 +450,7 @@ SeAppendPrivileges(IN OUT PACCESS_STATE AccessState,
/* Free the old privilege set if it was allocated */
if (AccessState->PrivilegesAllocated != FALSE)
ExFreePool(AuxData->PrivilegeSet);
ExFreePoolWithTag(AuxData->PrivilegeSet, TAG_PRIVILEGE_SET);
/* Now we are using an allocated privilege set */
AccessState->PrivilegesAllocated = TRUE;
@ -477,7 +480,7 @@ NTAPI
SeFreePrivileges(IN PPRIVILEGE_SET Privileges)
{
PAGED_CODE();
ExFreePool(Privileges);
ExFreePoolWithTag(Privileges, TAG_PRIVILEGE_SET);
}
/*

View file

@ -281,8 +281,9 @@ SepCaptureSecurityQualityOfService(IN POBJECT_ATTRIBUTES ObjectAttributes OPTIO
{
if (*Present)
{
CapturedQos = ExAllocatePool(PoolType,
sizeof(SECURITY_QUALITY_OF_SERVICE));
CapturedQos = ExAllocatePoolWithTag(PoolType,
sizeof(SECURITY_QUALITY_OF_SERVICE),
TAG_QOS);
if (CapturedQos != NULL)
{
RtlCopyMemory(CapturedQos,
@ -312,8 +313,9 @@ SepCaptureSecurityQualityOfService(IN POBJECT_ATTRIBUTES ObjectAttributes OPTIO
if (((PSECURITY_QUALITY_OF_SERVICE)ObjectAttributes->SecurityQualityOfService)->Length ==
sizeof(SECURITY_QUALITY_OF_SERVICE))
{
CapturedQos = ExAllocatePool(PoolType,
sizeof(SECURITY_QUALITY_OF_SERVICE));
CapturedQos = ExAllocatePoolWithTag(PoolType,
sizeof(SECURITY_QUALITY_OF_SERVICE),
TAG_QOS);
if (CapturedQos != NULL)
{
RtlCopyMemory(CapturedQos,
@ -371,7 +373,7 @@ SepReleaseSecurityQualityOfService(IN PSECURITY_QUALITY_OF_SERVICE CapturedSecur
if (CapturedSecurityQualityOfService != NULL &&
(AccessMode != KernelMode || CaptureIfKernel))
{
ExFreePool(CapturedSecurityQualityOfService);
ExFreePoolWithTag(CapturedSecurityQualityOfService, TAG_QOS);
}
}
@ -904,9 +906,11 @@ SeSetSecurityDescriptorInfoEx(
}
SaclLength = Sacl ? ROUND_UP((ULONG)Sacl->AclSize, 4) : 0;
NewSd = ExAllocatePool(NonPagedPool,
sizeof(SECURITY_DESCRIPTOR_RELATIVE) + OwnerLength + GroupLength +
DaclLength + SaclLength);
NewSd = ExAllocatePoolWithTag(NonPagedPool,
sizeof(SECURITY_DESCRIPTOR_RELATIVE) +
OwnerLength + GroupLength +
DaclLength + SaclLength,
TAG_SD);
if (NewSd == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;