On 3/2/22 18:47, Sean Christopherson wrote:
+ /* This is safe, since we have a reference from open(). */
+ __module_get(THIS_MODULE);
This isn't sufficient. For x86, it only grabs a reference to kvm.ko, not the
vendor module. Instead, we can do:
if (!try_module_get(kvm_chardev_ops.owner))
return ERR_PTR(-EINVAL);
And then on top, revert commit revert ("KVM: set owner of cpu and vm file operations").
vCPUs file descriptors hold reference to the VM, which means they indirectly hold a
reference to the module. So once the "real" bug of struct kvm not holding a reference
to the module is fixed, grabbing a reference when a VM/vCPU inode is opened becomes
unnecessary.
Got it, I'll wait for David to post the right thing. :)
Paolo