Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Validate usec ranges in sys___select50()



details:   https://anonhg.NetBSD.org/src/rev/116e275bd38f
branches:  trunk
changeset: 965522:116e275bd38f
user:      kamil <kamil%NetBSD.org@localhost>
date:      Fri Sep 20 15:00:47 2019 +0000

description:
Validate usec ranges in sys___select50()

Later in the code selcommon() checks for proper timespec, check only
correct usec of timeval before type conversions.

diffstat:

 sys/kern/sys_select.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (29 lines):

diff -r 0bd89a52fd98 -r 116e275bd38f sys/kern/sys_select.c
--- a/sys/kern/sys_select.c     Fri Sep 20 14:53:24 2019 +0000
+++ b/sys/kern/sys_select.c     Fri Sep 20 15:00:47 2019 +0000
@@ -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 <sys/cdefs.h>
-__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 <sys/param.h>
 #include <sys/systm.h>
@@ -205,6 +205,10 @@
                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;
        }



Home | Main Index | Thread Index | Old Index