From bee08a4b9ff0f2c269a4e3a8159b689fbb8d1ab8 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sun, 9 Aug 2020 01:08:24 +0200 Subject: Kernel: More PID/TID typing --- Kernel/Syscalls/sched.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'Kernel/Syscalls/sched.cpp') diff --git a/Kernel/Syscalls/sched.cpp b/Kernel/Syscalls/sched.cpp index b144f39792..7729a817b0 100644 --- a/Kernel/Syscalls/sched.cpp +++ b/Kernel/Syscalls/sched.cpp @@ -35,7 +35,7 @@ int Process::sys$yield() return 0; } -int Process::sys$donate(int tid) +int Process::sys$donate(pid_t tid) { REQUIRE_PROMISE(stdio); if (tid < 0) @@ -48,7 +48,7 @@ int Process::sys$donate(int tid) return 0; } -int Process::sys$sched_setparam(int tid, Userspace user_param) +int Process::sys$sched_setparam(int pid, Userspace user_param) { REQUIRE_PROMISE(proc); if (!validate_read_typed(user_param)) @@ -59,8 +59,8 @@ int Process::sys$sched_setparam(int tid, Userspace us InterruptDisabler disabler; auto* peer = Thread::current(); - if (tid != 0) - peer = Thread::from_tid(tid); + if (pid != 0) + peer = Thread::from_tid(pid); if (!peer) return -ESRCH; @@ -68,8 +68,7 @@ int Process::sys$sched_setparam(int tid, Userspace us if (!is_superuser() && m_euid != peer->process().m_uid && m_uid != peer->process().m_uid) return -EPERM; - if (desired_param.sched_priority < THREAD_PRIORITY_MIN || - desired_param.sched_priority > THREAD_PRIORITY_MAX) + if (desired_param.sched_priority < THREAD_PRIORITY_MIN || desired_param.sched_priority > THREAD_PRIORITY_MAX) return -EINVAL; peer->set_priority((u32)desired_param.sched_priority); @@ -84,8 +83,11 @@ int Process::sys$sched_getparam(pid_t pid, Userspace user_p InterruptDisabler disabler; auto* peer = Thread::current(); - if (pid != 0) + if (pid != 0) { + // FIXME: PID/TID BUG + // The entire process is supposed to be affected. peer = Thread::from_tid(pid); + } if (!peer) return -ESRCH; @@ -93,12 +95,14 @@ int Process::sys$sched_getparam(pid_t pid, Userspace user_p if (!is_superuser() && m_euid != peer->process().m_uid && m_uid != peer->process().m_uid) return -EPERM; - struct sched_param param { (int) peer->priority() }; + struct sched_param param { + (int)peer->priority() + }; copy_to_user(user_param, ¶m); return 0; } -int Process::sys$set_thread_boost(int tid, int amount) +int Process::sys$set_thread_boost(pid_t tid, int amount) { REQUIRE_PROMISE(proc); if (amount < 0 || amount > 20) -- cgit v1.2.3