All,
I recently ran into a bug with an older kernel where xtime's tv_nsec
field had accumulated more then 2 seconds worth of time. The timespec's
tv_nsec is a signed long, however gettimeofday() treats it as an
unsigned long. Thus when the failure occured, very strange and difficult
to debug time problems occurred.
The main cause of the problem I was seeing is already fixed in mainline,
however just to be safe, I figured the following patch would be wise.
I only audited i386 and x86_64, however other arches probably could have
similar signed problems as well.
Please let me know if you have any further comments or feedback.
thanks
-john
linux-2.6.13_signed-tv_nsec_A0.patch
====================================
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -824,7 +824,7 @@ static void update_wall_time(unsigned lo
do {
ticks--;
update_wall_time_one_tick();
- if (xtime.tv_nsec >= 1000000000) {
+ if ((unsigned long)xtime.tv_nsec >= 1000000000) {
xtime.tv_nsec -= 1000000000;
xtime.tv_sec++;
second_overflow();