mirror of
https://github.com/RGBCube/serenity
synced 2025-07-08 17:47:35 +00:00
Kernel: Always reject never-userspace addresses before checking regions
At the moment, addresses below 8MB and above 3GB are never accessible to userspace, so just reject them without even looking at the current process's memory regions.
This commit is contained in:
parent
8a0ef92100
commit
c9ec415e2f
1 changed files with 11 additions and 0 deletions
|
@ -584,20 +584,31 @@ void MemoryManager::unquickmap_page()
|
|||
m_quickmap_in_use = false;
|
||||
}
|
||||
|
||||
static inline bool is_user_address(VirtualAddress vaddr)
|
||||
{
|
||||
return vaddr.get() >= (8 * MB) && vaddr.get() < 0xc0000000;
|
||||
}
|
||||
|
||||
bool MemoryManager::validate_user_stack(const Process& process, VirtualAddress vaddr) const
|
||||
{
|
||||
if (!is_user_address(vaddr))
|
||||
return false;
|
||||
auto* region = user_region_from_vaddr(const_cast<Process&>(process), vaddr);
|
||||
return region && region->is_user_accessible() && region->is_stack();
|
||||
}
|
||||
|
||||
bool MemoryManager::validate_user_read(const Process& process, VirtualAddress vaddr) const
|
||||
{
|
||||
if (!is_user_address(vaddr))
|
||||
return false;
|
||||
auto* region = user_region_from_vaddr(const_cast<Process&>(process), vaddr);
|
||||
return region && region->is_user_accessible() && region->is_readable();
|
||||
}
|
||||
|
||||
bool MemoryManager::validate_user_write(const Process& process, VirtualAddress vaddr) const
|
||||
{
|
||||
if (!is_user_address(vaddr))
|
||||
return false;
|
||||
auto* region = user_region_from_vaddr(const_cast<Process&>(process), vaddr);
|
||||
return region && region->is_user_accessible() && region->is_writable();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue