Strip MM_POOL_PROTECTED flag to maintain NT compatibility and ensure correct pool tracking hash lookups
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 23s
Builds / ExectOS (i686, release) (push) Successful in 26s
Builds / ExectOS (i686, debug) (push) Successful in 37s
Builds / ExectOS (amd64, release) (push) Successful in 39s

This commit is contained in:
2026-03-24 08:39:47 +01:00
parent 4292d89185
commit b95613787a
2 changed files with 20 additions and 1 deletions

View File

@@ -35,6 +35,7 @@
/* Pool flags */ /* Pool flags */
#define MM_POOL_BIG_ALLOCATIONS_ENTRY_FREE 0x1 #define MM_POOL_BIG_ALLOCATIONS_ENTRY_FREE 0x1
#define MM_POOL_PROTECTED 0x80000000
#define MM_POOL_RAISE_EXCEPTION 0x10 #define MM_POOL_RAISE_EXCEPTION 0x10
/* Number of reserved zeroed PTEs */ /* Number of reserved zeroed PTEs */

View File

@@ -1053,7 +1053,12 @@ MM::Allocator::FreePool(IN PVOID VirtualAddress,
/* Retrieve original metadata while removing the allocation from the tracking table */ /* Retrieve original metadata while removing the allocation from the tracking table */
Tag = UnregisterBigAllocationTag(VirtualAddress, &PageCount, PoolType); Tag = UnregisterBigAllocationTag(VirtualAddress, &PageCount, PoolType);
if(!Tag) if(Tag & MM_POOL_PROTECTED)
{
/* Strip the protected pool bit */
Tag &= ~MM_POOL_PROTECTED;
}
else if(!Tag)
{ {
/* Fallback to a default tag */ /* Fallback to a default tag */
Tag = SIGNATURE32('B', 'i', 'g', 'A'); Tag = SIGNATURE32('B', 'i', 'g', 'A');
@@ -1100,6 +1105,13 @@ MM::Allocator::FreePool(IN PVOID VirtualAddress,
Tag = PoolEntry->PoolTag; Tag = PoolEntry->PoolTag;
Combined = FALSE; Combined = FALSE;
/* Check if the allocation tag carries the protected pool modifier */
if(Tag & MM_POOL_PROTECTED)
{
/* Strip the protected pool bit */
Tag &= ~MM_POOL_PROTECTED;
}
/* Remove the allocation from the tracking table */ /* Remove the allocation from the tracking table */
UnregisterAllocationTag(Tag, BlockSize * MM_POOL_BLOCK_SIZE, (MMPOOL_TYPE)(PoolEntry->PoolType - 1)); UnregisterAllocationTag(Tag, BlockSize * MM_POOL_BLOCK_SIZE, (MMPOOL_TYPE)(PoolEntry->PoolType - 1));
@@ -1467,6 +1479,9 @@ MM::Allocator::RegisterAllocationTag(IN ULONG Tag,
Processor = KE::Processor::GetCurrentProcessorNumber(); Processor = KE::Processor::GetCurrentProcessorNumber();
CpuTable = TagTables[Processor]; CpuTable = TagTables[Processor];
/* Strip the protected pool bit */
Tag &= ~MM_POOL_PROTECTED;
/* Compute the initial hash index */ /* Compute the initial hash index */
Hash = ComputeHash(Tag, AllocationsTrackingTableMask); Hash = ComputeHash(Tag, AllocationsTrackingTableMask);
Index = Hash; Index = Hash;
@@ -1861,6 +1876,9 @@ MM::Allocator::UnregisterAllocationTag(IN ULONG Tag,
Processor = KE::Processor::GetCurrentProcessorNumber(); Processor = KE::Processor::GetCurrentProcessorNumber();
CpuTable = TagTables[Processor]; CpuTable = TagTables[Processor];
/* Strip the protected pool bit */
Tag &= ~MM_POOL_PROTECTED;
/* Compute the initial hash index */ /* Compute the initial hash index */
Hash = ComputeHash(Tag, AllocationsTrackingTableMask); Hash = ComputeHash(Tag, AllocationsTrackingTableMask);
Index = Hash; Index = Hash;