On Tue, Jul 11, 2023 at 04:01:25PM -0700, Sean Christopherson wrote: > 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@xxxxxxxxxxxxx> > Closes: https://lore.kernel.org/all/CAC_GQSr3xzZaeZt85k_RCBd5kfiOve8qXo7a81Cq53LuVQ5r=Q@xxxxxxxxxxxxxx > Cc: stable@xxxxxxxxxxxxxxx > Cc: Kees Cook <keescook@xxxxxxxxxxxx> > Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx> Thanks for preparing this! Looks like the common get/put code pattern, so I can review this patch, unlike the rest of the series. :) Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx> -- Kees Cook