https://git.reactos.org/?p=reactos.git;a=commitdiff;h=28193399ee039b62a03f8…
commit 28193399ee039b62a03f8ad8c6b23d6bb04facfe
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Jan 6 12:58:14 2019 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Sun Jan 6 12:58:14 2019 +0100
[NTOSKRNL] Properly check for address validity in !poolfind
---
ntoskrnl/mm/ARM3/expool.c | 54 ++++++++++++++++++-----------------------------
1 file changed, 21 insertions(+), 33 deletions(-)
diff --git a/ntoskrnl/mm/ARM3/expool.c b/ntoskrnl/mm/ARM3/expool.c
index e03645387a..e69be03cbf 100644
--- a/ntoskrnl/mm/ARM3/expool.c
+++ b/ntoskrnl/mm/ARM3/expool.c
@@ -3163,7 +3163,6 @@ ExpKdbgExtPoolFindPagedPool(
ULONG i = 0;
PPOOL_HEADER Entry;
PVOID BaseVa;
- PMMPTE PointerPte;
PMMPDE PointerPde;
KdbpPrint("Searching Paged pool (%p : %p) for Tag: %.4s\n",
MmPagedPoolStart, MmPagedPoolEnd, (PCHAR)&Tag);
@@ -3192,13 +3191,7 @@ ExpKdbgExtPoolFindPagedPool(
}
/* Check if allocation is valid */
- PointerPte = MiAddressToPte(BaseVa);
- if ((ULONG_PTR)PointerPte > PTE_TOP)
- {
- break;
- }
-
- if (PointerPte->u.Hard.Valid)
+ if (MmIsAddressValid(BaseVa))
{
for (Entry = BaseVa;
(ULONG_PTR)Entry + sizeof(POOL_HEADER) < (ULONG_PTR)BaseVa +
PAGE_SIZE;
@@ -3243,7 +3236,6 @@ ExpKdbgExtPoolFindNonPagedPool(
{
PPOOL_HEADER Entry;
PVOID BaseVa;
- PMMPTE PointerPte;
KdbpPrint("Searching NonPaged pool (%p : %p) for Tag: %.4s\n",
MmNonPagedPoolStart, MmNonPagedPoolEnd0, (PCHAR)&Tag);
@@ -3261,38 +3253,34 @@ ExpKdbgExtPoolFindNonPagedPool(
}
/* Check if allocation is valid */
- PointerPte = MiAddressToPte(BaseVa);
- if ((ULONG_PTR)PointerPte > PTE_TOP)
+ if (!MmIsAddressValid(BaseVa))
{
- break;
+ continue;
}
- if (PointerPte->u.Hard.Valid)
+ for (Entry = BaseVa;
+ (ULONG_PTR)Entry + sizeof(POOL_HEADER) < (ULONG_PTR)BaseVa + PAGE_SIZE;
+ Entry = (PVOID)((ULONG_PTR)Entry + 8))
{
- for (Entry = BaseVa;
- (ULONG_PTR)Entry + sizeof(POOL_HEADER) < (ULONG_PTR)BaseVa +
PAGE_SIZE;
- Entry = (PVOID)((ULONG_PTR)Entry + 8))
+ /* Try to find whether we have a pool entry */
+ if (!ExpKdbgExtValidatePoolHeader(BaseVa, Entry, NonPagedPool))
{
- /* Try to find whether we have a pool entry */
- if (!ExpKdbgExtValidatePoolHeader(BaseVa, Entry, NonPagedPool))
+ continue;
+ }
+
+ if ((Entry->PoolTag & Mask) == (Tag & Mask))
+ {
+ if (FoundCallback != NULL)
{
- continue;
+ FoundCallback(Entry, CallbackContext);
}
-
- if ((Entry->PoolTag & Mask) == (Tag & Mask))
+ else
{
- if (FoundCallback != NULL)
- {
- FoundCallback(Entry, CallbackContext);
- }
- else
- {
- /* Print the line */
- KdbpPrint("%p size: %4d previous size: %4d %s
%.4s\n",
- Entry, Entry->BlockSize, Entry->PreviousSize,
- Entry->PoolType ? "(Allocated)" :
"(Free) ",
- (PCHAR)&Entry->PoolTag);
- }
+ /* Print the line */
+ KdbpPrint("%p size: %4d previous size: %4d %s %.4s\n",
+ Entry, Entry->BlockSize, Entry->PreviousSize,
+ Entry->PoolType ? "(Allocated)" : "(Free)
",
+ (PCHAR)&Entry->PoolTag);
}
}
}