stos: pool: Protect pool structures with lock

Signed-off-by: Chloe M. <chloe@mensia.org>
This commit is contained in:
Chloe M.
2026-06-24 17:43:45 +00:00
parent 995da1df2d
commit ed2d4744d7
2 changed files with 11 additions and 1 deletions
+8 -1
View File
@@ -179,6 +179,7 @@ ExAllocatePoolWithTag(POOL_TYPE Type, USIZE ByteCount, ULONG Tag)
{
KPCR *ThisCore;
MEMORY_POOL *AllocPool;
VOID *Base;
if (ByteCount == 0) {
return NULL;
@@ -195,6 +196,7 @@ ExAllocatePoolWithTag(POOL_TYPE Type, USIZE ByteCount, ULONG Tag)
ThisCore = HalKpcrCurrent();
AllocPool = &ThisCore->AllocPool;
KeSpinLockAcquire(&AllocPool->Lock, false);
/*
* Ensure that the byte count is aligned by the minimum granularity
@@ -207,10 +209,14 @@ ExAllocatePoolWithTag(POOL_TYPE Type, USIZE ByteCount, ULONG Tag)
"allocation in pool #%d exceeds page size\n",
AllocPool->Id
);
KeSpinLockRelease(&AllocPool->Lock);
return NULL;
}
return AllocatePoolWithTag(AllocPool, Type, ByteCount, Tag);
Base = AllocatePoolWithTag(AllocPool, Type, ByteCount, Tag);
KeSpinLockRelease(&AllocPool->Lock);
return Base;
}
ST_STATUS
@@ -225,6 +231,7 @@ ExPoolInit(MEMORY_POOL *Pool)
}
Pool->Id = PoolCount;
KeSpinLockInit(&Pool->Lock, "ex-pool");
DTRACE("bringing up pool #%d\n", Pool->Id);
/* Initialize the pools */