time, ntp: Do not update time_state in middle of leap second
PATCH 1/1 time, ntp: Do not update time_state in middle of leap second
During leap second insertion testing it was noticed that a small window exists where the time_state could be reset such that time_state = TIME_OK, which then causes the leap second to not occur, or causes the entire leap second state machine to fail.
While this is highly unlikely to ever happen in the real world it is still something we should protect against, as breaking the state machine is obviously bad.
If the time_state == TIME_OOP (ie, the leap second is in progress) do not allow an external update to time_state.
Signed-off-by Prarit Bhargava <[email protected]>
--- kernel/time/ntp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/time/ntp.c +2 -1
@@ -534,7 +534,8 @@ void ntp_notify_cmos_timer(void) { }*/ static inline void process_adj_status (struct timex *txc,struct timespec64 *ts) { -if ((time_status &STA_PLL ) && !(txc->status &STA_PLL )) { +if ((time_status &STA_PLL ) && !(txc->status &STA_PLL ) && + (time_state !=TIME_OOP )) { time_state =TIME_OK ; time_status =STA_UNSYNC ;/* restart PPS frequency calibration */
Signature · 1 line
1.7.9.3