Skip to content

Commit f4501e8

Browse files
committed
Merge tag 'kvm-x86-fixes-6.10-11' of https://github.com/kvm-x86/linux into HEAD
KVM Xen: Fix a bug where KVM fails to check the validity of an incoming userspace virtual address and tries to activate a gfn_to_pfn_cache with a kernel address.
2 parents 1c5a0b5 + ebbdf37 commit f4501e8

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

arch/x86/kvm/xen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
741741
} else {
742742
void __user * hva = u64_to_user_ptr(data->u.shared_info.hva);
743743

744-
if (!PAGE_ALIGNED(hva) || !access_ok(hva, PAGE_SIZE)) {
744+
if (!PAGE_ALIGNED(hva)) {
745745
r = -EINVAL;
746746
} else if (!hva) {
747747
kvm_gpc_deactivate(&kvm->arch.xen.shinfo_cache);

virt/kvm/pfncache.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,9 @@ int kvm_gpc_activate(struct gfn_to_pfn_cache *gpc, gpa_t gpa, unsigned long len)
430430

431431
int kvm_gpc_activate_hva(struct gfn_to_pfn_cache *gpc, unsigned long uhva, unsigned long len)
432432
{
433+
if (!access_ok((void __user *)uhva, len))
434+
return -EINVAL;
435+
433436
return __kvm_gpc_activate(gpc, INVALID_GPA, uhva, len);
434437
}
435438

0 commit comments

Comments
 (0)