Module Name: src Committed By: martin Date: Sun Nov 1 17:26:01 UTC 2020
Modified Files: src/sys/kern [netbsd-9]: kern_time.c Log Message: Pull up following revision(s) (requested by nia in ticket #1124): sys/kern/kern_time.c: revision 1.206 kern_time: prevent the system clock from being set too low or high currently doing this will drive KUBSAN haywire and possibly cause system lock-ups, so more testing should probably be performed before we let the clock be set too many thousands of years into the future. ditto for negative values, which were being passed by chrony for some reason while my internet connection was being unreliable. this also triggered some interesting KUBSAN reports. To generate a diff of this commit: cvs rdiff -u -r1.197.4.3 -r1.197.4.4 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/kern/kern_time.c diff -u src/sys/kern/kern_time.c:1.197.4.3 src/sys/kern/kern_time.c:1.197.4.4 --- src/sys/kern/kern_time.c:1.197.4.3 Mon May 18 19:05:32 2020 +++ src/sys/kern/kern_time.c Sun Nov 1 17:26:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_time.c,v 1.197.4.3 2020/05/18 19:05:32 martin Exp $ */ +/* $NetBSD: kern_time.c,v 1.197.4.4 2020/11/01 17:26:01 martin Exp $ */ /*- * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.197.4.3 2020/05/18 19:05:32 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.197.4.4 2020/11/01 17:26:01 martin Exp $"); #include <sys/param.h> #include <sys/resourcevar.h> @@ -138,6 +138,13 @@ settime1(struct proc *p, const struct ti struct timespec delta, now; int s; + /* + * The time being set to an unreasonable value will cause + * unreasonable system behaviour. + */ + if (ts->tv_sec < 0 || ts->tv_sec > (1LL << 36)) + return (EINVAL); + /* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */ s = splclock(); nanotime(&now);