Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern kern: Handle clock winding back in nanosleep1 witho...
details: https://anonhg.NetBSD.org/src/rev/f445e820ad51
branches: trunk
changeset: 363474:f445e820ad51
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Mar 13 12:21:28 2022 +0000
description:
kern: Handle clock winding back in nanosleep1 without overflow.
Reported-by: syzbot+3bdd260582424a611946%syzkaller.appspotmail.com@localhost
diffstat:
sys/kern/kern_time.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diffs (35 lines):
diff -r eae7618824f2 -r f445e820ad51 sys/kern/kern_time.c
--- a/sys/kern/kern_time.c Sun Mar 13 11:35:47 2022 +0000
+++ b/sys/kern/kern_time.c Sun Mar 13 12:21:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_time.c,v 1.212 2022/03/12 16:46:57 riastradh Exp $ */
+/* $NetBSD: kern_time.c,v 1.213 2022/03/13 12:21:28 riastradh 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.212 2022/03/12 16:46:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.213 2022/03/13 12:21:28 riastradh Exp $");
#include <sys/param.h>
#include <sys/resourcevar.h>
@@ -435,8 +435,14 @@
if (flags & TIMER_ABSTIME) {
timespecsub(rqt, &rmtend, t);
} else {
- timespecsub(&rmtend, &rmtstart, t);
- timespecsub(rqt, t, t);
+ if (timespeccmp(&rmtend, &rmtstart, <))
+ timespecclear(t); /* clock wound back */
+ else
+ timespecsub(&rmtend, &rmtstart, t);
+ if (timespeccmp(rqt, t, <))
+ timespecclear(t);
+ else
+ timespecsub(rqt, t, t);
}
if (t->tv_sec < 0)
timespecclear(t);
Home |
Main Index |
Thread Index |
Old Index