Miscellaneous timer fixes:

- Fix timekeeping locking order bug in the timekeeping init code
    (Mikhail Gavrilov)
 
  - Fix u64 multiplication bug in the posix-cpu-timers code
    on 32-bit kernels (Zhan Xusheng)
 
  - Fix macro name in comment block (Ethan Nelson-Moore)
 
  - Fix off-by-one bug in the compat settimeofday() usecs
    validation code (Wang Yan)
 
 Signed-off-by: Ingo Molnar <mingo@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCgAvFiEEBpT5eoXrXCwVQwEKEnMQ0APhK1gFAmo6v6cRHG1pbmdvQGtl
 cm5lbC5vcmcACgkQEnMQ0APhK1iSVQ//RCLIhw+fUmcGrjN0E/MX8cFsg0ED3+PS
 3Dfi6mNY+vU5y2my+Mg8zMRw0m2xgnTs1rFeF8x9y2X6bbitoYePi/WomT4+uX/v
 Jj/EEfdbTBqvpZbfKiLN2GGwQJyVox5oRwEwKY1ik/xUFNxCqRxmELrNCUwU0Lwg
 b9UNjebX5WjtDufc0cw2RiBUNuAcAyE7gSqaf1IMyJTygS6l0iMQMkI6Xd8KHB+g
 LXRpB4V5RvFncCV6b81/9pKJzSM6EYdysKod/wi0kq0muxBlk+iiE7zdaiTKjzp5
 y/ItEStuNIQn/NAUYUX4ui1I9wRqYMrnNzvUFYLYWySpAU7V9GuyflB08RvXZpWb
 Gp6LtsZy192liyDvSUrYpQBnfkjKAPXxy3FrcnnI95U86UloXSMBvI+aQCHdFyt6
 TJpgkZM0fn7kjb9i/CB5Vyvrwu7iN+gm8lFtpu5DRHNzIVPvk/C4pyaM5Za/z68k
 dZ0Wv7pZzhLBjIxERzuMhr4YI6PG/DyFNz17JKiNr5S5sKk8q/pNhH3Ki99aaz5y
 IykkevHVgldp7/Zz91ixvLP3BYyFRx6++Bl1DOZyN/JAzAukuu2vBgaGnvzqfs5z
 7K5nqaouPNvvYbyCmb8bU9FtZUuHForN9LDQ3QGRYhQsVQH+u2FbEeFjfB8NQdOI
 llNA4FZgVUc=
 =dSO3
 -----END PGP SIGNATURE-----

Merge tag 'timers-urgent-2026-06-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull misc timer fixes from Ingo Molnar:

 - Fix timekeeping locking order bug in the timekeeping init code
   (Mikhail Gavrilov)

 - Fix u64 multiplication bug in the posix-cpu-timers code on 32-bit
   kernels (Zhan Xusheng)

 - Fix macro name in comment block (Ethan Nelson-Moore)

 - Fix off-by-one bug in the compat settimeofday() usecs validation code
   (Wang Yan)

* tag 'timers-urgent-2026-06-23' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  time: Fix off-by-one in compat settimeofday() usec validation
  hrtimer: Correct CONFIG_NO_HZ_COMMON macro name in comment
  posix-cpu-timers: Use u64 multiplication in update_rlimit_cpu()
  timekeeping: Register default clocksource before taking tk_core.lock
This commit is contained in:
Linus Torvalds 2026-06-23 16:57:39 -07:00
commit 541643982b
4 changed files with 7 additions and 6 deletions

View File

@ -799,7 +799,7 @@ static inline void hrtimer_switch_to_hres(void) { }
*
* This is only invoked when:
* - CONFIG_HIGH_RES_TIMERS is enabled.
* - CONFIG_NOHZ_COMMON is enabled
* - CONFIG_NO_HZ_COMMON is enabled
*
* For the other cases this function is empty and because the call sites
* are optimized out it vanishes as well, i.e. no need for lots of

View File

@ -41,7 +41,7 @@ void posix_cputimers_group_init(struct posix_cputimers *pct, u64 cpu_limit)
*/
int update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new)
{
u64 nsecs = rlim_new * NSEC_PER_SEC;
u64 nsecs = (u64)rlim_new * NSEC_PER_SEC;
unsigned long irq_fl;
if (!lock_task_sighand(task, &irq_fl))

View File

@ -251,7 +251,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32 __user *, tv,
get_user(new_ts.tv_nsec, &tv->tv_usec))
return -EFAULT;
if (new_ts.tv_nsec > USEC_PER_SEC || new_ts.tv_nsec < 0)
if (new_ts.tv_nsec >= USEC_PER_SEC || new_ts.tv_nsec < 0)
return -EINVAL;
new_ts.tv_nsec *= NSEC_PER_USEC;

View File

@ -2061,13 +2061,14 @@ void __init timekeeping_init(void)
*/
wall_to_mono = timespec64_sub(boot_offset, wall_time);
clock = clocksource_default_clock();
if (clock->enable)
clock->enable(clock);
guard(raw_spinlock_irqsave)(&tk_core.lock);
ntp_init();
clock = clocksource_default_clock();
if (clock->enable)
clock->enable(clock);
tk_setup_internals(tks, clock);
tk_set_xtime(tks, &wall_time);