lkml.org 
[lkml]   [1999]   [Sep]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject2.2.12: patchlet for adjtimex
Hello,

I'll attach a patch that will take care of a potential overflow
condition if STA_PLL and STA_PPSTIME is active and the offset exceeds
bounds. (The STA_PPSTIME won't work in the standard kernel, so this
is almost a non-issue, but it's more correct that way). PPSkit-0.7
does not have this problem, because the implementation is quite
different...

Regards,
Ulrich


--- kernel/time.c.SAVED Wed Mar 24 20:31:47 1999
+++ kernel/time.c Mon Sep 27 20:35:50 1999
@@ -22,6 +22,10 @@
* "A Kernel Model for Precision Timekeeping" by Dave Mills
* Allow time_constant larger than MAXTC(6) for NTP v4 (MAXTC == 10)
* (Even though the technical memorandum forbids it)
+ * 1999-09-27 Ulrich Windl
+ * adjtimex(): Fix case where `ltemp' could be out of bounds in PLL mode
+ * when adjusting the offset via MOD_OFFSET and STA_PPSTIME is active
+ * (extremely unlikely and not too serious).
*/

#include <linux/mm.h>
@@ -299,13 +303,15 @@
* Scale the phase adjustment and
* clamp to the operating range.
*/
- if (ltemp > MAXPHASE)
- time_offset = MAXPHASE << SHIFT_UPDATE;
- else if (ltemp < -MAXPHASE)
- time_offset = -(MAXPHASE << SHIFT_UPDATE);
- else
- time_offset = ltemp << SHIFT_UPDATE;
-
+ if (ltemp >= 0) {
+ if (ltemp > MAXPHASE)
+ ltemp = MAXPHASE;
+ time_offset = ltemp << SHIFT_UPDATE;
+ } else {
+ if (ltemp < -MAXPHASE)
+ ltemp = -MAXPHASE;
+ time_offset = -(-ltemp << SHIFT_UPDATE);
+ }
/*
* Select whether the frequency is to be controlled
* and in which mode (PLL or FLL). Clamp to the operating
\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.397 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site