]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: let kvm_destroy_vm_debugfs clean up vCPU debugfs directories
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 4 Jun 2020 13:16:52 +0000 (15:16 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 4 Jun 2020 15:00:54 +0000 (11:00 -0400)
commit2e4d8a641afcfe02959209e3b3e80a5c0073ebee
tree3e3036834486e7506c7293e92649b9fab3119620
parent18c1b47a2b837d6d5ab65dd432f0f8e680010730
KVM: let kvm_destroy_vm_debugfs clean up vCPU debugfs directories

After commit c363e83 ("KVM: x86: move kvm_create_vcpu_debugfs after
last failure point") we are creating the pre-vCPU debugfs files
after the creation of the vCPU file descriptor.  This makes it
possible for userspace to reach kvm_vcpu_release before
kvm_create_vcpu_debugfs has finished.  The vcpu->debugfs_dentry
then does not have any associated inode anymore, and this causes
a NULL-pointer dereference in debugfs_create_file.

The solution is simply to avoid removing the files; they are
cleaned up when the VM file descriptor is closed (and that must be
after KVM_CREATE_VCPU returns).  We can stop storing the dentry
in struct kvm_vcpu too, because it is not needed anywhere after
kvm_create_vcpu_debugfs returns.

Reported-by: syzbot+705f4401d5a93a59b87d@syzkaller.appspotmail.com
Fixes: c363e83dc339 ("KVM: x86: move kvm_create_vcpu_debugfs after last failure point")
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/arm64/kvm/arm.c
arch/x86/kvm/debugfs.c
include/linux/kvm_host.h
virt/kvm/kvm_main.c