Skip to content

timers: Prevent multiplication overflow in timespec/val conversions

Thomas Gleixner lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2itimer: Make timeval to nsec conversion range limitedkernel/time/itimer.c+6 -20 replies
2/2posix-cpu-timers: Make timespec to nsec conversion safekernel/time/posix-cpu-timers.c+5 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [patch 0/2] timers: Prevent multiplication overflow in timespec/val conversions

KASAN detected a multiplication overflow in the sys_setitimer() timeval conversion. The same issue is possible the posix-cpu-timer sys_timer_set() implementation.

In both cases the conversion of the tv_sec part overflows when multiplied with NSEC_PER_SEC, i.e. 1e9.

This can be mitigated by using the timespec/val_to_ktime() helper, which prevents the overflow and clamps the result to KTIME_MAX (~292 years).

Thanks,

tglx