Merge tag 'timers_urgent_for_v5.15_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer fix from Borislav Petkov:

- Handle negative second values properly when converting a timespec64
to nanoseconds.

* tag 'timers_urgent_for_v5.15_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
time: Handle negative seconds correctly in timespec64_to_ns()

+7 -2
+7 -2
include/linux/time64.h
··· 25 25 #define TIME64_MIN (-TIME64_MAX - 1) 26 26 27 27 #define KTIME_MAX ((s64)~((u64)1 << 63)) 28 + #define KTIME_MIN (-KTIME_MAX - 1) 28 29 #define KTIME_SEC_MAX (KTIME_MAX / NSEC_PER_SEC) 30 + #define KTIME_SEC_MIN (KTIME_MIN / NSEC_PER_SEC) 29 31 30 32 /* 31 33 * Limits for settimeofday(): ··· 126 124 */ 127 125 static inline s64 timespec64_to_ns(const struct timespec64 *ts) 128 126 { 129 - /* Prevent multiplication overflow */ 130 - if ((unsigned long long)ts->tv_sec >= KTIME_SEC_MAX) 127 + /* Prevent multiplication overflow / underflow */ 128 + if (ts->tv_sec >= KTIME_SEC_MAX) 131 129 return KTIME_MAX; 130 + 131 + if (ts->tv_sec <= KTIME_SEC_MIN) 132 + return KTIME_MIN; 132 133 133 134 return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec; 134 135 }