From 54354712e25df2aa2cf562de4dd9251365a041fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Mon, 22 Feb 2021 11:43:04 +0100 Subject: [PATCH] [NTOS:MM] Fail allocating non-paged pool when running out of available pages --- ntoskrnl/mm/ARM3/pool.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ntoskrnl/mm/ARM3/pool.c b/ntoskrnl/mm/ARM3/pool.c index 7c0e1bb93ba..9490f326874 100644 --- a/ntoskrnl/mm/ARM3/pool.c +++ b/ntoskrnl/mm/ARM3/pool.c @@ -849,6 +849,19 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, // MiAcquirePfnLockAtDpcLevel(); + /* Check that we have enough available pages for this request */ + if (MmAvailablePages < SizeInPages) + { + MiReleasePfnLockFromDpcLevel(); + KeReleaseQueuedSpinLock(LockQueueMmNonPagedPoolLock, OldIrql); + + MiReleaseSystemPtes(StartPte, SizeInPages, NonPagedPoolExpansion); + + DPRINT1("OUT OF AVAILABLE PAGES! Required %lu, Available %lu\n", SizeInPages, MmAvailablePages); + + return NULL; + } + // // Loop the pages //