WSL2-Linux-Kernel/kernel/time
Zeng Tao cb47755725 time: Prevent undefined behaviour in timespec64_to_ns()
UBSAN reports:

Undefined behaviour in ./include/linux/time64.h:127:27
signed integer overflow:
17179869187 * 1000000000 cannot be represented in type 'long long int'
Call Trace:
 timespec64_to_ns include/linux/time64.h:127 [inline]
 set_cpu_itimer+0x65c/0x880 kernel/time/itimer.c:180
 do_setitimer+0x8e/0x740 kernel/time/itimer.c:245
 __x64_sys_setitimer+0x14c/0x2c0 kernel/time/itimer.c:336
 do_syscall_64+0xa1/0x540 arch/x86/entry/common.c:295

Commit bd40a17576 ("y2038: itimer: change implementation to timespec64")
replaced the original conversion which handled time clamping correctly with
timespec64_to_ns() which has no overflow protection.

Fix it in timespec64_to_ns() as this is not necessarily limited to the
usage in itimers.

[ tglx: Added comment and adjusted the fixes tag ]

Fixes: 361a3bf005 ("time64: Add time64.h header and define struct timespec64")
Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/1598952616-6416-1-git-send-email-prime.zeng@hisilicon.com
2020-10-26 11:48:11 +01:00
..
Kconfig posix-cpu-timers: Provide mechanisms to defer timer handling to task_work 2020-08-06 16:50:59 +02:00
Makefile
alarmtimer.c alarmtimer: Convert comma to semicolon 2020-08-25 12:45:53 +02:00
clockevents.c
clocksource.c
hrtimer.c hrtimer: Remove unused inline function debug_hrtimer_free() 2020-10-26 11:39:21 +01:00
itimer.c time: Prevent undefined behaviour in timespec64_to_ns() 2020-10-26 11:48:11 +01:00
jiffies.c
namespace.c
ntp.c
ntp_internal.h
posix-clock.c
posix-cpu-timers.c posix-cpu-timers: Provide mechanisms to defer timer handling to task_work 2020-08-06 16:50:59 +02:00
posix-stubs.c
posix-timers.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
posix-timers.h
sched_clock.c time/sched_clock: Mark sched_clock_read_begin/retry() as notrace 2020-10-26 11:34:31 +01:00
test_udelay.c
tick-broadcast-hrtimer.c
tick-broadcast.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
tick-common.c
tick-internal.h
tick-oneshot.c
tick-sched.c tick-sched: Clarify "NOHZ: local_softirq_pending" warning 2020-08-24 18:38:32 -07:00
tick-sched.h
time.c
timeconst.bc
timeconv.c
timecounter.c
timekeeping.c These are the locking updates for v5.10: 2020-10-12 13:06:20 -07:00
timekeeping.h
timekeeping_debug.c
timekeeping_internal.h timekeeping/vsyscall: Provide vdso_update_begin/end() 2020-08-06 10:57:30 +02:00
timer.c timers: Remove unused inline funtion debug_timer_free() 2020-10-26 11:39:21 +01:00
timer_list.c
vsyscall.c timekeeping/vsyscall: Provide vdso_update_begin/end() 2020-08-06 10:57:30 +02:00