summaryrefslogtreecommitdiff
path: root/Kernel/VM/MemoryManager.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-15 22:21:28 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-15 22:21:28 +0100
commit0a75a46501d45f8f537934191227d07d0f1a44ca (patch)
tree1bb4785face1bdb098a9f96109a585e2487f6454 /Kernel/VM/MemoryManager.cpp
parent77cf607cdabfdf9231767556b86e85be0f40b20b (diff)
downloadserenity-0a75a46501d45f8f537934191227d07d0f1a44ca.zip
Kernel: Make sure the kernel info page is read-only for userspace
To enforce this, we create two separate mappings of the same underlying physical page. A writable mapping for the kernel, and a read-only one for userspace (the one returned by sys$get_kernel_info_page.)
Diffstat (limited to 'Kernel/VM/MemoryManager.cpp')
-rw-r--r--Kernel/VM/MemoryManager.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp
index 5515411d6c..92e240ecff 100644
--- a/Kernel/VM/MemoryManager.cpp
+++ b/Kernel/VM/MemoryManager.cpp
@@ -369,6 +369,17 @@ OwnPtr<Region> MemoryManager::allocate_user_accessible_kernel_region(size_t size
return allocate_kernel_region(size, name, true);
}
+OwnPtr<Region> MemoryManager::allocate_kernel_region_with_vmobject(VMObject& vmobject, size_t size, const StringView& name)
+{
+ InterruptDisabler disabler;
+ ASSERT(!(size % PAGE_SIZE));
+ auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
+ ASSERT(range.is_valid());
+ auto region = make<Region>(range, vmobject, 0, name, PROT_READ | PROT_WRITE | PROT_EXEC);
+ region->map(kernel_page_directory());
+ return region;
+}
+
void MemoryManager::deallocate_user_physical_page(PhysicalPage&& page)
{
for (auto& region : m_user_physical_regions) {