lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdVXdH+2tgS9rUNqwZwRsGjiecW1t1_sJJLJRhpTuzPxcQ@mail.gmail.com>
Date:   Mon, 11 Jan 2021 11:43:58 +0100
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     John Stultz <john.stultz@...aro.org>,
        Jason Gunthorpe <jgg@...pe.ca>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Stephen Boyd <sboyd@...nel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Geert Uytterhoeven <geert+renesas@...der.be>
Subject: Re: [PATCH] ntp: Fix RTC synchronization on 32-bit platforms

On Mon, Jan 11, 2021 at 11:40 AM Geert Uytterhoeven
<geert+renesas@...der.be> wrote:
> Due to an integer overflow, RTC synchronization now happens every 2s
> instead of the intended 11 minutes.  Fix this by forcing 64-bit
> arithmetic for the sync period calculation.
>
> Fixes: c9e6189fb03123a7 ("ntp: Make the RTC synchronization more reliable")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
> ---
>  kernel/time/ntp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
> index 7404d38315276a96..54d52fab201d283e 100644
> --- a/kernel/time/ntp.c
> +++ b/kernel/time/ntp.c
> @@ -498,7 +498,7 @@ int second_overflow(time64_t secs)
>  static void sync_hw_clock(struct work_struct *work);
>  static DECLARE_WORK(sync_work, sync_hw_clock);
>  static struct hrtimer sync_hrtimer;
> -#define SYNC_PERIOD_NS (11UL * 60 * NSEC_PER_SEC)
> +#define SYNC_PERIOD_NS (11ULL * 60 * NSEC_PER_SEC)
>
>  static enum hrtimer_restart sync_timer_callback(struct hrtimer *timer)
>  {

While the line

    exp = ktime_add_ns(exp, 2 * NSEC_PER_SEC - offset_nsec);

is currently not an issue, it may be wise to change it to

    exp = ktime_add_ns(exp, 2ULL * NSEC_PER_SEC - offset_nsec);

in case someone wants to experiment with values larger then 4s?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ