arm/kvm: fix ioctl error handling
Subsystems (5)
PATCH 1/1 arm/kvm: fix ioctl error handling
Calling return copy_to_user(...) in an ioctl will not do the right thing if there's a pagefault:copy_to_user returns the number of bytes not copied in this case.
Fix up kvm to do
return copy_to_user(...)) ? -EFAULT : 0;
everywhere.
Signed-off-by Michael S. Tsirkin <[email protected]>
---
Compiled only.
arch/arm/kvm/guest.c | 2 +- arch/arm64/kvm/guest.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/kvm/guest.c +1 -1
@@ -161,7 +161,7 @@ static int get_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)u64 val; val =kvm_arm_timer_get_reg (vcpu, reg->id); -return copy_to_user (uaddr, &val,KVM_REG_SIZE (reg->id)); +return copy_to_user (uaddr, &val,KVM_REG_SIZE (reg->id)) ? -EFAULT :0 ; }static unsigned long num_core_regs (void )
arch/arm64/kvm/guest.c +1 -1
@@ -194,7 +194,7 @@ static int get_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)u64 val; val =kvm_arm_timer_get_reg (vcpu, reg->id); -return copy_to_user (uaddr, &val,KVM_REG_SIZE (reg->id)); +return copy_to_user (uaddr, &val,KVM_REG_SIZE (reg->id)) ? -EFAULT :0 ; }/**
Signature · 1 line
MST
Quoted 5 lines · Michael S. Tsirkin
Calling return
copy_to_user(...)in an ioctl will not do the right thing if there's a pagefault:copy_to_userreturns the number of bytes not copied in this case.
Quoted 7 lines
Fix up kvm to do
return copy_to_user(...)) ? -EFAULT : 0;everywhere.
Signed-off-by Michael S. Tsirkin <[email protected]>
Acked-by Christoffer Dall <[email protected]>