Skip to content

Commit 5177604

Browse files
bonzinikees
authored andcommitted
kvm: x86: fix KVM_XEN_HVM_CONFIG ioctl
This ioctl is obsolete (it was used by Xenner as far as I know) but still let's not break it gratuitously... Its handler is copying directly into struct kvm. Go through a bounce buffer instead, with the added benefit that we can actually do something useful with the flags argument---the previous code was exiting with -EINVAL but still doing the copy. This technically is a userspace ABI breakage, but since no one should be using the ioctl, it's a good occasion to see if someone actually complains. Cc: [email protected] Cc: Kees Cook <[email protected]> Cc: Radim Krčmář <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent 4651573 commit 5177604

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

arch/x86/kvm/x86.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4238,13 +4238,14 @@ long kvm_arch_vm_ioctl(struct file *filp,
42384238
mutex_unlock(&kvm->lock);
42394239
break;
42404240
case KVM_XEN_HVM_CONFIG: {
4241+
struct kvm_xen_hvm_config xhc;
42414242
r = -EFAULT;
4242-
if (copy_from_user(&kvm->arch.xen_hvm_config, argp,
4243-
sizeof(struct kvm_xen_hvm_config)))
4243+
if (copy_from_user(&xhc, argp, sizeof(xhc)))
42444244
goto out;
42454245
r = -EINVAL;
4246-
if (kvm->arch.xen_hvm_config.flags)
4246+
if (xhc.flags)
42474247
goto out;
4248+
memcpy(&kvm->arch.xen_hvm_config, &xhc, sizeof(xhc));
42484249
r = 0;
42494250
break;
42504251
}

0 commit comments

Comments
 (0)