Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Centralise the setitimer() timer type validation in...



details:   https://anonhg.NetBSD.org/src/rev/ace7f75aeec8
branches:  trunk
changeset: 982168:ace7f75aeec8
user:      simonb <simonb%NetBSD.org@localhost>
date:      Sat Apr 03 12:57:21 2021 +0000

description:
Centralise the setitimer() timer type validation in dosetitimer() as is
done with dogetitimer().

diffstat:

 sys/compat/common/kern_time_50.c |  6 ++----
 sys/kern/kern_time.c             |  9 ++++-----
 2 files changed, 6 insertions(+), 9 deletions(-)

diffs (64 lines):

diff -r 647829991fc4 -r ace7f75aeec8 sys/compat/common/kern_time_50.c
--- a/sys/compat/common/kern_time_50.c  Sat Apr 03 12:06:53 2021 +0000
+++ b/sys/compat/common/kern_time_50.c  Sat Apr 03 12:57:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_time_50.c,v 1.35 2020/02/27 16:41:59 pgoyette Exp $       */
+/*     $NetBSD: kern_time_50.c,v 1.36 2021/04/03 12:57:21 simonb 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_time_50.c,v 1.35 2020/02/27 16:41:59 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time_50.c,v 1.36 2021/04/03 12:57:21 simonb Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -324,8 +324,6 @@
        struct itimerval aitv;
        int error;
 
-       if ((u_int)which > ITIMER_PROF)
-               return (EINVAL);
        itvp = SCARG(uap, itv);
        if (itvp &&
            (error = copyin(itvp, &aitv50, sizeof(aitv50))) != 0)
diff -r 647829991fc4 -r ace7f75aeec8 sys/kern/kern_time.c
--- a/sys/kern/kern_time.c      Sat Apr 03 12:06:53 2021 +0000
+++ b/sys/kern/kern_time.c      Sat Apr 03 12:57:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_time.c,v 1.210 2020/12/08 04:09:38 thorpej Exp $  */
+/*     $NetBSD: kern_time.c,v 1.211 2021/04/03 12:57:21 simonb Exp $   */
 
 /*-
  * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009, 2020
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.210 2020/12/08 04:09:38 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.211 2021/04/03 12:57:21 simonb Exp $");
 
 #include <sys/param.h>
 #include <sys/resourcevar.h>
@@ -1576,8 +1576,6 @@
        struct itimerval aitv;
        int error;
 
-       if ((u_int)which > ITIMER_MONOTONIC)
-               return (EINVAL);
        itvp = SCARG(uap, itv);
        if (itvp &&
            (error = copyin(itvp, &aitv, sizeof(struct itimerval))) != 0)
@@ -1604,7 +1602,8 @@
        struct itlist *itl;
        int error;
 
-       KASSERT((u_int)which <= CLOCK_MONOTONIC);
+       if ((u_int)which > ITIMER_MONOTONIC)
+               return (EINVAL);
        if (itimerfix(&itvp->it_value) || itimerfix(&itvp->it_interval))
                return (EINVAL);
 



Home | Main Index | Thread Index | Old Index