summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorAndy Fiddaman <omnios@citrus-it.co.uk>2021-11-24 14:28:46 +0000
committerAndy Fiddaman <omnios@citrus-it.co.uk>2021-12-06 16:50:59 +0000
commitea3cb02b50effb9ec1ecee7e7178c14143cd2485 (patch)
treee815478db32ddf98e1987f97f3d9d44b9b00ce94 /usr/src
parent6ba75e2448bdf3ae62cf3d6d13895172a2b7a249 (diff)
downloadillumos-gate-ea3cb02b50effb9ec1ecee7e7178c14143cd2485.tar.gz
14262 ntp_adjtime() should only validate constant with MOD_TIMECONST
Reviewed by: Rich Lowe <richlowe@richlowe.net> Reviewed by: Jason King <jason.brian.king+illumos@gmail.com> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/common/syscall/ntptime.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/usr/src/uts/common/syscall/ntptime.c b/usr/src/uts/common/syscall/ntptime.c
index 631277ab41..963e7ddfbf 100644
--- a/usr/src/uts/common/syscall/ntptime.c
+++ b/usr/src/uts/common/syscall/ntptime.c
@@ -17,7 +17,9 @@
* purpose. It is provided "as is" without express or implied warranty.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
+ */
/*
* Modification history kern_ntptime.c
@@ -116,7 +118,7 @@ ntp_gettime(struct ntptimeval *tp)
* synchronization requested
*/
(time_status & (STA_PPSFREQ | STA_PPSTIME) &&
- !(time_status & STA_PPSSIGNAL)) ||
+ !(time_status & STA_PPSSIGNAL)) ||
/*
* PPS jitter exceeded when time synchronization
@@ -128,9 +130,10 @@ ntp_gettime(struct ntptimeval *tp)
* PPS wander exceeded or calibration error when
* frequency synchronization requested
*/
- (time_status & STA_PPSFREQ && time_status &
- (STA_PPSWANDER | STA_PPSERROR)))
+ (time_status & STA_PPSFREQ &&
+ time_status & (STA_PPSWANDER | STA_PPSERROR))) {
return (TIME_ERROR);
+ }
return (time_state);
}
@@ -157,7 +160,11 @@ ntp_adjtime(struct timex *tp)
if (modes != 0 && secpolicy_settime(CRED()) != 0)
return (set_errno(EPERM));
- if (ntv.constant < 0 || ntv.constant > 30)
+ /*
+ * If the time constant is being set, validate it first so that
+ * no changes are made if it is out of range.
+ */
+ if ((modes & MOD_TIMECONST) && (ntv.constant < 0 || ntv.constant > 30))
return (set_errno(EINVAL));
mutex_enter(&tod_lock);
@@ -173,6 +180,10 @@ ntp_adjtime(struct timex *tp)
time_constant = ntv.constant;
if (modes & MOD_OFFSET)
clock_update(ntv.offset);
+ /*
+ * clock_update() updates time_freq so keep MOD_FREQUENCY after
+ * MOD_OFFSET.
+ */
if (modes & MOD_FREQUENCY)
time_freq = ntv.freq - pps_freq;
/*