On Fri, Dec 01, 2023 at 04:51:55PM -0800, Sean Christopherson wrote: > There's one more wrinkle: this patch is buggy in that it doesn't ensure the liveliness > of KVM-the-module, i.e. nothing prevents userspace from unloading kvm.ko while VFIO > still holds a reference to a kvm structure, and so invoking ->put_kvm() could jump > into freed code. To fix that, KVM would also need to pass along a module pointer :-( Maybe we should be refcounting the struct file not the struct kvm? Then we don't need special helpers and it keeps the module alive correctly. Jason