kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kvm: Fixes lack of KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 enabled check
@ 2021-01-12  9:29 Kunkun Jiang
  2021-01-12 10:20 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Kunkun Jiang @ 2021-01-12  9:29 UTC (permalink / raw)
  To: Paolo Bonzini, kvm, linux-kernel; +Cc: wanghaibin.wang, Keqian Zhu

The KVM_CLEAR_DIRTY_LOG ioctl lacks the check whether the capability
KVM_CAP_MANUAL_DIRTY_LOG_PROTECT is enabled or not. This may cause
some problems if userspace calls the KVM_CLEAR_DIRTY_LOG ioctl, but
dose't enable this capability. So we'd better to add it.

Fixes: 2a31b9db15353 ("kvm: introduce manual dirty log reprotect")
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
---
 virt/kvm/kvm_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index fa9e3614d30e..8f5633d8a0e8 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1602,6 +1602,9 @@ static int kvm_clear_dirty_log_protect(struct kvm *kvm,
 	unsigned long *dirty_bitmap_buffer;
 	bool flush;
 
+	if (!kvm->manual_dirty_log_protect)
+		return -EPERM;
+
 	/* Dirty ring tracking is exclusive to dirty log tracking */
 	if (kvm->dirty_ring_size)
 		return -ENXIO;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-12 10:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12  9:29 [PATCH] kvm: Fixes lack of KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 enabled check Kunkun Jiang
2021-01-12 10:20 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).