diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2018-05-07 19:24:34 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2018-05-11 11:21:11 +0200 |
commit | 452a68d0ef341c4d544757e02154788227b2a08b (patch) | |
tree | cd20a5942452373352c9861437b13f0eb58f94fe /arch/x86/kvm/hyperv.c | |
parent | 6356ee0c9602004e0a3b4b2dad68ee2ee9385b17 (diff) | |
download | linux-stable-452a68d0ef341c4d544757e02154788227b2a08b.tar.gz linux-stable-452a68d0ef341c4d544757e02154788227b2a08b.tar.bz2 linux-stable-452a68d0ef341c4d544757e02154788227b2a08b.zip |
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
vcpu->kvm->srcu.
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/hyperv.c')
-rw-r--r-- | arch/x86/kvm/hyperv.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 14dd5e5010a2..5708e951a5c6 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -1296,8 +1296,10 @@ static u16 kvm_hvcall_signal_event(struct kvm_vcpu *vcpu, bool fast, u64 param) if (param & ~KVM_HYPERV_CONN_ID_MASK) return HV_STATUS_INVALID_HYPERCALL_INPUT; - /* 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) return HV_STATUS_INVALID_PORT_ID; |