kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: check steal time address when enable steal time
@ 2021-11-05  6:37 Li RongQing
  0 siblings, 0 replies; only message in thread
From: Li RongQing @ 2021-11-05  6:37 UTC (permalink / raw)
  To: kvm, lirongqing

check steal time address when enable steal time, disable steal
time if guest gives a wrong address, to avoid unnecessary
write/read invalid memory

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 arch/x86/kvm/x86.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 2686f2e..8c7f4f4 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3440,6 +3440,9 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 		if (data & KVM_STEAL_RESERVED_MASK)
 			return 1;
 
+		if (!kvm_vcpu_gfn_to_memslot(vcpu, data >> PAGE_SHIFT))
+			return 1;
+
 		vcpu->arch.st.msr_val = data;
 
 		if (!(data & KVM_MSR_ENABLED))
-- 
1.7.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-05  6:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-05  6:37 [PATCH] KVM: x86: check steal time address when enable steal time Li RongQing

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).