[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070325111420.GA16988@elte.hu>
Date: Sun, 25 Mar 2007 13:14:20 +0200
From: Ingo Molnar <mingo@...e.hu>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Roman Zippel <zippel@...ux-m68k.org>,
john stultz <johnstul@...ibm.com>, linux-kernel@...r.kernel.org
Subject: [patch] ntp: avoid integer overflow in do_adjtimex()
* Thomas Gleixner <tglx@...utronix.de> wrote:
> Here you go. It's ugly, but it should do the trick for now.
>
> tglx
here's your patch with proper metadata:
--------------------->
From: Thomas Gleixner <tglx@...utronix.de>
Subject: [patch] ntp: avoid integer overflow in do_adjtimex()
John Stultz traced back ntpd problems to the following issue:
do_adjtimex() [used by ntpd] can overflow if there's a too long delay
between timer interrupts - as it can happen on NO_HZ. Expand the
time_adjust calculation/division from 32 bits to 64 bits.
Found-by: John Stultz <johnstul@...ibm.com>
Signed-off-by: Ingo Molnar <mingo@...e.hu>
---
Index: linux-2.6/kernel/time/ntp.c
===================================================================
--- linux-2.6.orig/kernel/time/ntp.c
+++ linux-2.6/kernel/time/ntp.c
@@ -196,7 +196,7 @@ void __attribute__ ((weak)) notify_arch_
*/
int do_adjtimex(struct timex *txc)
{
- long mtemp, save_adjust;
+ long mtemp, save_adjust, rem;
s64 freq_adj, temp64;
int result;
@@ -314,7 +314,9 @@ int do_adjtimex(struct timex *txc)
freq_adj += time_freq;
freq_adj = min(freq_adj, (s64)MAXFREQ_NSEC);
time_freq = max(freq_adj, (s64)-MAXFREQ_NSEC);
- do_div(time_offset, NTP_INTERVAL_FREQ);
+ time_offset = div_long_long_rem_signed(time_offset,
+ NTP_INTERVAL_FREQ,
+ &rem);
time_offset <<= SHIFT_UPDATE;
} /* STA_PLL */
} /* txc->modes & ADJ_OFFSET */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists