Kernel + LibPthread: Use Userspace<T> in the create_thread syscall
This commit is contained in:
parent
337e8f98cd
commit
7490ea9449
Notes:
sideshowbarker
2024-07-19 04:17:43 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/7490ea94494 Pull-request: https://github.com/SerenityOS/serenity/pull/2996
4 changed files with 6 additions and 6 deletions
|
@ -355,7 +355,7 @@ struct SC_create_thread_params {
|
|||
unsigned int m_guard_page_size = 0; // Rounded up to PAGE_SIZE
|
||||
unsigned int m_reported_guard_page_size = 0; // The lie we tell callers
|
||||
unsigned int m_stack_size = 4 * MB; // Default PTHREAD_STACK_MIN
|
||||
void* m_stack_location = nullptr; // nullptr means any, o.w. process virtual address
|
||||
Userspace<void*> m_stack_location; // nullptr means any, o.w. process virtual address
|
||||
};
|
||||
|
||||
struct SC_realpath_params {
|
||||
|
|
|
@ -296,7 +296,7 @@ public:
|
|||
int sys$getpeername(const Syscall::SC_getpeername_params*);
|
||||
int sys$sched_setparam(pid_t pid, Userspace<const struct sched_param*>);
|
||||
int sys$sched_getparam(pid_t pid, Userspace<struct sched_param*>);
|
||||
int sys$create_thread(void* (*)(void*), const Syscall::SC_create_thread_params*);
|
||||
int sys$create_thread(void* (*)(void*), Userspace<const Syscall::SC_create_thread_params*>);
|
||||
void sys$exit_thread(void*);
|
||||
int sys$join_thread(int tid, void** exit_value);
|
||||
int sys$detach_thread(int tid);
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
int Process::sys$create_thread(void* (*entry)(void*), const Syscall::SC_create_thread_params* user_params)
|
||||
int Process::sys$create_thread(void* (*entry)(void*), Userspace<const Syscall::SC_create_thread_params*> user_params)
|
||||
{
|
||||
REQUIRE_PROMISE(thread);
|
||||
if (!validate_read((const void*)entry, sizeof(void*)))
|
||||
|
@ -45,13 +45,13 @@ int Process::sys$create_thread(void* (*entry)(void*), const Syscall::SC_create_t
|
|||
|
||||
unsigned detach_state = params.m_detach_state;
|
||||
int schedule_priority = params.m_schedule_priority;
|
||||
void* stack_location = params.m_stack_location;
|
||||
Userspace<void*> stack_location = params.m_stack_location;
|
||||
unsigned stack_size = params.m_stack_size;
|
||||
|
||||
if (!validate_write(stack_location, stack_size))
|
||||
return -EFAULT;
|
||||
|
||||
u32 user_stack_address = reinterpret_cast<u32>(stack_location) + stack_size;
|
||||
u32 user_stack_address = reinterpret_cast<u32>(stack_location.ptr()) + stack_size;
|
||||
|
||||
if (!MM.validate_user_stack(*this, VirtualAddress(user_stack_address - 4)))
|
||||
return -EFAULT;
|
||||
|
|
|
@ -383,7 +383,7 @@ int pthread_attr_getstack(const pthread_attr_t* attributes, void** p_stack_ptr,
|
|||
if (!attributes_impl || !p_stack_ptr || !p_stack_size)
|
||||
return EINVAL;
|
||||
|
||||
*p_stack_ptr = attributes_impl->m_stack_location;
|
||||
*p_stack_ptr = attributes_impl->m_stack_location.ptr();
|
||||
*p_stack_size = attributes_impl->m_stack_size;
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue