Re: [PATCH] time: Fix off-by-one in settimeofday() usec validation

From: John Stultz

Date: Mon Jun 01 2026 - 17:59:19 EST


On Sun, May 31, 2026 at 9:35 PM Naveen Kumar Chaudhary
<naveen.osdev@xxxxxxxxx> wrote:
>
> The validation check uses '>' instead of '>=' when comparing tv_usec
> against USEC_PER_SEC, allowing the value 1000000 through. After
> conversion to nanoseconds (*= 1000), this produces tv_nsec ==
> NSEC_PER_SEC, violating the timespec invariant that tv_nsec must be
> less than NSEC_PER_SEC.
>
> Use '>=' to reject tv_usec values that are not in the valid range of
> 0 to 999999.
>
> Signed-off-by: Naveen Kumar Chaudhary <naveen.osdev@xxxxxxxxx>

Probably needs a Fixes: tag. Likely: 5e0fb1b57bea ("y2038: time: avoid
timespec usage in settimeofday()")

Otherwise looks reasonable,
Acked-by: John Stultz <jstultz@xxxxxxxxxx>

thanks
-john