Skip to content

Commit

Permalink
kvm, cpuid: Fix sparse warning
Browse files Browse the repository at this point in the history
We need to copy padding to kernel space first before looking at it.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
  • Loading branch information
Borislav Petkov authored and Gleb Natapov committed Nov 7, 2013
1 parent a890b6f commit 1b2ca42
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions arch/x86/kvm/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 1b2ca42

Please sign in to comment.