lkml.org 
[lkml]   [2019]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH] ntp: Avoid undefined behaviour in second_overflow()
On Wed, 6 Mar 2019, Miroslav Lichvar wrote:
> On Tue, Mar 05, 2019 at 05:42:25PM -0800, John Stultz wrote:
> > > --- a/kernel/time/ntp.c
> > > +++ b/kernel/time/ntp.c
> > > @@ -677,6 +677,8 @@ static inline void process_adjtimex_modes(const struct timex *txc, s32 *time_tai
> > >
> > > if (txc->modes & ADJ_MAXERROR)
> > > time_maxerror = txc->maxerror;
> > > + if (time_maxerror > NTP_PHASE_LIMIT)
> > > + time_maxerror = NTP_PHASE_LIMIT;
> >
> > This looks sane to me.
> > Acked-by: John Stultz <john.stultz@linaro.org>
> >
> > Though it makes me wonder a bit more about the sanity checking on the
> > other parameters passed via adjtimex(), tick_usec for instance looks
> > like it could be similarly problematic.
>
> The tick length is checked earlier in timekeeping_validate_timex(), so
> that should be ok.
>
> What I'd like to see clamped is the system time itself. ktime_t
> overflows on Apr 11 2262. clock_settime() and adjtimex(ADJ_SETOFFSET)
> can set the time close to the overflow and let everything break.
>
> Boot a VM and try this:
>
> # date -s 'Apr 11 23:47:15 UTC 2262'

So once Arnd is done with y2038, we'll ask him to look into y2262 :)

Seriously, yes we should do clamping there.

Thanks,

tglx

\
 
 \ /
  Last update: 2019-03-06 13:30    [W:0.057 / U:5.188 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site