Module Name: src Committed By: simonb Date: Sat Apr 3 12:57:21 UTC 2021
Modified Files: src/sys/compat/common: kern_time_50.c src/sys/kern: kern_time.c Log Message: Centralise the setitimer() timer type validation in dosetitimer() as is done with dogetitimer(). To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/compat/common/kern_time_50.c cvs rdiff -u -r1.210 -r1.211 src/sys/kern/kern_time.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/compat/common/kern_time_50.c diff -u src/sys/compat/common/kern_time_50.c:1.35 src/sys/compat/common/kern_time_50.c:1.36 --- src/sys/compat/common/kern_time_50.c:1.35 Thu Feb 27 16:41:59 2020 +++ src/sys/compat/common/kern_time_50.c Sat Apr 3 12:57:21 2021 @@ -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 @@ compat_50_sys_setitimer(struct lwp *l, 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) Index: src/sys/kern/kern_time.c diff -u src/sys/kern/kern_time.c:1.210 src/sys/kern/kern_time.c:1.211 --- src/sys/kern/kern_time.c:1.210 Tue Dec 8 04:09:38 2020 +++ src/sys/kern/kern_time.c Sat Apr 3 12:57:21 2021 @@ -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 @@ sys___setitimer50(struct lwp *l, const s 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 @@ dosetitimer(struct proc *p, int which, s 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);