diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2021-04-26 17:22:04 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-27 09:19:55 +0200 |
commit | b630e39fbb705b145fd940e85b491287d69de6b9 (patch) | |
tree | c1695fe2df6c80774fa65f839c6d59e1e0a38ada /Kernel | |
parent | c3cff7d70a27e93c2006cbe78f3c2d00da7a44a2 (diff) | |
download | serenity-b630e39fbb705b145fd940e85b491287d69de6b9.zip |
Kernel: Check futex command if realtime clock is used
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Syscalls/futex.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Kernel/Syscalls/futex.cpp b/Kernel/Syscalls/futex.cpp index 89a801d073..33efb138fa 100644 --- a/Kernel/Syscalls/futex.cpp +++ b/Kernel/Syscalls/futex.cpp @@ -90,6 +90,12 @@ KResultOr<int> Process::sys$futex(Userspace<const Syscall::SC_futex_params*> use Thread::BlockTimeout timeout; u32 cmd = params.futex_op & FUTEX_CMD_MASK; + + bool use_realtime_clock = (params.futex_op & FUTEX_CLOCK_REALTIME) != 0; + if (use_realtime_clock && cmd != FUTEX_WAIT && cmd != FUTEX_WAIT_BITSET) { + return ENOSYS; + } + switch (cmd) { case FUTEX_WAIT: case FUTEX_WAIT_BITSET: @@ -99,8 +105,8 @@ KResultOr<int> Process::sys$futex(Userspace<const Syscall::SC_futex_params*> use auto timeout_time = copy_time_from_user(params.timeout); if (!timeout_time.has_value()) return EFAULT; - clockid_t clock_id = (params.futex_op & FUTEX_CLOCK_REALTIME) ? CLOCK_REALTIME_COARSE : CLOCK_MONOTONIC_COARSE; bool is_absolute = cmd != FUTEX_WAIT; + clockid_t clock_id = use_realtime_clock ? CLOCK_REALTIME_COARSE : CLOCK_MONOTONIC_COARSE; timeout = Thread::BlockTimeout(is_absolute, &timeout_time.value(), nullptr, clock_id); } if (cmd == FUTEX_WAIT_BITSET && params.val3 == FUTEX_BITSET_MATCH_ANY) |