Skip to contentSkip to conversation

fix vsyscall settimeofday

PATCH In review Daniel Walker 2 participants 2 messages Mar 5, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix vsyscall settimeofday

I've only seen this on x86_64 .

The vsyscall state only gets updated when a timer interrupts comes in . So if the time is set long before the next timer, there will be a period when a gettimeofday() won't reflect the correct time.

I added an explicit update_vsyscall() during the settimeofday(), that way the vsyscall state doesn't get stale.

Any thought John?

---
 kernel/timer.c |    2 ++
 1 file changed, 2 insertions(+)
kernel/timer.c +2 -0
Index: linux-2.6.20/kernel/timer.c
===================================================================
@@ -861,6 +861,8 @@ int do_settimeofday(struct timespec *tv)
 	clock->error = 0;
 	ntp_clear();
 
+	update_vsyscall(&xtime, clock);
+
 	write_sequnlock_irqrestore(&xtime_lock, flags);
 
 	/* signal hrtimers about time change */
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Daniel Walker

I've only seen this on x86_64 .

The vsyscall state only gets updated when a timer interrupts comes in . So if the time is set long before the next timer, there will be a period when a gettimeofday() won't reflect the correct time.

I added an explicit update_vsyscall() during the settimeofday(), that way the vsyscall state doesn't get stale.

Any thought John?

Oh! Yes, very good catch, Daniel!

Thanks so much!
-john

Quoted 1 line
Quoted 17 lines
---
 kernel/timer.c |    2 ++
 1 file changed, 2 insertions(+)

Index: linux-2.6.20/kernel/timer.c
===================================================================

kernel/timer.c +2 -0
@@ -861,6 +861,8 @@ int do_settimeofday(struct timespec *tv)
 	clock->error = 0;
 	ntp_clear();
 
+	update_vsyscall(&xtime, clock);
+
 	write_sequnlock_irqrestore(&xtime_lock, flags);
 
 	/* signal hrtimers about time change */