From: Matthew Dillon Date: Mon, 15 Jan 2007 19:08:10 +0000 (+0000) Subject: cputimer_intr_reload() - prevent a negatively indexed or too-small a reload X-Git-Tag: v2.0.1~3676 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/307ae84dfc892ef0e7d9caebcb1f73831c21bb5c cputimer_intr_reload() - prevent a negatively indexed or too-small a reload value from loading the kqueue timer with an illegal value. --- diff --git a/sys/platform/vkernel/platform/kqueue.c b/sys/platform/vkernel/platform/kqueue.c index f753ab8727..f145c1fef2 100644 --- a/sys/platform/vkernel/platform/kqueue.c +++ b/sys/platform/vkernel/platform/kqueue.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/platform/vkernel/platform/kqueue.c,v 1.2 2007/01/15 05:27:31 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/platform/kqueue.c,v 1.3 2007/01/15 19:08:10 dillon Exp $ */ #include @@ -166,6 +166,8 @@ kqueue_reload_timer(struct kqueue_info *info, int ms) struct timespec ts = { 0, 0 }; struct kevent kev; + KKASSERT(ms > 0); + EV_SET(&kev, info->fd, EVFILT_TIMER, EV_ADD|EV_ENABLE|EV_ONESHOT|EV_CLEAR, 0, (uintptr_t)ms, info); if (kevent(KQueueFd, &kev, 1, NULL, 0, &ts) < 0) diff --git a/sys/platform/vkernel/platform/systimer.c b/sys/platform/vkernel/platform/systimer.c index 87c51122e2..73ccbfba44 100644 --- a/sys/platform/vkernel/platform/systimer.c +++ b/sys/platform/vkernel/platform/systimer.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/platform/vkernel/platform/systimer.c,v 1.10 2007/01/15 05:27:31 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/platform/systimer.c,v 1.11 2007/01/15 19:08:10 dillon Exp $ */ #include @@ -135,13 +135,18 @@ cputimer_intr_config(struct cputimer *timer) } /* - * Reload the interrupt for our core systimer. + * Reload the interrupt for our core systimer. Because the caller's + * reload calculation can be negatively indexed, we need a minimal + * check to ensure that a reasonable reload value is selected. */ void cputimer_intr_reload(sysclock_t reload) { - if (kqueue_timer_info) + if (kqueue_timer_info) { + if ((int)reload < 1) + reload = 1; kqueue_reload_timer(kqueue_timer_info, (reload + 999) / 1000); + } } /*