]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-4.14/ntp-allow-tai-utc-offset-to-be-set-to-zero.patch
Merge branch 'master' of gitolite.kernel.org:/pub/scm/linux/kernel/git/stable/stable...
[thirdparty/kernel/stable-queue.git] / queue-4.14 / ntp-allow-tai-utc-offset-to-be-set-to-zero.patch
CommitLineData
6e4ffbcf
SL
1From d083639da32af03050e6c28a0f4212b89c038cef Mon Sep 17 00:00:00 2001
2From: Miroslav Lichvar <mlichvar@redhat.com>
3Date: Wed, 17 Apr 2019 10:48:33 +0200
4Subject: ntp: Allow TAI-UTC offset to be set to zero
5
6[ Upstream commit fdc6bae940ee9eb869e493990540098b8c0fd6ab ]
7
8The ADJ_TAI adjtimex mode sets the TAI-UTC offset of the system clock.
9It is typically set by NTP/PTP implementations and it is automatically
10updated by the kernel on leap seconds. The initial value is zero (which
11applications may interpret as unknown), but this value cannot be set by
12adjtimex. This limitation seems to go back to the original "nanokernel"
13implementation by David Mills.
14
15Change the ADJ_TAI check to accept zero as a valid TAI-UTC offset in
16order to allow setting it back to the initial value.
17
18Fixes: 153b5d054ac2 ("ntp: support for TAI")
19Suggested-by: Ondrej Mosnacek <omosnace@redhat.com>
20Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
21Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
22Cc: John Stultz <john.stultz@linaro.org>
23Cc: Richard Cochran <richardcochran@gmail.com>
24Cc: Prarit Bhargava <prarit@redhat.com>
25Link: https://lkml.kernel.org/r/20190417084833.7401-1-mlichvar@redhat.com
26Signed-off-by: Sasha Levin <sashal@kernel.org>
27---
28 kernel/time/ntp.c | 2 +-
29 1 file changed, 1 insertion(+), 1 deletion(-)
30
31diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
32index 99e03bec68e4..4bb9b66338be 100644
33--- a/kernel/time/ntp.c
34+++ b/kernel/time/ntp.c
35@@ -640,7 +640,7 @@ static inline void process_adjtimex_modes(struct timex *txc,
36 time_constant = max(time_constant, 0l);
37 }
38
39- if (txc->modes & ADJ_TAI && txc->constant > 0)
40+ if (txc->modes & ADJ_TAI && txc->constant >= 0)
41 *time_tai = txc->constant;
42
43 if (txc->modes & ADJ_OFFSET)
44--
452.20.1
46