mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
Kernel: Don't consider kernel memory regions for syscall origin check
We should never enter the syscall handler from a kernel address.
This commit is contained in:
parent
d71f64b97f
commit
c6b7b98b64
Notes:
sideshowbarker
2024-07-18 19:19:24 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/c6b7b98b641
3 changed files with 6 additions and 6 deletions
|
@ -190,7 +190,7 @@ void syscall_handler(TrapFrame* trap)
|
|||
handle_crash(regs, "Bad stack on syscall entry", SIGSTKFLT);
|
||||
}
|
||||
|
||||
auto* calling_region = MM.find_region_from_vaddr(process.space(), VirtualAddress(regs.eip));
|
||||
auto* calling_region = MM.find_user_region_from_vaddr(process.space(), VirtualAddress(regs.eip));
|
||||
if (!calling_region) {
|
||||
dbgln("Syscall from {:p} which has no associated region", regs.eip);
|
||||
handle_crash(regs, "Syscall from unknown region", SIGSEGV);
|
||||
|
|
|
@ -431,7 +431,7 @@ Region* MemoryManager::kernel_region_from_vaddr(VirtualAddress vaddr)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Region* MemoryManager::user_region_from_vaddr(Space& space, VirtualAddress vaddr)
|
||||
Region* MemoryManager::find_user_region_from_vaddr(Space& space, VirtualAddress vaddr)
|
||||
{
|
||||
ScopedSpinLock lock(space.get_lock());
|
||||
return space.find_region_containing({ vaddr, 1 });
|
||||
|
@ -440,7 +440,7 @@ Region* MemoryManager::user_region_from_vaddr(Space& space, VirtualAddress vaddr
|
|||
Region* MemoryManager::find_region_from_vaddr(Space& space, VirtualAddress vaddr)
|
||||
{
|
||||
ScopedSpinLock lock(s_mm_lock);
|
||||
if (auto* region = user_region_from_vaddr(space, vaddr))
|
||||
if (auto* region = find_user_region_from_vaddr(space, vaddr))
|
||||
return region;
|
||||
return kernel_region_from_vaddr(vaddr);
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ Region* MemoryManager::find_region_from_vaddr(VirtualAddress vaddr)
|
|||
if (!page_directory)
|
||||
return nullptr;
|
||||
VERIFY(page_directory->space());
|
||||
return user_region_from_vaddr(*page_directory->space(), vaddr);
|
||||
return find_user_region_from_vaddr(*page_directory->space(), vaddr);
|
||||
}
|
||||
|
||||
PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault)
|
||||
|
@ -855,7 +855,7 @@ bool MemoryManager::validate_user_stack(const Process& process, VirtualAddress v
|
|||
if (!is_user_address(vaddr))
|
||||
return false;
|
||||
ScopedSpinLock lock(s_mm_lock);
|
||||
auto* region = user_region_from_vaddr(const_cast<Process&>(process).space(), vaddr);
|
||||
auto* region = find_user_region_from_vaddr(const_cast<Process&>(process).space(), vaddr);
|
||||
return region && region->is_user() && region->is_stack();
|
||||
}
|
||||
|
||||
|
|
|
@ -188,6 +188,7 @@ public:
|
|||
}
|
||||
|
||||
static Region* find_region_from_vaddr(Space&, VirtualAddress);
|
||||
static Region* find_user_region_from_vaddr(Space&, VirtualAddress);
|
||||
|
||||
void dump_kernel_regions();
|
||||
|
||||
|
@ -215,7 +216,6 @@ private:
|
|||
static void flush_tlb_local(VirtualAddress, size_t page_count = 1);
|
||||
static void flush_tlb(const PageDirectory*, VirtualAddress, size_t page_count = 1);
|
||||
|
||||
static Region* user_region_from_vaddr(Space&, VirtualAddress);
|
||||
static Region* kernel_region_from_vaddr(VirtualAddress);
|
||||
|
||||
static Region* find_region_from_vaddr(VirtualAddress);
|
||||
|
|
Loading…
Reference in a new issue