Security fix

This commit is contained in:
Alex 2022-12-22 01:42:35 +02:00
parent e1036d0ff5
commit 865fa79f0b
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD

View File

@ -22,15 +22,22 @@ namespace Memory
void Tracker::FreePages(void *Address, size_t Count)
{
KernelAllocator.FreePages(Address, Count);
for (size_t i = 0; i < Count; i++)
Memory::Virtual(this->PageTable).Remap((void *)((uintptr_t)Address + (i * PAGE_SIZE)), (void *)((uint64_t)Address + (i * PAGE_SIZE)), Memory::PTFlag::RW);
for (uintptr_t i = 0; i < AllocatedPagesList.size(); i++)
for (size_t i = 0; i < AllocatedPagesList.size(); i++)
if (AllocatedPagesList[i].Address == Address)
{
// TODO: Advanced checks. Allow if the page count is less than the requested one.
if (AllocatedPagesList[i].PageCount != Count)
{
error("FreePages: Page count mismatch! (Allocated: %lld, Requested: %lld)", AllocatedPagesList[i].PageCount, Count);
return;
}
KernelAllocator.FreePages(Address, Count);
for (size_t i = 0; i < Count; i++)
Memory::Virtual(this->PageTable).Remap((void *)((uintptr_t)Address + (i * PAGE_SIZE)), (void *)((uint64_t)Address + (i * PAGE_SIZE)), Memory::PTFlag::RW);
AllocatedPagesList.remove(i);
break;
return;
}
}