diff options
author | David Matlack <dmatlack@google.com> | 2022-03-03 18:33:27 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-04-08 14:40:38 +0200 |
commit | eccfee44949d2d8ac9675d5b3f29cacaed5ba6c8 (patch) | |
tree | aa8b0b45d1c2cb66f8d6c89bf5f736c5c8e43414 /tools/arch/h8300 | |
parent | 09c771c45c1243e295470225aaee726693fdc242 (diff) | |
download | linux-stable-eccfee44949d2d8ac9675d5b3f29cacaed5ba6c8.tar.gz linux-stable-eccfee44949d2d8ac9675d5b3f29cacaed5ba6c8.tar.bz2 linux-stable-eccfee44949d2d8ac9675d5b3f29cacaed5ba6c8.zip |
KVM: Prevent module exit until all VMs are freed
commit 5f6de5cbebee925a612856fce6f9182bb3eee0db upstream.
Tie the lifetime the KVM module to the lifetime of each VM via
kvm.users_count. This way anything that grabs a reference to the VM via
kvm_get_kvm() cannot accidentally outlive the KVM module.
Prior to this commit, the lifetime of the KVM module was tied to the
lifetime of /dev/kvm file descriptors, VM file descriptors, and vCPU
file descriptors by their respective file_operations "owner" field.
This approach is insufficient because references grabbed via
kvm_get_kvm() do not prevent closing any of the aforementioned file
descriptors.
This fixes a long standing theoretical bug in KVM that at least affects
async page faults. kvm_setup_async_pf() grabs a reference via
kvm_get_kvm(), and drops it in an asynchronous work callback. Nothing
prevents the VM file descriptor from being closed and the KVM module
from being unloaded before this callback runs.
Fixes: af585b921e5d ("KVM: Halt vcpu if page it tries to access is swapped out")
Fixes: 3d3aab1b973b ("KVM: set owner of cpu and vm file operations")
Cc: stable@vger.kernel.org
Suggested-by: Ben Gardon <bgardon@google.com>
[ Based on a patch from Ben implemented for Google's kernel. ]
Signed-off-by: David Matlack <dmatlack@google.com>
Message-Id: <20220303183328.1499189-2-dmatlack@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/arch/h8300')
0 files changed, 0 insertions, 0 deletions