Skip to content

Commit 8c49767

Browse files
Philipp Stannersean-jc
authored andcommitted
KVM: s390: Harden copying of userspace-array against overflow
guestdbg.c utilizes memdup_user() to copy a userspace array. This, currently, does not check for an overflow. Use the new wrapper memdup_array_user() to copy the array more safely. Note, KVM explicitly checks the number of entries before duplicating the array, i.e. adding the overflow check should be a glorified nop. Suggested-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Philipp Stanner <pstanner@redhat.com> Acked-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com> Link: https://lore.kernel.org/r/20231102181526.43279-3-pstanner@redhat.com [sean: call out that KVM pre-checks the number of entries] Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 573cc0e commit 8c49767

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

arch/s390/kvm/guestdbg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
213213
else if (dbg->arch.nr_hw_bp > MAX_BP_COUNT)
214214
return -EINVAL;
215215

216-
bp_data = memdup_user(dbg->arch.hw_bp,
217-
sizeof(*bp_data) * dbg->arch.nr_hw_bp);
216+
bp_data = memdup_array_user(dbg->arch.hw_bp, dbg->arch.nr_hw_bp,
217+
sizeof(*bp_data));
218218
if (IS_ERR(bp_data))
219219
return PTR_ERR(bp_data);
220220

0 commit comments

Comments
 (0)