public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: marcelo.dalmas@ge.com, stable@vger.kernel.org
Subject: Re: [PATCH backport] ntp: Remove invalid cast in time offset math
Date: Tue, 10 Dec 2024 16:22:12 +0100	[thread overview]
Message-ID: <2024121004-riveter-heading-d7c3@gregkh> (raw)
In-Reply-To: <878qssr16f.ffs@tglx>

On Fri, Dec 06, 2024 at 09:44:56PM +0100, Thomas Gleixner wrote:
> 
> From: Marcelo Dalmas <marcelo.dalmas@ge.com>
> 
> commit f5807b0606da7ac7c1b74a386b22134ec7702d05 upstream.
> 
> Due to an unsigned cast, adjtimex() returns the wrong offest when using
> ADJ_MICRO and the offset is negative. In this case a small negative offset
> returns approximately 4.29 seconds (~ 2^32/1000 milliseconds) due to the
> unsigned cast of the negative offset.
> 
> This cast was added when the kernel internal struct timex was changed to
> use type long long for the time offset value to address the problem of a
> 64bit/32bit division on 32bit systems.
> 
> The correct cast would have been (s32), which is correct as time_offset can
> only be in the range of [INT_MIN..INT_MAX] because the shift constant used
> for calculating it is 32. But that's non-obvious.
> 
> Remove the cast and use div_s64() to cure the issue.
> 
> [ tglx: Fix white space damage, use div_s64() and amend the change log ]
> [ tglx: Backport for 6.12.y and older ]
> 
> Fixes: ead25417f82e ("timex: use __kernel_timex internally")
> Signed-off-by: Marcelo Dalmas <marcelo.dalmas@ge.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/all/SJ0P101MB03687BF7D5A10FD3C49C51E5F42E2@SJ0P101MB0368.NAMP101.PROD.OUTLOOK.COM
> ---
>  kernel/time/ntp.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Now applied, thanks.

greg k-h

      reply	other threads:[~2024-12-10 15:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-06 12:03 FAILED: patch "[PATCH] ntp: Remove invalid cast in time offset math" failed to apply to 6.12-stable tree gregkh
2024-12-06 20:44 ` [PATCH backport] ntp: Remove invalid cast in time offset math Thomas Gleixner
2024-12-10 15:22   ` Greg KH [this message]

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=2024121004-riveter-heading-d7c3@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=marcelo.dalmas@ge.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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