]> git.baikalelectronics.ru Git - kernel.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)
commita0ba574b2103b8ee2f7ac406ea13100e09630dad
treef55d3554476ce03c7fe6731284221a177e896d6b
parent60f3ce491fc9b28316d7ae1ad48a5b082fc459da
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