diff --git a/sys/compat/linux/check_error.d b/sys/compat/linux/check_error.d index 9e3c00a..eeb18c9 100644 --- a/sys/compat/linux/check_error.d +++ b/sys/compat/linux/check_error.d @@ -43,7 +43,7 @@ linuxulator*:futex:futex_get:error, linuxulator*:futex:futex_sleep:requeue_error, linuxulator*:futex:futex_sleep:sleep_error, linuxulator*:futex:futex_wait:copyin_error, -linuxulator*:futex:futex_wait:itimerfix_error, +linuxulator*:futex:futex_wait:itimercheck_error, linuxulator*:futex:futex_wait:sleep_error, linuxulator*:futex:futex_atomic_op:missing_access_check, linuxulator*:futex:futex_atomic_op:unimplemented_op, diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c index c1531d0..9fabf2b 100644 --- a/sys/compat/linux/linux_futex.c +++ b/sys/compat/linux/linux_futex.c @@ -131,7 +131,7 @@ LIN_SDT_PROBE_DEFINE1(futex, futex_requeue, return, "int"); LIN_SDT_PROBE_DEFINE4(futex, futex_wait, entry, "struct futex *", "struct waiting_proc **", "struct l_timespec *", "uint32_t"); LIN_SDT_PROBE_DEFINE1(futex, futex_wait, copyin_error, "int"); -LIN_SDT_PROBE_DEFINE1(futex, futex_wait, itimerfix_error, "int"); +LIN_SDT_PROBE_DEFINE1(futex, futex_wait, itimercheck_error, "int"); LIN_SDT_PROBE_DEFINE1(futex, futex_wait, sleep_error, "int"); LIN_SDT_PROBE_DEFINE1(futex, futex_wait, return, "int"); LIN_SDT_PROBE_DEFINE3(futex, futex_atomic_op, entry, "struct thread *", @@ -580,9 +580,9 @@ futex_wait(struct futex *f, struct waiting_proc *wp, struct l_timespec *ts, return (error); } TIMESPEC_TO_TIMEVAL(&tv, &timeout); - error = itimerfix(&tv); + error = itimercheck(&tv); if (error) { - LIN_SDT_PROBE1(futex, futex_wait, itimerfix_error, + LIN_SDT_PROBE1(futex, futex_wait, itimercheck_error, error); LIN_SDT_PROBE1(futex, futex_wait, return, error); return (error); diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index ac2384c..987f3f8 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -504,7 +504,7 @@ linux_select(struct thread *td, struct linux_select_args *args) (intmax_t)utv.tv_sec, utv.tv_usec); #endif - if (itimerfix(&utv)) { + if (itimercheck(&utv)) { /* * The timeval was invalid. Convert it to something * valid that will act as it does under Linux. diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c index 1c778f9..d1c4a55 100644 --- a/sys/compat/linux/linux_signal.c +++ b/sys/compat/linux/linux_signal.c @@ -463,7 +463,7 @@ linux_rt_sigtimedwait(struct thread *td, #endif tv.tv_sec = (long)ltv.tv_sec; tv.tv_usec = (suseconds_t)ltv.tv_usec; - if (itimerfix(&tv)) { + if (itimercheck(&tv)) { /* * The timeout was invalid. Convert it to something * valid that will act as it does under Linux. diff --git a/sys/compat/linux/trace_futexes.d b/sys/compat/linux/trace_futexes.d index bd9dac6..08514c8 100644 --- a/sys/compat/linux/trace_futexes.d +++ b/sys/compat/linux/trace_futexes.d @@ -44,7 +44,7 @@ linuxulator*:futex:futex_get:error, linuxulator*:futex:futex_sleep:requeue_error, linuxulator*:futex:futex_sleep:sleep_error, linuxulator*:futex:futex_wait:copyin_error, -linuxulator*:futex:futex_wait:itimerfix_error, +linuxulator*:futex:futex_wait:itimercheck_error, linuxulator*:futex:futex_wait:sleep_error, linuxulator*:futex:futex_atomic_op:missing_access_check, linuxulator*:futex:futex_atomic_op:unimplemented_op, diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 3aaed60..f392d17 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -743,13 +743,11 @@ kern_setitimer(struct thread *td, u_int which, struct itimerval *aitv, if (which > ITIMER_PROF) return (EINVAL); - if (itimerfix(&aitv->it_value) || - aitv->it_value.tv_sec > INT32_MAX / 2) + if (itimercheck(&aitv->it_value)) return (EINVAL); if (!timevalisset(&aitv->it_value)) timevalclear(&aitv->it_interval); - else if (itimerfix(&aitv->it_interval) || - aitv->it_interval.tv_sec > INT32_MAX / 2) + else if (itimercheck(&aitv->it_interval)) return (EINVAL); if (which == ITIMER_REAL) { @@ -824,19 +822,15 @@ realitexpire(void *arg) /* * Check that a proposed value to load into the .it_value or - * .it_interval part of an interval timer is acceptable, and - * fix it to have at least minimal value (i.e. if it is less - * than the resolution of the clock, round it up.) + * .it_interval part of an interval timer is acceptable. */ int -itimerfix(struct timeval *tv) +itimercheck(struct timeval *tv) { - if (tv->tv_sec < 0 || tv->tv_usec < 0 || tv->tv_usec >= 1000000) + if (tv->tv_sec < 0 || tv->tv_sec > 100000000 || + tv->tv_usec < 0 || tv->tv_usec >= 1000000) return (EINVAL); - if (tv->tv_sec == 0 && tv->tv_usec != 0 && - tv->tv_usec < (u_int)tick / 16) - tv->tv_usec = (u_int)tick / 16; return (0); } diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index 7f9f881..e2ed22f 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -1957,12 +1957,9 @@ kern_aio_suspend(struct thread *td, int njoblist, struct aiocb **ujoblist, int error, i, timo; timo = 0; - if (ts) { - if (ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000) - return (EINVAL); - + if (ts != NULL) { TIMESPEC_TO_TIMEVAL(&atv, ts); - if (itimerfix(&atv)) + if (itimercheck(&atv)) return (EINVAL); timo = tvtohz(&atv); } @@ -2490,12 +2487,9 @@ kern_aio_waitcomplete(struct thread *td, struct aiocb **aiocbp, ops->store_aiocb(aiocbp, NULL); timo = 0; - if (ts) { - if ((ts->tv_nsec < 0) || (ts->tv_nsec >= 1000000000)) - return (EINVAL); - + if (ts != NULL) { TIMESPEC_TO_TIMEVAL(&atv, ts); - if (itimerfix(&atv)) + if (itimercheck(&atv)) return (EINVAL); timo = tvtohz(&atv); } diff --git a/sys/net/bpf.c b/sys/net/bpf.c index cb3ed27..21955ed 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1440,7 +1440,7 @@ bpfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, * Subtract 1 tick from tvtohz() since this isn't * a one-shot timer. */ - if ((error = itimerfix(tv)) == 0) + if ((error = itimercheck(tv)) == 0) d->bd_rtout = tvtohz(tv) - 1; break; } diff --git a/sys/sys/time.h b/sys/sys/time.h index 82a7db1..3ef0056 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -441,7 +441,7 @@ void getmicrotime(struct timeval *tvp); /* Other functions */ int itimerdecr(struct itimerval *itp, int usec); -int itimerfix(struct timeval *tv); +int itimercheck(struct timeval *tv); int ppsratecheck(struct timeval *, int *, int); int ratecheck(struct timeval *, const struct timeval *); void timevaladd(struct timeval *t1, const struct timeval *t2);