From: Borislav Petkov Date: Wed, 6 Nov 2013 14:46:02 +0000 (+0100) Subject: kvm, cpuid: Fix sparse warning X-Git-Tag: accepted/tizen/common/20141203.182822~1116^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b2ca42267fe8c4e909312f2b83dfef882cf6234;p=platform%2Fkernel%2Flinux-arm64.git kvm, cpuid: Fix sparse warning We need to copy padding to kernel space first before looking at it. Reported-by: kbuild test robot Signed-off-by: Borislav Petkov Signed-off-by: Gleb Natapov --- diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 8f66fba..c697625 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, __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;