KVM: Add missing debugfs cleanup in kvm_init error path
PATCH 1/1 KVM: Add missing debugfs cleanup in kvm_init error path
If any initialization after kvm_init_debug() fails the cleanup code did not remove the debugfs entries. Therefore, the corresponding debugfs entries where still alive but the backing fops are already freed, creating a use-after-free scenario. Fix this by removing the debugfs entries if vfio init fails.
--- virt/kvm/kvm_main.c | 1 + 1 file changed, 1 insertion(+)
virt/kvm/kvm_main.c +1 -0
@@ -6559,6 +6559,7 @@ int kvm_init(unsigned vcpu_size, unsigned vcpu_align, struct module *module) err_gmem:kvm_vfio_ops_exit (); err_vfio: +debugfs_remove_recursive (kvm_debugfs_dir);kvm_async_pf_deinit (); err_async_pf:kvm_irqfd_exit ();
Signature · 1 line
2.53.0
Sean Christopherson
reviewerQuoted 5 lines · Steffen Eiden
If any initialization after
kvm_init_debug()fails the cleanup code did not remove the debugfs entries. Therefore, the corresponding debugfs entries where still alive but the backing fops are already freed, creating a use-after-free scenario. Fix this by removing the debugfs entries if vfio init fails.
Already posted, and applied locally on my end.
https://lore.kernel.org/all/20260706095910.39798-1-leixiang%40kylinos.cn
Quoted 10 lines · Sean Christopherson
Quoted 5 lines · Steffen Eiden
If any initialization after
kvm_init_debug()fails the cleanup code did not remove the debugfs entries. Therefore, the corresponding debugfs entries where still alive but the backing fops are already freed, creating a use-after-free scenario. Fix this by removing the debugfs entries if vfio init fails.Already posted, and applied locally on my end.
https://lore.kernel.org/all/20260706095910.39798-1-leixiang%40kylinos.cn
Oh sorry, I missed that.