From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932103AbbBGS3z (ORCPT ); Sat, 7 Feb 2015 13:29:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60839 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756804AbbBGS3x (ORCPT ); Sat, 7 Feb 2015 13:29:53 -0500 From: Prarit Bhargava To: linux-kernel@vger.kernel.org Cc: Prarit Bhargava , John Stultz , Thomas Gleixner , Miroslav Lichvar Subject: [PATCH] time, ntp: Do not update time_state in middle of leap second Date: Sat, 7 Feb 2015 13:29:39 -0500 Message-Id: <1423333779-9857-1-git-send-email-prarit@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. [v2]: Only block time_state change when TIME_OOP Signed-off-by: Prarit Bhargava Cc: John Stultz Cc: Thomas Gleixner Cc: Miroslav Lichvar --- kernel/time/ntp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 28bf91c..6ff5cd5 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -535,7 +535,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)) { - time_state = TIME_OK; + if (time_state != TIME_OOP) + time_state = TIME_OK; time_status = STA_UNSYNC; /* restart PPS frequency calibration */ pps_reset_freq_interval(); -- 1.7.9.3