LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] KVM: hyperv: idr_find needs RCU protection
@ 2018-05-07 17:25 Paolo Bonzini
  2018-05-08 17:35 ` Roman Kagan
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2018-05-07 17:25 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: Roman Kagan, Thomas Avery

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.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/hyperv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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;
 
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: hyperv: idr_find needs RCU protection
  2018-05-07 17:25 [PATCH] KVM: hyperv: idr_find needs RCU protection Paolo Bonzini
@ 2018-05-08 17:35 ` Roman Kagan
  0 siblings, 0 replies; 2+ messages in thread
From: Roman Kagan @ 2018-05-08 17:35 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: linux-kernel, kvm, Thomas Avery

On Mon, May 07, 2018 at 07:25:00PM +0200, Paolo Bonzini wrote:
> 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.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/kvm/hyperv.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-08 17:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-07 17:25 [PATCH] KVM: hyperv: idr_find needs RCU protection Paolo Bonzini
2018-05-08 17:35 ` Roman Kagan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).