Skip to content

Commit 452a68d

Browse files
committed
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 <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 6356ee0 commit 452a68d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/x86/kvm/hyperv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,8 +1296,10 @@ static u16 kvm_hvcall_signal_event(struct kvm_vcpu *vcpu, bool fast, u64 param)
12961296
if (param & ~KVM_HYPERV_CONN_ID_MASK)
12971297
return HV_STATUS_INVALID_HYPERCALL_INPUT;
12981298

1299-
/* conn_to_evt is protected by vcpu->kvm->srcu */
1299+
/* the eventfd is protected by vcpu->kvm->srcu, but conn_to_evt isn't */
1300+
rcu_read_lock();
13001301
eventfd = idr_find(&vcpu->kvm->arch.hyperv.conn_to_evt, param);
1302+
rcu_read_unlock();
13011303
if (!eventfd)
13021304
return HV_STATUS_INVALID_PORT_ID;
13031305

0 commit comments

Comments
 (0)