Add check to ensure that the timeout value passed to rt_sigtimedwait()
is canonical.
Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Sergiu Moga <sergiu@unikraft.io>
GitHub-Closes: #1639
if ((sig = pprocess_signal_next_pending_t(pthread)))
goto out;
- if (timeout)
+ if (timeout) {
+ if (unlikely(!(uk_time_spec_canonical(timeout) &&
+ uk_time_spec_positive(timeout))))
+ return -EINVAL;
uk_semaphore_down_to(&pthread->signal->pending_semaphore,
uk_time_spec_to_nsec(timeout));
- else
+ } else {
uk_semaphore_down(&pthread->signal->pending_semaphore);
+ }
if ((sig = pprocess_signal_next_pending_t(pthread)))
goto out;