From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52425C2D0A3 for ; Tue, 3 Nov 2020 18:19:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E477F20786 for ; Tue, 3 Nov 2020 18:19:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ijWnBu82" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729065AbgKCSTO (ORCPT ); Tue, 3 Nov 2020 13:19:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21586 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729075AbgKCSTN (ORCPT ); Tue, 3 Nov 2020 13:19:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604427552; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d/hWu+N+wOTe562y79WDJHfHrZYi3ZnAqNsDEEWdHNM=; b=ijWnBu820WSzt/327gvE1FiZssZ8/BjoJvpqW9BxGPzA7jNGMYJnM5UqpbSiRkHdDcdwrv bJ+ulpTuyMn3C08VdgFlzvx0EQySIa34nOmFv6ZmArj1UbFQkMF8zQqOWJR+JLR7i+msh+ lbgcfjmkjYKP+kqvyveOGC9AMnED148= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-23-VCYS1BjpMkqsO61RFv8BAQ-1; Tue, 03 Nov 2020 13:19:08 -0500 X-MC-Unique: VCYS1BjpMkqsO61RFv8BAQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2D7751009E23; Tue, 3 Nov 2020 18:19:07 +0000 (UTC) Received: from w520.home (ovpn-112-213.phx2.redhat.com [10.3.112.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4843A2C31E; Tue, 3 Nov 2020 18:19:03 +0000 (UTC) Date: Tue, 3 Nov 2020 11:19:02 -0700 From: Alex Williamson To: Dan Carpenter Cc: Diana Craciun , Cornelia Huck , Bharat Bhushan , Eric Auger , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH 1/2] vfio/fsl-mc: return -EFAULT if copy_to_user() fails Message-ID: <20201103111902.1ac78ae3@w520.home> In-Reply-To: <20201023113450.GH282278@mwanda> References: <20201023113450.GH282278@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Fri, 23 Oct 2020 14:34:50 +0300 Dan Carpenter wrote: > The copy_to_user() function returns the number of bytes remaining to be > copied, but this code should return -EFAULT. > > Fixes: df747bcd5b21 ("vfio/fsl-mc: Implement VFIO_DEVICE_GET_REGION_INFO ioctl call") > Signed-off-by: Dan Carpenter > --- > drivers/vfio/fsl-mc/vfio_fsl_mc.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) Applied this and the following patch to vfio for-linus branch with Diana's acks for v5.10. Thanks, Alex > diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c > index 0113a980f974..21f22e3da11f 100644 > --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c > +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c > @@ -248,7 +248,9 @@ static long vfio_fsl_mc_ioctl(void *device_data, unsigned int cmd, > info.size = vdev->regions[info.index].size; > info.flags = vdev->regions[info.index].flags; > > - return copy_to_user((void __user *)arg, &info, minsz); > + if (copy_to_user((void __user *)arg, &info, minsz)) > + return -EFAULT; > + return 0; > } > case VFIO_DEVICE_GET_IRQ_INFO: > { > @@ -267,7 +269,9 @@ static long vfio_fsl_mc_ioctl(void *device_data, unsigned int cmd, > info.flags = VFIO_IRQ_INFO_EVENTFD; > info.count = 1; > > - return copy_to_user((void __user *)arg, &info, minsz); > + if (copy_to_user((void __user *)arg, &info, minsz)) > + return -EFAULT; > + return 0; > } > case VFIO_DEVICE_SET_IRQS: > {