Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern ntp(9): Clamp ntv->offset to avoid arithmetic overf...
details: https://anonhg.NetBSD.org/src/rev/be13e56854e0
branches: trunk
changeset: 363475:be13e56854e0
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Mar 13 12:30:47 2022 +0000
description:
ntp(9): Clamp ntv->offset to avoid arithmetic overflow on adjtime.
Reported-by: syzbot+b8406db60db88650652e%syzkaller.appspotmail.com@localhost
diffstat:
sys/kern/kern_ntptime.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diffs (36 lines):
diff -r f445e820ad51 -r be13e56854e0 sys/kern/kern_ntptime.c
--- a/sys/kern/kern_ntptime.c Sun Mar 13 12:21:28 2022 +0000
+++ b/sys/kern/kern_ntptime.c Sun Mar 13 12:30:47 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_ntptime.c,v 1.61 2022/02/05 15:29:50 riastradh Exp $ */
+/* $NetBSD: kern_ntptime.c,v 1.62 2022/03/13 12:30:47 riastradh Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
#include <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/sys/kern/kern_ntptime.c,v 1.59 2005/05/28 14:34:41 rwatson Exp $"); */
-__KERNEL_RCSID(0, "$NetBSD: kern_ntptime.c,v 1.61 2022/02/05 15:29:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ntptime.c,v 1.62 2022/03/13 12:30:47 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ntp.h"
@@ -365,10 +365,14 @@
#endif /* PPS_SYNC */
}
if (modes & MOD_OFFSET) {
- if (time_status & STA_NANO)
+ if (time_status & STA_NANO) {
hardupdate(ntv->offset);
- else
- hardupdate(ntv->offset * 1000);
+ } else {
+ long offset = ntv->offset;
+ offset = MIN(offset, MAXPHASE/1000);
+ offset = MAX(offset, -MAXPHASE/1000);
+ hardupdate(offset * 1000);
+ }
}
/*
Home |
Main Index |
Thread Index |
Old Index