KVM: x86: Don't re-acquire SRCU lock in complete_emulated_io()
authorSean Christopherson <seanjc@google.com>
Fri, 15 Apr 2022 00:43:41 +0000 (00:43 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Apr 2022 12:41:15 +0000 (14:41 +0200)
commitdaa3f16e8ce1ee3fef7496eba520d5661cca01fd
tree64441865fef6a548ceba77095c27a8fbfd9971bb
parent3a59b94b2805fdf82f84626c49da520315e6f65a
KVM: x86: Don't re-acquire SRCU lock in complete_emulated_io()

commit 2d08935682ac5f6bfb70f7e6844ec27d4a245fa4 upstream.

Don't re-acquire SRCU in complete_emulated_io() now that KVM acquires the
lock in kvm_arch_vcpu_ioctl_run().  More importantly, don't overwrite
vcpu->srcu_idx.  If the index acquired by complete_emulated_io() differs
from the one acquired by kvm_arch_vcpu_ioctl_run(), KVM will effectively
leak a lock and hang if/when synchronize_srcu() is invoked for the
relevant grace period.

Fixes: 8d25b7beca7e ("KVM: x86: pull kvm->srcu read-side to kvm_arch_vcpu_ioctl_run")
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20220415004343.2203171-2-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/x86.c