]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: Grab a reference to KVM for VM and vCPU stats file descriptors
authorSean Christopherson <seanjc@google.com>
Tue, 11 Jul 2023 23:01:25 +0000 (16:01 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Aug 2023 08:22:40 +0000 (10:22 +0200)
commit5883a4e8478d0b3ecf90262951d152ece0d5bb67
tree98d8b283ddce35d245da377b17d3faec1ca3b22e
parent0f7a2b567197798da7bfa2252f4485c0ca6c6266
KVM: Grab a reference to KVM for VM and vCPU stats file descriptors

commit eed3013faa401aae662398709410a59bb0646e32 upstream.

Grab a reference to KVM prior to installing VM and vCPU stats file
descriptors to ensure the underlying VM and vCPU objects are not freed
until the last reference to any and all stats fds are dropped.

Note, the stats paths manually invoke fd_install() and so don't need to
grab a reference before creating the file.

Fixes: ce55c049459c ("KVM: stats: Support binary stats retrieval for a VCPU")
Fixes: fcfe1baeddbf ("KVM: stats: Support binary stats retrieval for a VM")
Reported-by: Zheng Zhang <zheng.zhang@email.ucr.edu>
Closes: https://lore.kernel.org/all/CAC_GQSr3xzZaeZt85k_RCBd5kfiOve8qXo7a81Cq53LuVQ5r=Q@mail.gmail.com
Cc: stable@vger.kernel.org
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Message-Id: <20230711230131.648752-2-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
virt/kvm/kvm_main.c