Commit e125e7b6 authored by Jan Kiszka's avatar Jan Kiszka Committed by Avi Kivity

KVM: Fix KVM_GET_MSR_INDEX_LIST

So far, KVM copied the emulated_msrs (only MSR_IA32_MISC_ENABLE) to a
wrong address in user space due to broken pointer arithmetic. This
caused subtle corruption up there (missing MSR_IA32_MISC_ENABLE had
probably no practical relevance). Moreover, the size check for the
user-provided kvm_msr_list forgot about emulated MSRs.

Cc: stable@kernel.org
Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 90bc1a65
...@@ -1079,14 +1079,13 @@ long kvm_arch_dev_ioctl(struct file *filp, ...@@ -1079,14 +1079,13 @@ long kvm_arch_dev_ioctl(struct file *filp,
if (copy_to_user(user_msr_list, &msr_list, sizeof msr_list)) if (copy_to_user(user_msr_list, &msr_list, sizeof msr_list))
goto out; goto out;
r = -E2BIG; r = -E2BIG;
if (n < num_msrs_to_save) if (n < msr_list.nmsrs)
goto out; goto out;
r = -EFAULT; r = -EFAULT;
if (copy_to_user(user_msr_list->indices, &msrs_to_save, if (copy_to_user(user_msr_list->indices, &msrs_to_save,
num_msrs_to_save * sizeof(u32))) num_msrs_to_save * sizeof(u32)))
goto out; goto out;
if (copy_to_user(user_msr_list->indices if (copy_to_user(user_msr_list->indices + num_msrs_to_save,
+ num_msrs_to_save * sizeof(u32),
&emulated_msrs, &emulated_msrs,
ARRAY_SIZE(emulated_msrs) * sizeof(u32))) ARRAY_SIZE(emulated_msrs) * sizeof(u32)))
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment