Skip to content

Commit bd218bc

Browse files
wildea01chazy
authored andcommitted
KVM: ARM/arm64: return -EFAULT if copy_from_user fails in set_timer_reg
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>
1 parent 18d4576 commit bd218bc

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎arch/arm/kvm/guest.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static int set_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
163163

164164
ret = copy_from_user(&val, uaddr, KVM_REG_SIZE(reg->id));
165165
if (ret != 0)
166-
return ret;
166+
return -EFAULT;
167167

168168
return kvm_arm_timer_set_reg(vcpu, reg->id, val);
169169
}

‎arch/arm64/kvm/guest.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static int set_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
174174

175175
ret = copy_from_user(&val, uaddr, KVM_REG_SIZE(reg->id));
176176
if (ret != 0)
177-
return ret;
177+
return -EFAULT;
178178

179179
return kvm_arm_timer_set_reg(vcpu, reg->id, val);
180180
}

0 commit comments

Comments
 (0)