mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
Kernel: Sanitize all user-supplied timeval's/timespec's
This also removes a bunch of unnecessary EINVAL. Most of them weren't even recommended by POSIX.
This commit is contained in:
parent
649abc01bc
commit
8598240193
4 changed files with 42 additions and 28 deletions
|
@ -45,9 +45,11 @@ KResultOr<int> Process::sys$select(Userspace<const Syscall::SC_select_params*> u
|
|||
|
||||
Thread::BlockTimeout timeout;
|
||||
if (params.timeout) {
|
||||
timespec timeout_copy;
|
||||
if (!copy_from_user(&timeout_copy, params.timeout))
|
||||
Optional<Time> timeout_time = copy_time_from_user(params.timeout);
|
||||
if (!timeout_time.has_value())
|
||||
return EFAULT;
|
||||
auto timeout_copy = timeout_time->to_timespec();
|
||||
// FIXME: Should use AK::Time internally
|
||||
timeout = Thread::BlockTimeout(false, &timeout_copy);
|
||||
}
|
||||
|
||||
|
@ -142,7 +144,6 @@ KResultOr<int> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_
|
|||
{
|
||||
REQUIRE_PROMISE(stdio);
|
||||
|
||||
// FIXME: Return -EINVAL if timeout is invalid.
|
||||
Syscall::SC_poll_params params;
|
||||
if (!copy_from_user(¶ms, user_params))
|
||||
return EFAULT;
|
||||
|
@ -152,9 +153,11 @@ KResultOr<int> Process::sys$poll(Userspace<const Syscall::SC_poll_params*> user_
|
|||
|
||||
Thread::BlockTimeout timeout;
|
||||
if (params.timeout) {
|
||||
timespec timeout_copy;
|
||||
if (!copy_from_user(&timeout_copy, params.timeout))
|
||||
auto timeout_time = copy_time_from_user(params.timeout);
|
||||
if (!timeout_time.has_value())
|
||||
return EFAULT;
|
||||
timespec timeout_copy = timeout_time->to_timespec();
|
||||
// FIXME: Should use AK::Time internally
|
||||
timeout = Thread::BlockTimeout(false, &timeout_copy);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue