]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.9/ntp-allow-tai-utc-offset-to-be-set-to-zero.patch
fixes for 4.9
[thirdparty/kernel/stable-queue.git] / queue-4.9 / ntp-allow-tai-utc-offset-to-be-set-to-zero.patch
1 From 9681e8461eba5a60a058737a6ea19a46a95dc42a Mon Sep 17 00:00:00 2001
2 From: Miroslav Lichvar <mlichvar@redhat.com>
3 Date: Wed, 17 Apr 2019 10:48:33 +0200
4 Subject: ntp: Allow TAI-UTC offset to be set to zero
5
6 [ Upstream commit fdc6bae940ee9eb869e493990540098b8c0fd6ab ]
7
8 The ADJ_TAI adjtimex mode sets the TAI-UTC offset of the system clock.
9 It is typically set by NTP/PTP implementations and it is automatically
10 updated by the kernel on leap seconds. The initial value is zero (which
11 applications may interpret as unknown), but this value cannot be set by
12 adjtimex. This limitation seems to go back to the original "nanokernel"
13 implementation by David Mills.
14
15 Change the ADJ_TAI check to accept zero as a valid TAI-UTC offset in
16 order to allow setting it back to the initial value.
17
18 Fixes: 153b5d054ac2 ("ntp: support for TAI")
19 Suggested-by: Ondrej Mosnacek <omosnace@redhat.com>
20 Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
21 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
22 Cc: John Stultz <john.stultz@linaro.org>
23 Cc: Richard Cochran <richardcochran@gmail.com>
24 Cc: Prarit Bhargava <prarit@redhat.com>
25 Link: https://lkml.kernel.org/r/20190417084833.7401-1-mlichvar@redhat.com
26 Signed-off-by: Sasha Levin <sashal@kernel.org>
27 ---
28 kernel/time/ntp.c | 2 +-
29 1 file changed, 1 insertion(+), 1 deletion(-)
30
31 diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
32 index 6df8927c58a5..0a16419006f3 100644
33 --- a/kernel/time/ntp.c
34 +++ b/kernel/time/ntp.c
35 @@ -639,7 +639,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 --
45 2.20.1
46