Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ntp: Fix RTC synchronization on 32-bit platforms

Due to an integer overflow, RTC synchronization now happens every 2s
instead of the intended 11 minutes. Fix this by forcing 64-bit
arithmetic for the sync period calculation.

Annotate the other place which multiplies seconds for consistency as well.

Fixes: c9e6189fb03123a7 ("ntp: Make the RTC synchronization more reliable")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20210111103956.290378-1-geert+renesas@glider.be

authored by

Geert Uytterhoeven and committed by
Thomas Gleixner
e3fab2f3 aba428a0

+2 -2
+2 -2
kernel/time/ntp.c
··· 498 498 static void sync_hw_clock(struct work_struct *work); 499 499 static DECLARE_WORK(sync_work, sync_hw_clock); 500 500 static struct hrtimer sync_hrtimer; 501 - #define SYNC_PERIOD_NS (11UL * 60 * NSEC_PER_SEC) 501 + #define SYNC_PERIOD_NS (11ULL * 60 * NSEC_PER_SEC) 502 502 503 503 static enum hrtimer_restart sync_timer_callback(struct hrtimer *timer) 504 504 { ··· 512 512 ktime_t exp = ktime_set(ktime_get_real_seconds(), 0); 513 513 514 514 if (retry) 515 - exp = ktime_add_ns(exp, 2 * NSEC_PER_SEC - offset_nsec); 515 + exp = ktime_add_ns(exp, 2ULL * NSEC_PER_SEC - offset_nsec); 516 516 else 517 517 exp = ktime_add_ns(exp, SYNC_PERIOD_NS - offset_nsec); 518 518