summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kaster <akaster@serenityos.org>2021-07-06 20:25:22 -0600
committerAndreas Kling <kling@serenityos.org>2021-07-11 19:42:00 +0200
commit578d45b480c5b167df916ebc42e13bc1bd6153c1 (patch)
tree76a48cbf6eefd12ca746b4d88b3cc07e8712a97a
parentab196b484a4b901886c449f9eebb5e8c8efa290a (diff)
downloadserenity-578d45b480c5b167df916ebc42e13bc1bd6153c1.zip
Kernel: Create and use USER_RANGE_CEILING
We had an inconsistency in valid user addresses. is_user_range() was checking against the kernel base address, but previous changes caused the maximum valid user addressable range to be 32 MiB below that. This patch stops mmap(MAP_FIXED) of a range between these two bounds from panic-ing the kernel in RangeAllocator::allocate_specific.
-rw-r--r--Kernel/Sections.h2
-rw-r--r--Kernel/VM/MemoryManager.h2
-rw-r--r--Kernel/VM/PageDirectory.cpp2
3 files changed, 4 insertions, 2 deletions
diff --git a/Kernel/Sections.h b/Kernel/Sections.h
index dede1e7462..61b5d57e29 100644
--- a/Kernel/Sections.h
+++ b/Kernel/Sections.h
@@ -19,3 +19,5 @@
#define KERNEL_QUICKMAP_PD (KERNEL_PT1024_BASE + 0x7000)
#define KERNEL_QUICKMAP_PER_CPU_BASE (KERNEL_PT1024_BASE + 0x8000)
#define KERNEL_PHYSICAL_PAGES_BASE (KERNEL_BASE + KERNEL_PD_OFFSET)
+
+#define USER_RANGE_CEILING 0xBE000000
diff --git a/Kernel/VM/MemoryManager.h b/Kernel/VM/MemoryManager.h
index 2be1fb9db8..16d695e7c2 100644
--- a/Kernel/VM/MemoryManager.h
+++ b/Kernel/VM/MemoryManager.h
@@ -278,7 +278,7 @@ void VMObject::for_each_region(Callback callback)
inline bool is_user_address(VirtualAddress vaddr)
{
- return vaddr.get() < KERNEL_BASE;
+ return vaddr.get() < USER_RANGE_CEILING;
}
inline bool is_user_range(VirtualAddress vaddr, size_t size)
diff --git a/Kernel/VM/PageDirectory.cpp b/Kernel/VM/PageDirectory.cpp
index 3fd515697f..08897da286 100644
--- a/Kernel/VM/PageDirectory.cpp
+++ b/Kernel/VM/PageDirectory.cpp
@@ -63,7 +63,7 @@ UNMAP_AFTER_INIT void PageDirectory::allocate_kernel_directory()
PageDirectory::PageDirectory(const RangeAllocator* parent_range_allocator)
{
constexpr FlatPtr userspace_range_base = 0x00800000;
- constexpr FlatPtr userspace_range_ceiling = 0xbe000000;
+ constexpr FlatPtr userspace_range_ceiling = USER_RANGE_CEILING;
ScopedSpinLock lock(s_mm_lock);
if (parent_range_allocator) {