mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 06:14:39 +01:00
The compat version of settimeofday() uses '>' instead of '>=' when validating tv_usec against USEC_PER_SEC, allowing the value 1000000 to pass the check. After the subsequent conversion to nanoseconds (tv_nsec *= NSEC_PER_USEC), this results in tv_nsec == NSEC_PER_SEC, which violates the timespec invariant that tv_nsec must be strictly less than NSEC_PER_SEC. The native settimeofday() was already fixed in commitce4abda5e1("time: Fix off-by-one in settimeofday() usec validation"), but the compat counterpart was missed. Fix it by using '>=' to reject tv_usec values outside the valid range [0, USEC_PER_SEC - 1]. Fixes:5e0fb1b57b("y2038: time: avoid timespec usage in settimeofday()") Signed-off-by: Wang Yan <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Cc: [email protected] Link: https://patch.msgid.link/[email protected]