Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/kern Pull up following revision(s) (requested by nia ...



details:   https://anonhg.NetBSD.org/src/rev/afc95f16bffd
branches:  netbsd-9
changeset: 964176:afc95f16bffd
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Nov 01 17:26:01 2020 +0000

description:
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.

diffstat:

 sys/kern/kern_time.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r a8a45d22a479 -r afc95f16bffd sys/kern/kern_time.c
--- a/sys/kern/kern_time.c      Sun Nov 01 17:19:34 2020 +0000
+++ b/sys/kern/kern_time.c      Sun Nov 01 17:26:01 2020 +0000
@@ -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 @@
        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);



Home | Main Index | Thread Index | Old Index