提交 1b2ca422 编写于 作者: B Borislav Petkov 提交者: Gleb Natapov

kvm, cpuid: Fix sparse warning

We need to copy padding to kernel space first before looking at it.
Reported-by: Nkbuild test robot <fengguang.wu@intel.com>
Signed-off-by: NBorislav Petkov <bp@suse.de>
Signed-off-by: NGleb Natapov <gleb@redhat.com>
上级 a890b6fe
...@@ -564,6 +564,7 @@ static bool sanity_check_entries(struct kvm_cpuid_entry2 __user *entries, ...@@ -564,6 +564,7 @@ static bool sanity_check_entries(struct kvm_cpuid_entry2 __user *entries,
__u32 num_entries, unsigned int ioctl_type) __u32 num_entries, unsigned int ioctl_type)
{ {
int i; int i;
__u32 pad[3];
if (ioctl_type != KVM_GET_EMULATED_CPUID) if (ioctl_type != KVM_GET_EMULATED_CPUID)
return false; return false;
...@@ -577,9 +578,10 @@ static bool sanity_check_entries(struct kvm_cpuid_entry2 __user *entries, ...@@ -577,9 +578,10 @@ static bool sanity_check_entries(struct kvm_cpuid_entry2 __user *entries,
* sheds a tear. * sheds a tear.
*/ */
for (i = 0; i < num_entries; i++) { for (i = 0; i < num_entries; i++) {
if (entries[i].padding[0] || if (copy_from_user(pad, entries[i].padding, sizeof(pad)))
entries[i].padding[1] || return true;
entries[i].padding[2])
if (pad[0] || pad[1] || pad[2])
return true; return true;
} }
return false; return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册