Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a50d64d6 authored by Xiao Guangrong's avatar Xiao Guangrong Committed by Avi Kivity
Browse files

KVM: fix missing check for memslot flags



Check flags when memslot is registered from userspace as Avi's suggestion

Signed-off-by: default avatarXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 8e3d9d06
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -678,6 +678,14 @@ void update_memslots(struct kvm_memslots *slots, struct kvm_memory_slot *new)
	slots->generation++;
	slots->generation++;
}
}


static int check_memory_region_flags(struct kvm_userspace_memory_region *mem)
{
	if (mem->flags & ~KVM_MEM_LOG_DIRTY_PAGES)
		return -EINVAL;

	return 0;
}

/*
/*
 * Allocate some memory and give it an address in the guest physical address
 * Allocate some memory and give it an address in the guest physical address
 * space.
 * space.
@@ -698,6 +706,10 @@ int __kvm_set_memory_region(struct kvm *kvm,
	struct kvm_memory_slot old, new;
	struct kvm_memory_slot old, new;
	struct kvm_memslots *slots, *old_memslots;
	struct kvm_memslots *slots, *old_memslots;


	r = check_memory_region_flags(mem);
	if (r)
		goto out;

	r = -EINVAL;
	r = -EINVAL;
	/* General sanity checks */
	/* General sanity checks */
	if (mem->memory_size & (PAGE_SIZE - 1))
	if (mem->memory_size & (PAGE_SIZE - 1))