KVM: ARM/arm64: return -EFAULT if copy_from_user fails in set_timer_reg
authorWill Deacon <will.deacon@arm.com>
Tue, 26 Aug 2014 14:13:23 +0000 (15:13 +0100)
committerChristoffer Dall <christoffer.dall@linaro.org>
Wed, 27 Aug 2014 20:49:45 +0000 (22:49 +0200)
We currently return the number of bytes not copied if set_timer_reg
fails, which is almost certainly not what userspace would like.

This patch returns -EFAULT instead.

Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
arch/arm/kvm/guest.c
arch/arm64/kvm/guest.c

index 813e492586909e006ccdcb1f3dc752729cc322ef..cc0b78769bd8ab40e5237b88aaedb14068f767e0 100644 (file)
@@ -163,7 +163,7 @@ static int set_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
 
        ret = copy_from_user(&val, uaddr, KVM_REG_SIZE(reg->id));
        if (ret != 0)
-               return ret;
+               return -EFAULT;
 
        return kvm_arm_timer_set_reg(vcpu, reg->id, val);
 }
index 8d1ec2887a266b3addf62ae63adea8729a057ae7..76794692c20b9463717430f01b66b2e73f36bc23 100644 (file)
@@ -174,7 +174,7 @@ static int set_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
 
        ret = copy_from_user(&val, uaddr, KVM_REG_SIZE(reg->id));
        if (ret != 0)
-               return ret;
+               return -EFAULT;
 
        return kvm_arm_timer_set_reg(vcpu, reg->id, val);
 }