From 651ba03c6d5e252b837c57bf3c9fd63d8a7f9e60 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 10 Jun 2019 14:54:55 +0200 Subject: [PATCH] [NTOSKRNL] Taggify some allocs --- ntoskrnl/include/internal/tag.h | 2 ++ ntoskrnl/se/srm.c | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ntoskrnl/include/internal/tag.h b/ntoskrnl/include/internal/tag.h index cca581f15cf..dc47c9cd4f4 100644 --- a/ntoskrnl/include/internal/tag.h +++ b/ntoskrnl/include/internal/tag.h @@ -178,6 +178,8 @@ #define TAG_LUID 'uLeS' #define TAG_PRIVILEGE_SET 'rPeS' #define TAG_TOKEN_DYNAMIC 'dTeS' +#define TAG_SE_HANDLES_TAB 'aHeS' +#define TAG_SE_DIR_BUFFER 'bDeS' /* LPC Tags */ #define TAG_LPC_MESSAGE 'McpL' diff --git a/ntoskrnl/se/srm.c b/ntoskrnl/se/srm.c index fc91cd1f1dc..d67305036a9 100644 --- a/ntoskrnl/se/srm.c +++ b/ntoskrnl/se/srm.c @@ -489,7 +489,9 @@ SepCleanupLUIDDeviceMapDirectory( * All handles have been already closed */ AllocateLinksAgain: - LinksBuffer = ExAllocatePoolWithTag(PagedPool, LinksSize, 'aHeS'); + LinksBuffer = ExAllocatePoolWithTag(PagedPool, + LinksSize, + TAG_SE_HANDLES_TAB); if (LinksBuffer == NULL) { /* @@ -504,7 +506,7 @@ AllocateLinksAgain: */ if (DirectoryInfo != NULL) { - ExFreePoolWithTag(DirectoryInfo, 0); + ExFreePoolWithTag(DirectoryInfo, TAG_SE_DIR_BUFFER); } if (!UseCurrentProc) @@ -551,7 +553,9 @@ AllocateLinksAgain: } /* And reallocate a bigger one */ - DirectoryInfo = ExAllocatePoolWithTag(PagedPool, DirInfoLength, 'bDeS'); + DirectoryInfo = ExAllocatePoolWithTag(PagedPool, + DirInfoLength, + TAG_SE_DIR_BUFFER); /* Fail if we cannot allocate */ if (DirectoryInfo == NULL) { @@ -584,7 +588,7 @@ AllocateLinksAgain: /* Allow 20 more HANDLEs */ LinksCount += 20; CurrentLinks = 0; - ExFreePoolWithTag(LinksBuffer, 'aHeS'); + ExFreePoolWithTag(LinksBuffer, TAG_SE_HANDLES_TAB); LinksSize = LinksCount * sizeof(HANDLE); /* And reloop again */ @@ -627,12 +631,12 @@ AllocateLinksAgain: ZwClose(LinksBuffer[i]); } /* And free our links buffer */ - ExFreePoolWithTag(LinksBuffer, 'aHeS'); + ExFreePoolWithTag(LinksBuffer, TAG_SE_HANDLES_TAB); /* Free our directory info buffer - it might be NULL if we failed realloc */ if (DirectoryInfo != NULL) { - ExFreePoolWithTag(DirectoryInfo, 'bDeS'); + ExFreePoolWithTag(DirectoryInfo, TAG_SE_DIR_BUFFER); } /* Close our session directory */