* [PATCH] ntp: Limit TAI-UTC offset
@ 2019-06-18 15:47 Miroslav Lichvar
2019-06-22 9:34 ` [tip:timers/core] " tip-bot for Miroslav Lichvar
0 siblings, 1 reply; 2+ messages in thread
From: Miroslav Lichvar @ 2019-06-18 15:47 UTC (permalink / raw)
To: linux-kernel
Cc: swkhack, Miroslav Lichvar, John Stultz, Prarit Bhargava,
Richard Cochran, Stephen Boyd, Thomas Gleixner
Don't allow the TAI-UTC offset of the system clock to be set by
adjtimex() to a value larger than 100000 seconds.
This prevents an overflow in the conversion to int, prevents the
CLOCK_TAI clock from getting too far ahead of the CLOCK_REALTIME clock,
and it is still large enough to allow leap seconds to be inserted at the
maximum rate currently supported by the kernel (once per day) for the
next ~270 years, however unlikely it is that someone can survive a
catastrophic event which slowed down the rotation of the Earth so much.
Cc: John Stultz <john.stultz@linaro.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
---
kernel/time/ntp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 8de4f789dc1b..65eb796610dc 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -43,6 +43,7 @@ static u64 tick_length_base;
#define MAX_TICKADJ 500LL /* usecs */
#define MAX_TICKADJ_SCALED \
(((MAX_TICKADJ * NSEC_PER_USEC) << NTP_SCALE_SHIFT) / NTP_INTERVAL_FREQ)
+#define MAX_TAI_OFFSET 100000
/*
* phase-lock loop variables
@@ -691,7 +692,8 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
time_constant = max(time_constant, 0l);
}
- if (txc->modes & ADJ_TAI && txc->constant >= 0)
+ if (txc->modes & ADJ_TAI &&
+ txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET)
*time_tai = txc->constant;
if (txc->modes & ADJ_OFFSET)
--
2.17.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip:timers/core] ntp: Limit TAI-UTC offset
2019-06-18 15:47 [PATCH] ntp: Limit TAI-UTC offset Miroslav Lichvar
@ 2019-06-22 9:34 ` tip-bot for Miroslav Lichvar
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Miroslav Lichvar @ 2019-06-22 9:34 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, tglx, prarit, mlichvar, richardcochran, mingo, hpa,
sboyd, john.stultz, swkhack
Commit-ID: d897a4ab11dc8a9fda50d2eccc081a96a6385998
Gitweb: https://git.kernel.org/tip/d897a4ab11dc8a9fda50d2eccc081a96a6385998
Author: Miroslav Lichvar <mlichvar@redhat.com>
AuthorDate: Tue, 18 Jun 2019 17:47:13 +0200
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 22 Jun 2019 11:28:53 +0200
ntp: Limit TAI-UTC offset
Don't allow the TAI-UTC offset of the system clock to be set by adjtimex()
to a value larger than 100000 seconds.
This prevents an overflow in the conversion to int, prevents the CLOCK_TAI
clock from getting too far ahead of the CLOCK_REALTIME clock, and it is
still large enough to allow leap seconds to be inserted at the maximum rate
currently supported by the kernel (once per day) for the next ~270 years,
however unlikely it is that someone can survive a catastrophic event which
slowed down the rotation of the Earth so much.
Reported-by: Weikang shi <swkhack@gmail.com>
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Link: https://lkml.kernel.org/r/20190618154713.20929-1-mlichvar@redhat.com
---
kernel/time/ntp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 8de4f789dc1b..65eb796610dc 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -43,6 +43,7 @@ static u64 tick_length_base;
#define MAX_TICKADJ 500LL /* usecs */
#define MAX_TICKADJ_SCALED \
(((MAX_TICKADJ * NSEC_PER_USEC) << NTP_SCALE_SHIFT) / NTP_INTERVAL_FREQ)
+#define MAX_TAI_OFFSET 100000
/*
* phase-lock loop variables
@@ -691,7 +692,8 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
time_constant = max(time_constant, 0l);
}
- if (txc->modes & ADJ_TAI && txc->constant >= 0)
+ if (txc->modes & ADJ_TAI &&
+ txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET)
*time_tai = txc->constant;
if (txc->modes & ADJ_OFFSET)
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-22 9:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-18 15:47 [PATCH] ntp: Limit TAI-UTC offset Miroslav Lichvar
2019-06-22 9:34 ` [tip:timers/core] " tip-bot for Miroslav Lichvar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).