Received: by 10.192.165.148 with SMTP id m20csp3333712imm; Mon, 7 May 2018 10:25:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpApsWFv0seQn5RDXbNyPPhIyIDesEhOVpH8KPEJAmZbKbnL0WDtBn3LMHOB9iDBva6IHZV X-Received: by 2002:a6b:21cb:: with SMTP id h194-v6mr38473878ioh.181.1525713935151; Mon, 07 May 2018 10:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525713935; cv=none; d=google.com; s=arc-20160816; b=Sfd/9bbAIsL65KTASO5Hc3hHzdoDseKsisT1PQ6XW0OepfkN86suqxY+VOm0MICnYq UFVhqlPy/kdK4NaK2TOIFdIHpNcBXOu34KyQX2fSTfQZIX3G5aZSlhdRghQs/vgyvvR6 LlUI9V+ESzkllOFVlqsZa+GKtqm3wrH1iFB9gru5qTo/5LxPKqvfM8DZzD36CcqbrXt6 7OjZB7K4N/AYVe9/8URpx1en18XKbUevtYINITUCbEStWLjZy3A2squahd9YUQzfLK6O aB20kQnYiD+spDEKkcL2U6Lqu8uTsup5k5YamqG5Em+/MwfqkB08Xc2wrbnyUwTytWer Coxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=HN1HQgUb6t+KreOoD0ObEryoiSWFzsFbn975pxzklJA=; b=XlqjGinIyAGFKXLSa025+rV7Y/fetAP7D9hvVA76txEI5SH12MU9sfBLyn2PRdsTzj emW1IoXtC7HwGgwIvBfDVNvczMLJ2D/vdem2MzRA9mrOhGCv0YE1l8c2jsgtbfyI/ARl 5EZaHNBT7Zn4W/5whxczDFvqZBznMpl33Bvau8BwAE676jiHW67k81jZjZqW4A0xvgVY Cay5MZrKHcpfDRpc1hrXPmYfwGetoqCptt1Aj7PGtc2icbmfvhxf5k9SiUaJ5Zx6l0Lf 74XjpeAfAACH/UqfFrPMl7hSS0lhfyhuqiFCoojEDXcb6uWZV2axF6fBhTwskC5aBaNN gKiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=CcP1Gv19; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l16-v6si7413616iti.135.2018.05.07.10.25.21; Mon, 07 May 2018 10:25:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=CcP1Gv19; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752734AbeEGRZH (ORCPT + 99 others); Mon, 7 May 2018 13:25:07 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:37020 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752449AbeEGRZF (ORCPT ); Mon, 7 May 2018 13:25:05 -0400 Received: by mail-wm0-f66.google.com with SMTP id l1-v6so16813777wmb.2; Mon, 07 May 2018 10:25:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=HN1HQgUb6t+KreOoD0ObEryoiSWFzsFbn975pxzklJA=; b=CcP1Gv19F+tWgwW81j7oVMucY1gs9vEwAXx8HbUux3IIT6IZ/fkMmIN7YbPr7pjGTC aYZMtNVytvUZXj+FN8FkjAMb31sBBTh7yJOdfVec0DR7UJm2e2HcONUm/p8wvK2AUuZX /ElJJ5HHF/C6Ib9S1eMgib7zzyRpdhPZd4+8anwAudORVG8R98YGS2RjdhBiL7mfIXkB 9wK9wC2xBLt3IqXy4HwRf1fC/DXjHtcq/gvwWBUJ3Zajb3EvuYlKDIVfDWJ4cZJtd1fJ 9bG/JPwQn/cjFIJGdlDirQy2FM+C72EaMuOxKAMM+ad2HGlQoxkvkUVpid+k3xYcdDuB /kPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=HN1HQgUb6t+KreOoD0ObEryoiSWFzsFbn975pxzklJA=; b=GnS/YLra+3DnVpXxxfTIxvQn2m2RPgW9+CpEjjawUeazIZv2lqAOBT2EL7fiKGRZSI 9iAk42SmtCMd7lBNzadionx8eMkVVVJNmnu/KdF52SYiKohvSbmXYTdjcNAL3+P0PSyj pKgupNSZ5kQYrqqHLppm4CpFWSL5ka0rqKEvOyydGjTA2LiZ1pSLox75ppHfH1rAj0VK s+Tkff28eM/xXPtoSj+yx4auRqUS0qrOIjZqSqORXEDibyXAiDHjfhGe3/fQfWXU7aIV yOEB09VN3vtl5Uqey81ZPCytbDNGTDxVBMs3XxvZZ+Vho/oksMdEathyFYbpVBoaJl2o TqpA== X-Gm-Message-State: ALQs6tDdiK6EfuSpUd4MOPBdAR5lPwFhAjCmqw0y5D7Qi/VTs4I0eE2X LcFuT4G+ZLDgJkMFVypXe2+oe+/1 X-Received: by 2002:a50:84e9:: with SMTP id 96-v6mr51032215edq.235.1525713903903; Mon, 07 May 2018 10:25:03 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-189-60.clienti.tiscali.it. [78.12.189.60]) by smtp.gmail.com with ESMTPSA id g21-v6sm10124128edm.27.2018.05.07.10.25.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 10:25:03 -0700 (PDT) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Roman Kagan , Thomas Avery Subject: [PATCH] KVM: hyperv: idr_find needs RCU protection Date: Mon, 7 May 2018 19:25:00 +0200 Message-Id: <1525713900-26152-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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