Skip to contentSkip to conversation

FAILED: patch "[PATCH] KVM: PPC: Book3S: Fix incorrect guest-to-user-translation" failed to apply to 4.19-stable tree

PATCH [email protected] 2 participants 3 messages Sep 3, 2019 – Sep 4, 2019

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From ddfd151f3def9258397fcde7a372205a2d661903 Mon Sep 17 00:00:00 2001
From: Alexey Kardashevskiy <[email protected]>
Date: Mon, 26 Aug 2019 14:55:20 +1000
Subject: [PATCH] KVM: PPC: Book3S: Fix incorrect guest-to-user-translation
error handling

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 [email protected] # v4.11+
Fixes 121f80ba68f1 ("KVM: PPC: VFIO: Add in-kernel acceleration for VFIO")
arch/powerpc/kvm/book3s_64_vio.c +4 -2
index e99a14798ab0..c4b606fe73eb 100644
@@ -660,8 +660,10 @@ long kvmppc_h_put_tce_indirect(struct kvm_vcpu *vcpu,
 		}
 		tce = be64_to_cpu(tce);
 
-		if (kvmppc_tce_to_ua(vcpu->kvm, tce, &ua))
-			return H_PARAMETER;
+		if (kvmppc_tce_to_ua(vcpu->kvm, tce, &ua)) {
+			ret = H_PARAMETER;
+			goto unlock_exit;
+		}
 
 		list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
 			ret = kvmppc_tce_iommu_map(vcpu->kvm, stt,
arch/powerpc/kvm/book3s_64_vio_hv.c +4 -2
index f50bbeedfc66..b4f20f13b860 100644
@@ -556,8 +556,10 @@ long kvmppc_rm_h_put_tce_indirect(struct kvm_vcpu *vcpu,
 		unsigned long tce = be64_to_cpu(((u64 *)tces)[i]);
 
 		ua = 0;
-		if (kvmppc_rm_tce_to_ua(vcpu->kvm, tce, &ua, NULL))
-			return H_PARAMETER;
+		if (kvmppc_rm_tce_to_ua(vcpu->kvm, tce, &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, stt,
maintainer
#1 lore raw
Quoted 5 lines · On Tue, Sep 03, 2019 at 08:40:13PM +0200, [email protected] wrote:

The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

I've fixed it up for 4.19 and 4.14. The issue was mostly due to missing 2001825efcea7 ("KVM: PPC: Book3S HV: Avoid lockdep debugging in TCE realmode handlers").

--
Thanks,
Sasha

author maintainer
#2 lore raw
Quoted 10 lines · Sasha Levin
Quoted 5 lines · On Tue, Sep 03, 2019 at 08:40:13PM +0200, [email protected] wrote:

The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

I've fixed it up for 4.19 and 4.14. The issue was mostly due to missing 2001825efcea7 ("KVM: PPC: Book3S HV: Avoid lockdep debugging in TCE realmode handlers").

Thanks for fixing up all of these FAILED: reports and adding them to the queues.

greg k-h