Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1011188ybe; Wed, 4 Sep 2019 11:06:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLuPIyhNaXFyhrgchW2PQT9ceRI58D7DGLt/WQiI6pSY8OiuuAssVIekzwo08hrBKRaBXY X-Received: by 2002:aa7:99da:: with SMTP id v26mr5615803pfi.258.1567620416509; Wed, 04 Sep 2019 11:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620416; cv=none; d=google.com; s=arc-20160816; b=b0WDnXBxPlEpfYEo/veJCkNADbo7rIcctPxdb083exLc2zI3MVcdiYzsmjtrNxUlDZ vHiK6yIZFrONeQ4LSYJB++zkT6fmsAAWoVd+EcuLSRUSm36xFoyxL/Gw4BUxsEW4nXgq TMjAKzxUgzfWh720762at7TtSUTY68yUbIrfiYg01MNFH0smQEWj+t2A36n+x3mDlqnx qRIcKkYQJrcpHs4TfI4Gmag6DeKOugmw3csiVFWcZZNQlWQ791n5Bch7/q8kDvu9TFXe 2UwQc5Pwx5KbTmpdhwqlgt7VuEKZq8LEm1cZYJ4Fg0M1x6hDYCxc5FoyI5ube1K5vTai f7UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vk01BWsbVjxTc+qGASTr6U1RreSWuH9oyfQhGXUm9NA=; b=ckcz1JbDW/fVBCIZiwKSjSpvErPCeZ2Y1fjckdU4HmC/08zTpN2i8lmzC8CtcOmLRN rxIdqAEoFHqLIMxjG6V49PHGFjq4BJiz9WowXMBwTHLJY0FWd76fmwhGKTaD7VkbdGdm 2AQIoKZUJOtbJ44SIoevf2gONE6exyCy/yKdHmUWjwG9loExALUxHZPad/bwqwFWMC9l yZNIgTFeHuW4kgQE/afYrs3CsEyKWkg/EmBhyqdjSwxjLln4UhMt9hBKoUCpzTXuaOlr MftX0CFbE3xcNl8JmhZ4uu62fKMWZXkSqjsvsEX8mz6/hzGwo37NCR5onFvqVCjsGv8k 7Obg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="FWa1TN/Q"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y8si2025022plp.294.2019.09.04.11.06.36; Wed, 04 Sep 2019 11:06:56 -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=pass header.i=@kernel.org header.s=default header.b="FWa1TN/Q"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389180AbfIDSE6 (ORCPT + 99 others); Wed, 4 Sep 2019 14:04:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:46182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389173AbfIDSE6 (ORCPT ); Wed, 4 Sep 2019 14:04:58 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9DEF7206B8; Wed, 4 Sep 2019 18:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620297; bh=zV6Oz1eNYxYgplHgnqQsHbvKLHOd2FEQv/eSx8SQHxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FWa1TN/QQzTpu2hnUYAac6w6GnHuQF904jJ2GdDWfWH8FINbT0ZBBJNRhZc8ei6qG Rj4G/tHQVIoyzfky3pk7k0KBig4i4dCkGuUGGJW/sT1tQPhrJSEp8uI8TvXAQhx2z5 PgcRXP5aTWVzDphbSNmedKuOQynQjAidLvhpLXcI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexey Kardashevskiy , Paul Mackerras , Sasha Levin Subject: [PATCH 4.14 49/57] KVM: PPC: Book3S: Fix incorrect guest-to-user-translation error handling Date: Wed, 4 Sep 2019 19:54:17 +0200 Message-Id: <20190904175306.689260889@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175301.777414715@linuxfoundation.org> References: <20190904175301.777414715@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit ddfd151f3def9258397fcde7a372205a2d661903 ] H_PUT_TCE_INDIRECT handlers receive a page with up to 512 TCEs from a guest. Although we verify correctness of TCEs before we do anything with the existing tables, there is a small window when a check in kvmppc_tce_validate might pass and right after that the guest alters the page of TCEs, causing an early exit from the handler and leaving srcu_read_lock(&vcpu->kvm->srcu) (virtual mode) or lock_rmap(rmap) (real mode) locked. This fixes the bug by jumping to the common exit code with an appropriate unlock. Cc: stable@vger.kernel.org # v4.11+ Fixes: 121f80ba68f1 ("KVM: PPC: VFIO: Add in-kernel acceleration for VFIO") Signed-off-by: Alexey Kardashevskiy Signed-off-by: Paul Mackerras Signed-off-by: Sasha Levin --- arch/powerpc/kvm/book3s_64_vio.c | 6 ++++-- arch/powerpc/kvm/book3s_64_vio_hv.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c index e14cec6bc3398..2c6cce8e7cfd0 100644 --- a/arch/powerpc/kvm/book3s_64_vio.c +++ b/arch/powerpc/kvm/book3s_64_vio.c @@ -566,8 +566,10 @@ long kvmppc_h_put_tce_indirect(struct kvm_vcpu *vcpu, if (kvmppc_gpa_to_ua(vcpu->kvm, tce & ~(TCE_PCI_READ | TCE_PCI_WRITE), - &ua, NULL)) - return H_PARAMETER; + &ua, NULL)) { + ret = H_PARAMETER; + goto unlock_exit; + } list_for_each_entry_lockless(stit, &stt->iommu_tables, next) { ret = kvmppc_tce_iommu_map(vcpu->kvm, diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c b/arch/powerpc/kvm/book3s_64_vio_hv.c index 648cf6c013489..23d6d1592f117 100644 --- a/arch/powerpc/kvm/book3s_64_vio_hv.c +++ b/arch/powerpc/kvm/book3s_64_vio_hv.c @@ -475,8 +475,10 @@ long kvmppc_rm_h_put_tce_indirect(struct kvm_vcpu *vcpu, ua = 0; if (kvmppc_gpa_to_ua(vcpu->kvm, tce & ~(TCE_PCI_READ | TCE_PCI_WRITE), - &ua, NULL)) - return H_PARAMETER; + &ua, NULL)) { + ret = H_PARAMETER; + goto unlock_exit; + } list_for_each_entry_lockless(stit, &stt->iommu_tables, next) { ret = kvmppc_rm_tce_iommu_map(vcpu->kvm, -- 2.20.1