Messages in this thread Patch in this message | | | From | "Ulrich Windl" <> | Date | Tue, 28 Sep 1999 08:43:36 +0200 | Subject | 2.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 | |