public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Miroslav Lichvar <mlichvar@redhat.com>
To: John Stultz <john.stultz@linaro.org>
Cc: Xiongfeng Wang <wangxiongfeng2@huawei.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Stephen Boyd <sboyd@kernel.org>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH] ntp: Avoid undefined behaviour in second_overflow()
Date: Wed, 6 Mar 2019 10:54:42 +0100	[thread overview]
Message-ID: <20190306095442.GM21520@localhost> (raw)
In-Reply-To: <CALAqxLXFGKDzxT-S9DDnjRRYvDB1Qq3T-tHYYGQXg3c47HtTbQ@mail.gmail.com>

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'

There was a patch submitted couple years ago that prevented overflows
in 32-bit time_t and ktime_t.

http://lkml.iu.edu/hypermail/linux/kernel/1510.0/04719.html

-- 
Miroslav Lichvar

  reply	other threads:[~2019-03-06  9:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-06  1:28 [RFC PATCH] ntp: Avoid undefined behaviour in second_overflow() Xiongfeng Wang
2019-03-06  1:42 ` John Stultz
2019-03-06  9:54   ` Miroslav Lichvar [this message]
2019-03-06 12:29     ` Thomas Gleixner
2019-03-06 13:37       ` Arnd Bergmann
2019-03-07  5:10         ` Richard Cochran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190306095442.GM21520@localhost \
    --to=mlichvar@redhat.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wangxiongfeng2@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox