]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: PPC: Book3S: Improve KVM reference counting
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Thu, 21 Feb 2019 03:44:14 +0000 (14:44 +1100)
committerPaul Mackerras <paulus@ozlabs.org>
Fri, 22 Feb 2019 01:51:02 +0000 (12:51 +1100)
commite8374bd29a2843f107d8e0a97b1527a1451c3c9b
tree19a4029961cc474e7ca8231adcb78b998a62c44a
parente9787596330b91bb616454b0123e78185a5f7534
KVM: PPC: Book3S: Improve KVM reference counting

The anon fd's ops releases the KVM reference in the release hook.
However we reference the KVM object after we create the fd so there is
small window when the release function can be called and
dereferenced the KVM object which potentially may free it.

It is not a problem at the moment as the file is created and KVM is
referenced under the KVM lock and the release function obtains the same
lock before dereferencing the KVM (although the lock is not held when
calling kvm_put_kvm()) but it is potentially fragile against future changes.

This references the KVM object before creating a file.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/kvm/book3s_64_vio.c