mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:28:12 +00:00
Kernel: Skip generic region lookup in sys$futex and sys$get_stack_bounds
Just ask the process space directly instead of using the generic region lookup that also checks for kernel regions.
This commit is contained in:
parent
b31a514cce
commit
b1c9f93fa3
2 changed files with 6 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -25,7 +25,6 @@
|
|||
*/
|
||||
|
||||
#include <AK/Singleton.h>
|
||||
#include <AK/Time.h>
|
||||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
|
@ -145,9 +144,7 @@ int Process::sys$futex(Userspace<const Syscall::SC_futex_params*> user_params)
|
|||
// acquiring the queue lock
|
||||
RefPtr<VMObject> vmobject, vmobject2;
|
||||
if (!is_private) {
|
||||
if (!Kernel::is_user_range(VirtualAddress(user_address_or_offset), sizeof(u32)))
|
||||
return -EFAULT;
|
||||
auto region = MM.find_region_from_vaddr(space(), VirtualAddress(user_address_or_offset));
|
||||
auto region = space().find_region_containing(Range { VirtualAddress { user_address_or_offset }, sizeof(u32) });
|
||||
if (!region)
|
||||
return -EFAULT;
|
||||
vmobject = region->vmobject();
|
||||
|
@ -157,9 +154,7 @@ int Process::sys$futex(Userspace<const Syscall::SC_futex_params*> user_params)
|
|||
case FUTEX_REQUEUE:
|
||||
case FUTEX_CMP_REQUEUE:
|
||||
case FUTEX_WAKE_OP: {
|
||||
if (!Kernel::is_user_range(VirtualAddress(user_address_or_offset2), sizeof(u32)))
|
||||
return -EFAULT;
|
||||
auto region2 = MM.find_region_from_vaddr(space(), VirtualAddress(user_address_or_offset2));
|
||||
auto region2 = space().find_region_containing(Range { VirtualAddress { user_address_or_offset2 }, sizeof(u32) });
|
||||
if (!region2)
|
||||
return -EFAULT;
|
||||
vmobject2 = region2->vmobject();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -25,14 +25,14 @@
|
|||
*/
|
||||
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
#include <Kernel/VM/Region.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
int Process::sys$get_stack_bounds(FlatPtr* user_stack_base, size_t* user_stack_size)
|
||||
{
|
||||
FlatPtr stack_pointer = Thread::current()->get_register_dump_from_stack().userspace_esp;
|
||||
auto* stack_region = MM.find_region_from_vaddr(space(), VirtualAddress(stack_pointer));
|
||||
auto* stack_region = space().find_region_containing(Range { VirtualAddress(stack_pointer), 1 });
|
||||
if (!stack_region) {
|
||||
ASSERT_NOT_REACHED();
|
||||
return -EINVAL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue