Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1314897

Re: [PATCH 1/2] ntp: Fix ADJ_SETOFFSET being used w/ ADJ_NANO

From David Herrmann <dh.herrmann@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/2] ntp: Fix ADJ_SETOFFSET being used w/ ADJ_NANO
Date 2016-01-22 12:10 +0100
Message-ID <qTHLl-3dT-39@gated-at.bofh.it> (permalink)
References <qTwwz-3Hx-37@gated-at.bofh.it> <qTwwz-3Hx-43@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi

On Fri, Jan 22, 2016 at 12:03 AM, John Stultz <john.stultz@linaro.org> wrote:
> Recently, in commit 37cf4dc3370f
> ("time: Verify time values in adjtimex ADJ_SETOFFSET to avoid overflow")
> I forgot to check if the timeval being passed was actually a
> timespec (as is signaled with ADJ_NANO).
>
> This resulted in that patch breaking ADJ_SETOFFSET users who set
> ADJ_NANO, by rejecting valid timespecs that were compared with
> valid timeval ranges.
>
> This patch addresses this by checking for the ADJ_NANO flag and
> using the timepsec check instead in that case.
>
> Cc: Sasha Levin <sasha.levin@oracle.com>
> Cc: Richard Cochran <richardcochran@gmail.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Prarit Bhargava <prarit@redhat.com>
> Cc: Harald Hoyer <harald@redhat.com>
> Cc: Kay Sievers <kay@vrfy.org>
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Reported-by: Harald Hoyer <harald@redhat.com>
> Reported-by: Kay Sievers <kay@vrfy.org>
> Signed-off-by: John Stultz <john.stultz@linaro.org>

Thanks for picking this up. Looks good to me:

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

Thanks
David

> ---
>  kernel/time/ntp.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
> index 36f2ca0..6df8927 100644
> --- a/kernel/time/ntp.c
> +++ b/kernel/time/ntp.c
> @@ -685,8 +685,18 @@ int ntp_validate_timex(struct timex *txc)
>                 if (!capable(CAP_SYS_TIME))
>                         return -EPERM;
>
> -               if (!timeval_inject_offset_valid(&txc->time))
> -                       return -EINVAL;
> +               if (txc->modes & ADJ_NANO) {
> +                       struct timespec ts;
> +
> +                       ts.tv_sec = txc->time.tv_sec;
> +                       ts.tv_nsec = txc->time.tv_usec;
> +                       if (!timespec_inject_offset_valid(&ts))
> +                               return -EINVAL;
> +
> +               } else {
> +                       if (!timeval_inject_offset_valid(&txc->time))
> +                               return -EINVAL;
> +               }
>         }
>
>         /*
> --
> 1.9.1
>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] Fix for ADJ_SETOFFSET w/ ADJ_NANO John Stultz <john.stultz@linaro.org> - 2016-01-22 00:10 +0100
  [PATCH 1/2] ntp: Fix ADJ_SETOFFSET being used w/ ADJ_NANO John Stultz <john.stultz@linaro.org> - 2016-01-22 00:10 +0100
    [tip:timers/urgent] ntp: Fix ADJ_SETOFFSET being used w/ ADJ_NANO tip-bot for John Stultz <tipbot@zytor.com> - 2016-01-22 12:10 +0100
    Re: [PATCH 1/2] ntp: Fix ADJ_SETOFFSET being used w/ ADJ_NANO David Herrmann <dh.herrmann@gmail.com> - 2016-01-22 12:10 +0100
  [PATCH 2/2] kselftests: timers: Add adjtimex SETOFFSET validity tests John Stultz <john.stultz@linaro.org> - 2016-01-22 00:10 +0100
    [tip:timers/urgent] kselftests: timers:   Add adjtimex SETOFFSET validity tests tip-bot for John Stultz <tipbot@zytor.com> - 2016-01-26 16:50 +0100
  Re: [PATCH 0/2] Fix for ADJ_SETOFFSET w/ ADJ_NANO Shuah Khan <shuahkh@osg.samsung.com> - 2016-01-22 00:20 +0100
    Re: [PATCH 0/2] Fix for ADJ_SETOFFSET w/ ADJ_NANO Thomas Gleixner <tglx@linutronix.de> - 2016-01-22 09:00 +0100
      Re: [PATCH 0/2] Fix for ADJ_SETOFFSET w/ ADJ_NANO Shuah Khan <shuahkh@osg.samsung.com> - 2016-01-22 16:00 +0100

csiph-web