]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.51/ntp-allow-tai-utc-offset-to-be-set-to-zero.patch
Linux 4.19.51
[thirdparty/kernel/stable-queue.git] / releases / 4.19.51 / ntp-allow-tai-utc-offset-to-be-set-to-zero.patch
1 From 739b40673dfcca13b1cb658c9ef12c1d5cc2f99a 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 c5e0cba3b39c..6b23cd584295 100644
33 --- a/kernel/time/ntp.c
34 +++ b/kernel/time/ntp.c
35 @@ -698,7 +698,7 @@ static inline void process_adjtimex_modes(const struct timex *txc, s32 *time_tai
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