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

Commit 1b2ca422 authored by Borislav Petkov's avatar Borislav Petkov Committed by Gleb Natapov
Browse files

kvm, cpuid: Fix sparse warning



We need to copy padding to kernel space first before looking at it.

Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Signed-off-by: default avatarGleb Natapov <gleb@redhat.com>
parent a890b6fe
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -564,6 +564,7 @@ static bool sanity_check_entries(struct kvm_cpuid_entry2 __user *entries,
				 __u32 num_entries, unsigned int ioctl_type)
{
	int i;
	__u32 pad[3];

	if (ioctl_type != KVM_GET_EMULATED_CPUID)
		return false;
@@ -577,9 +578,10 @@ static bool sanity_check_entries(struct kvm_cpuid_entry2 __user *entries,
	 * sheds a tear.
	 */
	for (i = 0; i < num_entries; i++) {
		if (entries[i].padding[0] ||
		    entries[i].padding[1] ||
		    entries[i].padding[2])
		if (copy_from_user(pad, entries[i].padding, sizeof(pad)))
			return true;

		if (pad[0] || pad[1] || pad[2])
			return true;
	}
	return false;