diff options
author | Borislav Petkov <bp@suse.de> | 2013-11-06 09:46:02 -0500 |
---|---|---|
committer | Gleb Natapov <gleb@redhat.com> | 2013-11-07 05:27:46 -0500 |
commit | 1b2ca42267fe8c4e909312f2b83dfef882cf6234 (patch) | |
tree | 227101073f1780d1b763e9e04389cf1fac3e520a /arch/x86/kvm/cpuid.c | |
parent | a890b6fefd1775a1c3a7d8fe8af968a3a7b23c04 (diff) |
kvm, cpuid: Fix sparse warning
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>
Diffstat (limited to 'arch/x86/kvm/cpuid.c')
-rw-r--r-- | arch/x86/kvm/cpuid.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 8f66fba804e4..c6976257eff5 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c | |||
@@ -564,6 +564,7 @@ static bool sanity_check_entries(struct kvm_cpuid_entry2 __user *entries, | |||
564 | __u32 num_entries, unsigned int ioctl_type) | 564 | __u32 num_entries, unsigned int ioctl_type) |
565 | { | 565 | { |
566 | int i; | 566 | int i; |
567 | __u32 pad[3]; | ||
567 | 568 | ||
568 | if (ioctl_type != KVM_GET_EMULATED_CPUID) | 569 | if (ioctl_type != KVM_GET_EMULATED_CPUID) |
569 | return false; | 570 | return false; |
@@ -577,9 +578,10 @@ static bool sanity_check_entries(struct kvm_cpuid_entry2 __user *entries, | |||
577 | * sheds a tear. | 578 | * sheds a tear. |
578 | */ | 579 | */ |
579 | for (i = 0; i < num_entries; i++) { | 580 | for (i = 0; i < num_entries; i++) { |
580 | if (entries[i].padding[0] || | 581 | if (copy_from_user(pad, entries[i].padding, sizeof(pad))) |
581 | entries[i].padding[1] || | 582 | return true; |
582 | entries[i].padding[2]) | 583 | |
584 | if (pad[0] || pad[1] || pad[2]) | ||
583 | return true; | 585 | return true; |
584 | } | 586 | } |
585 | return false; | 587 | return false; |