#endif /* CONFIG_LIBPOSIX_FDTAB */
+/**
+ * Return non-zero if `val` contains either negative or non-canonical times.
+ */
+static inline
+int timerfd_check_settime(const struct itimerspec *val)
+{
+ return !uk_time_spec_canonical(&val->it_value) ||
+ !uk_time_spec_canonical(&val->it_interval) ||
+ !uk_time_spec_positive(&val->it_value) ||
+ !uk_time_spec_positive(&val->it_interval);
+}
+
int uk_sys_timerfd_settime(const struct uk_file *f, int flags,
const struct itimerspec *new_value,
struct itimerspec *old_value)
return -EINVAL;
if (unlikely(f->vol != TIMERFD_VOLID))
return -EINVAL;
+ if (unlikely(timerfd_check_settime(new_value)))
+ return -EINVAL;
d = f->node;
uk_file_wlock(f);