diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2020-11-01 20:13:45 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-11-01 20:13:45 +0100 |
commit | 4312e0e8d3eab027d9506db091eb10e6a9ff25d3 (patch) | |
tree | c3d14403f5d9bae1040c97e22fb23d0438a9915c /include | |
parent | Merge tag 'smp-urgent-2020-11-01' of git://git.kernel.org/pub/scm/linux/kerne... (diff) | |
parent | time: Prevent undefined behaviour in timespec64_to_ns() (diff) | |
download | linux-4312e0e8d3eab027d9506db091eb10e6a9ff25d3.tar.xz linux-4312e0e8d3eab027d9506db091eb10e6a9ff25d3.zip |
Merge tag 'timers-urgent-2020-11-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer fixes from Thomas Gleixner:
"A few fixes for timers/timekeeping:
- Prevent undefined behaviour in the timespec64_to_ns() conversion
which is used for converting user supplied time input to
nanoseconds. It lacked overflow protection.
- Mark sched_clock_read_begin/retry() to prevent recursion in the
tracer
- Remove unused debug functions in the hrtimer and timerlist code"
* tag 'timers-urgent-2020-11-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
time: Prevent undefined behaviour in timespec64_to_ns()
timers: Remove unused inline funtion debug_timer_free()
hrtimer: Remove unused inline function debug_hrtimer_free()
time/sched_clock: Mark sched_clock_read_begin/retry() as notrace
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/time64.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/time64.h b/include/linux/time64.h index c9dcb3e5781f..5117cb5b5656 100644 --- a/include/linux/time64.h +++ b/include/linux/time64.h @@ -124,6 +124,10 @@ static inline bool timespec64_valid_settod(const struct timespec64 *ts) */ static inline s64 timespec64_to_ns(const struct timespec64 *ts) { + /* Prevent multiplication overflow */ + if ((unsigned long long)ts->tv_sec >= KTIME_SEC_MAX) + return KTIME_MAX; + return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec; } |