Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/common Validate usec ranges in compat_50_sys_sele...



details:   https://anonhg.NetBSD.org/src/rev/13cbb1499d38
branches:  trunk
changeset: 454534:13cbb1499d38
user:      kamil <kamil%NetBSD.org@localhost>
date:      Fri Sep 20 15:05:22 2019 +0000

description:
Validate usec ranges in compat_50_sys_select()

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

diffstat:

 sys/compat/common/kern_select_50.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (29 lines):

diff -r 9aa3a3213bea -r 13cbb1499d38 sys/compat/common/kern_select_50.c
--- a/sys/compat/common/kern_select_50.c        Fri Sep 20 15:00:47 2019 +0000
+++ b/sys/compat/common/kern_select_50.c        Fri Sep 20 15:05:22 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_select_50.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $      */
+/*     $NetBSD: kern_select_50.c,v 1.3 2019/09/20 15:05:22 kamil Exp $ */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_select_50.c,v 1.2 2019/01/27 02:08:39 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_select_50.c,v 1.3 2019/09/20 15:05:22 kamil Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -114,6 +114,10 @@
                error = copyin(SCARG(uap, tv), (void *)&atv50, sizeof(atv50));
                if (error)
                        return error;
+
+               if (atv50.tv_usec < 0 || atv50.tv_usec >= 1000000)
+                       return EINVAL;
+
                ats.tv_sec = atv50.tv_sec;
                ats.tv_nsec = atv50.tv_usec * 1000;
                ts = &ats;



Home | Main Index | Thread Index | Old Index