diff mbox series

[2/3] arch/s390/kvm: copy userspace-array safely

Message ID 20231102181526.43279-3-pstanner@redhat.com (mailing list archive)
State New, archived
Headers show
Series Use new wrappers to copy userspace arrays | expand

Commit Message

Philipp Stanner Nov. 2, 2023, 6:15 p.m. UTC
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.

Suggested-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Philipp Stanner <pstanner@redhat.com>
---
 arch/s390/kvm/guestdbg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Claudio Imbrenda Nov. 3, 2023, 11:55 a.m. UTC | #1
On Thu,  2 Nov 2023 19:15:25 +0100
Philipp Stanner <pstanner@redhat.com> wrote:

> 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.
> 
> Suggested-by: Dave Airlie <airlied@redhat.com>
> Signed-off-by: Philipp Stanner <pstanner@redhat.com>

Acked-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
>  arch/s390/kvm/guestdbg.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/s390/kvm/guestdbg.c b/arch/s390/kvm/guestdbg.c
> index 3765c4223bf9..80879fc73c90 100644
> --- a/arch/s390/kvm/guestdbg.c
> +++ b/arch/s390/kvm/guestdbg.c
> @@ -213,8 +213,8 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
>  	else if (dbg->arch.nr_hw_bp > MAX_BP_COUNT)
>  		return -EINVAL;
>  
> -	bp_data = memdup_user(dbg->arch.hw_bp,
> -			      sizeof(*bp_data) * dbg->arch.nr_hw_bp);
> +	bp_data = memdup_array_user(dbg->arch.hw_bp, dbg->arch.nr_hw_bp,
> +				    sizeof(*bp_data));
>  	if (IS_ERR(bp_data))
>  		return PTR_ERR(bp_data);
>
diff mbox series

Patch

diff --git a/arch/s390/kvm/guestdbg.c b/arch/s390/kvm/guestdbg.c
index 3765c4223bf9..80879fc73c90 100644
--- a/arch/s390/kvm/guestdbg.c
+++ b/arch/s390/kvm/guestdbg.c
@@ -213,8 +213,8 @@  int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
 	else if (dbg->arch.nr_hw_bp > MAX_BP_COUNT)
 		return -EINVAL;
 
-	bp_data = memdup_user(dbg->arch.hw_bp,
-			      sizeof(*bp_data) * dbg->arch.nr_hw_bp);
+	bp_data = memdup_array_user(dbg->arch.hw_bp, dbg->arch.nr_hw_bp,
+				    sizeof(*bp_data));
 	if (IS_ERR(bp_data))
 		return PTR_ERR(bp_data);