From: Kunkun Jiang <jiangkunkun@huawei.com>
To: Paolo Bonzini <pbonzini@redhat.com>, <kvm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: <wanghaibin.wang@huawei.com>, Keqian Zhu <zhukeqian1@huawei.com>
Subject: [PATCH] kvm: Fixes lack of KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 enabled check
Date: Tue, 12 Jan 2021 17:29:42 +0800 [thread overview]
Message-ID: <20210112092942.2310-1-jiangkunkun@huawei.com> (raw)
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
next reply other threads:[~2021-01-12 9:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-12 9:29 Kunkun Jiang [this message]
2021-01-12 10:20 ` [PATCH] kvm: Fixes lack of KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 enabled check Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210112092942.2310-1-jiangkunkun@huawei.com \
--to=jiangkunkun@huawei.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=wanghaibin.wang@huawei.com \
--cc=zhukeqian1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.