]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
time: x86: Fix race switching from vsyscall to non-vsyscall clock
authorJohn Stultz <john.stultz@linaro.org>
Fri, 2 Mar 2012 06:11:09 +0000 (22:11 -0800)
committerJohn Stultz <john.stultz@linaro.org>
Fri, 16 Mar 2012 01:17:53 +0000 (18:17 -0700)
commita939e817aa7e199d2fff05a67cb745be32dd5c2d
treef55d3554476ce03c7fe6731284221a177e896d6b
parenta078c6d0e6288fad6d83fb6d5edd91ddb7b6ab33
time: x86: Fix race switching from vsyscall to non-vsyscall clock

When switching from a vsyscall capable to a non-vsyscall capable
clocksource, there was a small race, where the last vsyscall
gettimeofday before the switch might return a invalid time value
using the new non-vsyscall enabled clocksource values after the
switch is complete.

This is due to the vsyscall code checking the vclock_mode once
outside of the seqcount protected section. After it reads the
vclock mode, it doesn't re-check that the sampled clock data
that is obtained in the seqcount critical section still matches.

The fix is to sample vclock_mode inside the protected section,
and as long as it isn't VCLOCK_NONE, return the calculated
value. If it has changed and is now VCLOCK_NONE, fall back
to the syscall gettime calculation.

v2:
  * Cleanup checks as suggested by tglx
  * Also fix same issue present in gettimeofday path

CC: Andy Lutomirski <luto@amacapital.net>
CC: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
arch/x86/vdso/vclock_gettime.c