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: stable@vger.kernel.org # v4.11+
Fixes: 121f80ba68
("KVM: PPC: VFIO: Add in-kernel acceleration for VFIO")
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
This commit is contained in:
parent
e442737239
commit
ddfd151f3d
|
@ -660,8 +660,10 @@ long kvmppc_h_put_tce_indirect(struct kvm_vcpu *vcpu,
|
||||||
}
|
}
|
||||||
tce = be64_to_cpu(tce);
|
tce = be64_to_cpu(tce);
|
||||||
|
|
||||||
if (kvmppc_tce_to_ua(vcpu->kvm, tce, &ua))
|
if (kvmppc_tce_to_ua(vcpu->kvm, tce, &ua)) {
|
||||||
return H_PARAMETER;
|
ret = H_PARAMETER;
|
||||||
|
goto unlock_exit;
|
||||||
|
}
|
||||||
|
|
||||||
list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
|
list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
|
||||||
ret = kvmppc_tce_iommu_map(vcpu->kvm, stt,
|
ret = kvmppc_tce_iommu_map(vcpu->kvm, stt,
|
||||||
|
|
|
@ -556,8 +556,10 @@ long kvmppc_rm_h_put_tce_indirect(struct kvm_vcpu *vcpu,
|
||||||
unsigned long tce = be64_to_cpu(((u64 *)tces)[i]);
|
unsigned long tce = be64_to_cpu(((u64 *)tces)[i]);
|
||||||
|
|
||||||
ua = 0;
|
ua = 0;
|
||||||
if (kvmppc_rm_tce_to_ua(vcpu->kvm, tce, &ua, NULL))
|
if (kvmppc_rm_tce_to_ua(vcpu->kvm, tce, &ua, NULL)) {
|
||||||
return H_PARAMETER;
|
ret = H_PARAMETER;
|
||||||
|
goto unlock_exit;
|
||||||
|
}
|
||||||
|
|
||||||
list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
|
list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
|
||||||
ret = kvmppc_rm_tce_iommu_map(vcpu->kvm, stt,
|
ret = kvmppc_rm_tce_iommu_map(vcpu->kvm, stt,
|
||||||
|
|
Loading…
Reference in New Issue