From: Thomas Gleixner <tglx@linutronix.de> mainline inclusion from mainline-v4.13-rc1 commit 098b0e01a91c42aaaf0425605cd126b03fcb0bcf category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/16862 CVE: CVE-2026-64560 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=... -------------------------------- The expiry time of a posix cpu timer is supplied through sys_timer_set() via a struct timespec. The timespec is validated for correctness. In the actual set timer implementation the timespec is converted to a scalar nanoseconds value. If the tv_sec part of the time spec is large enough the conversion to nanoseconds (sec * NSEC_PER_SEC) overflows 64bit. Mitigate that by using the timespec_to_ktime() conversion function, which checks the tv_sec part for a potential mult overflow and clamps the result to KTIME_MAX, which is about 292 years. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Xishi Qiu <qiuxishi@huawei.com> Cc: John Stultz <john.stultz@linaro.org> Link: http://lkml.kernel.org/r/20170620154113.588276707@linutronix.de Conflicts: kernel/time/posix-cpu-timers.c [ context conflicts. ] Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> --- kernel/time/posix-cpu-timers.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c index 3e08c8991833..c0adf954f556 100644 --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -591,7 +591,11 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, return -ESRCH; } - new_expires = timespec64_to_ns(&new->it_value); + /* + * Use the to_ktime conversion because that clamps the maximum + * value to KTIME_MAX and avoid multiplication overflows. + */ + new_expires = ktime_to_ns(timespec64_to_ktime(new->it_value)); /* * Protect against sighand release/switch in exit/exec and p->cpu_timers -- 2.34.1