]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: Fix potential race in KVM_GET_CLOCK
authorOliver Upton <oupton@google.com>
Thu, 16 Sep 2021 18:15:34 +0000 (18:15 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 1 Oct 2021 07:44:47 +0000 (03:44 -0400)
commite63b7c9e6ef9c76ace1a1454e54ca3c4f81a5a97
treed29e5a937cf2e583210fa2dd4a8e8c32b0b9bfaf
parentd01dbb8b90791c7df87c4efb3674d3bfacf64b35
KVM: x86: Fix potential race in KVM_GET_CLOCK

Sean noticed that KVM_GET_CLOCK was checking kvm_arch.use_master_clock
outside of the pvclock sync lock. This is problematic, as the clock
value written to the user may or may not actually correspond to a stable
TSC.

Fix the race by populating the entire kvm_clock_data structure behind
the pvclock_gtod_sync_lock.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Oliver Upton <oupton@google.com>
Message-Id: <20210916181538.968978-4-oupton@google.com>
Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c