Skip to content

Commit 4cad67f

Browse files
mstsirkinMarc Zyngier
authored andcommitted
arm/arm64: 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. Cc: [email protected] Acked-by: Christoffer Dall <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent fd451b9 commit 4cad67f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

arch/arm/kvm/guest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int get_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
161161
u64 val;
162162

163163
val = kvm_arm_timer_get_reg(vcpu, reg->id);
164-
return copy_to_user(uaddr, &val, KVM_REG_SIZE(reg->id));
164+
return copy_to_user(uaddr, &val, KVM_REG_SIZE(reg->id)) ? -EFAULT : 0;
165165
}
166166

167167
static unsigned long num_core_regs(void)

arch/arm64/kvm/guest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static int get_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
194194
u64 val;
195195

196196
val = kvm_arm_timer_get_reg(vcpu, reg->id);
197-
return copy_to_user(uaddr, &val, KVM_REG_SIZE(reg->id));
197+
return copy_to_user(uaddr, &val, KVM_REG_SIZE(reg->id)) ? -EFAULT : 0;
198198
}
199199

200200
/**

0 commit comments

Comments
 (0)