From 0af367548757726d67de7a1b6ac739e59aaaa1d7 Mon Sep 17 00:00:00 2001 From: kamil Date: Fri, 20 Sep 2019 15:00:47 +0000 Subject: [PATCH] Validate usec ranges in sys___select50() Later in the code selcommon() checks for proper timespec, check only correct usec of timeval before type conversions. --- sys/kern/sys_select.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/kern/sys_select.c b/sys/kern/sys_select.c index c5e69141d1af..b1f0b6a6969f 100644 --- a/sys/kern/sys_select.c +++ b/sys/kern/sys_select.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_select.c,v 1.47 2019/08/20 01:56:21 msaitoh Exp $ */ +/* $NetBSD: sys_select.c,v 1.48 2019/09/20 15:00:47 kamil Exp $ */ /*- * Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc. @@ -84,7 +84,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.47 2019/08/20 01:56:21 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.48 2019/09/20 15:00:47 kamil Exp $"); #include #include @@ -205,6 +205,10 @@ sys___select50(struct lwp *l, const struct sys___select50_args *uap, error = copyin(SCARG(uap, tv), (void *)&atv, sizeof(atv)); if (error) return error; + + if (atv.tv_usec < 0 || atv.tv_usec >= 1000000) + return EINVAL; + TIMEVAL_TO_TIMESPEC(&atv, &ats); ts = &ats; }