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.

Merge tag 'timers-urgent-2024-08-11' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull time keeping fixes from Thomas Gleixner:

- Fix a couple of issues in the NTP code where user supplied values are
neither sanity checked nor clamped to the operating range. This
results in integer overflows and eventualy NTP getting out of sync.

According to the history the sanity checks had been removed in favor
of clamping the values, but the clamping never worked correctly under
all circumstances. The NTP people asked to not bring the sanity
checks back as it might break existing applications.

Make the clamping work correctly and add it where it's missing

- If adjtimex() sets the clock it has to trigger the hrtimer subsystem
so it can adjust and if the clock was set into the future expire
timers if needed. The caller should provide a bitmask to tell
hrtimers which clocks have been adjusted.

adjtimex() uses not the proper constant and uses CLOCK_REALTIME
instead, which is 0. So hrtimers adjusts only the clocks, but does
not check for expired timers, which might make them expire really
late. Use the proper bitmask constant instead.

* tag 'timers-urgent-2024-08-11' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
timekeeping: Fix bogus clock_was_set() invocation in do_adjtimex()
ntp: Safeguard against time_constant overflow
ntp: Clamp maxerror and esterror to operating range

+5 -6
+4 -5
kernel/time/ntp.c
··· 727 727 } 728 728 729 729 if (txc->modes & ADJ_MAXERROR) 730 - time_maxerror = txc->maxerror; 730 + time_maxerror = clamp(txc->maxerror, 0, NTP_PHASE_LIMIT); 731 731 732 732 if (txc->modes & ADJ_ESTERROR) 733 - time_esterror = txc->esterror; 733 + time_esterror = clamp(txc->esterror, 0, NTP_PHASE_LIMIT); 734 734 735 735 if (txc->modes & ADJ_TIMECONST) { 736 - time_constant = txc->constant; 736 + time_constant = clamp(txc->constant, 0, MAXTC); 737 737 if (!(time_status & STA_NANO)) 738 738 time_constant += 4; 739 - time_constant = min(time_constant, (long)MAXTC); 740 - time_constant = max(time_constant, 0l); 739 + time_constant = clamp(time_constant, 0, MAXTC); 741 740 } 742 741 743 742 if (txc->modes & ADJ_TAI &&
+1 -1
kernel/time/timekeeping.c
··· 2606 2606 clock_set |= timekeeping_advance(TK_ADV_FREQ); 2607 2607 2608 2608 if (clock_set) 2609 - clock_was_set(CLOCK_REALTIME); 2609 + clock_was_set(CLOCK_SET_WALL); 2610 2610 2611 2611 ntp_notify_cmos_timer(); 2612 2612