[RHEL7,COMMIT] ms/KVM: hyperv: idr_find needs RCU protection

Submitted by Konstantin Khorenko on June 15, 2018, noon


Message ID 201806151200.w5FC0A7b009940@finist_ce7.work
State New
Series "KVM: hyperv: idr_find needs RCU protection"
Headers show

Commit Message

Konstantin Khorenko June 15, 2018, noon
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.9
commit 7f453e0de98d5182d6e55370baf3eab3d0e51c86
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Fri Jun 15 15:00:10 2018 +0300

    ms/KVM: hyperv: idr_find needs RCU protection
    Even though the eventfd is released after the KVM SRCU grace period
    elapses, the conn_to_evt data structure itself is not; it uses RCU
    internally, instead.  Fix the read-side critical section to happen
    under rcu_read_lock/unlock; the result is still protected by
    Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    (cherry picked from commit 452a68d0ef341c4d544757e02154788227b2a08b)
    Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
 arch/x86/kvm/hyperv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index d31d37c8765a..50fbbe99703b 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -1269,8 +1269,10 @@  static u16 kvm_hvcall_signal_event(struct kvm_vcpu *vcpu, bool fast, u64 param)
 	if (param & ~KVM_HYPERV_CONN_ID_MASK)
-	/* conn_to_evt is protected by vcpu->kvm->srcu */
+	/* the eventfd is protected by vcpu->kvm->srcu, but conn_to_evt isn't */
+	rcu_read_lock();
 	eventfd = idr_find(&vcpu->kvm->arch.hyperv.conn_to_evt, param);
+	rcu_read_unlock();
 	if (!eventfd)