Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp52616pxb; Mon, 2 Nov 2020 13:47:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7LD8iKRsAcWXzkWDspRZHRKJl7lINj5LgmHjTYVNRgl/85A/IHGeUsZ9PLu/dNYAbJo7W X-Received: by 2002:aa7:da44:: with SMTP id w4mr6748889eds.131.1604353645497; Mon, 02 Nov 2020 13:47:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604353645; cv=none; d=google.com; s=arc-20160816; b=tuOB+EC9hE28oTlSNkgDfOAGpuoCKwTk0PJicKQXHlJkRFCPT+yyWmxGY9OQJMBUCK qf/vjP3prBmv2EfCnvQTDgXw59urYOJXwPtzb968q5CdKyFgvc1kqPoRnJOTgEMaJNHn uANjhfjIuYDCgPGU+pkTHbBnfa4mccxQz0YD1aNW/DSZFLYi/XtKVASm085vd2CfnZ3V V/kx/Xll+3pZpkFcxQsIiroB8i4oEXGCpsr6AQ/5UblINU2wC90B2c2rJGvdE3BS1hf9 hKd1oR2Ds7ftVp+CJ+C+ojjTb9FF3xu0APvwtwdhFSeLGNlLB5NU2LeK06XeeaI66xZ+ Mc3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=cTFZ8lzIl2cNFfLo0OSYv8YB3iqFe9fcgW+Rx9EOOi4=; b=AQAnbDxENq1muk8X2CsMTB6h2Ih8rFG+nyXn7cMfPK3ErhVvcaCrfSEv2+n/uZKJV0 yYm+5iEPa5SEXr/XG5iYLbAf3BWvhmjUytJieNSngNlVQR3/XmE9xBJILFa1Zsz/O8TN TLVWDKMHa/EacUUCyOYEdkdV7pN5O+tzhnKQyMedARxBo3z0yErtx2exs41TYE1pJbfl D/QJOB0ye1JNPexEzbGxW1czH4E4OnbV3kOOkPTsWzMCyEyXL0X4uQlDogwd5g2l1NdI 9cqS4AAxOgCbK3HqRath98GNgoFzaftI4VW9HW3AJ+OxKDkQ+WSNO0CFQXLi6+WuQ4zK Hirw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ixLRqe3d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ci4si1047628ejb.436.2020.11.02.13.47.01; Mon, 02 Nov 2020 13:47:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ixLRqe3d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725829AbgKBVpp (ORCPT + 99 others); Mon, 2 Nov 2020 16:45:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46845 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725766AbgKBVpp (ORCPT ); Mon, 2 Nov 2020 16:45:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604353544; 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=cTFZ8lzIl2cNFfLo0OSYv8YB3iqFe9fcgW+Rx9EOOi4=; b=ixLRqe3dUgHMF20Sd+3zcCGcCwLODISR9/bx3h2LJhWVGUDbpBl86YwlEv79yKpVHqGSwk 46ABbEz/vtvOAguSIxtENjfyDh7dZms3P/jXYj9WDQxbNEI5BQEQpBkA3x27SQFS5CQYJj 8+j03FxwHJ3CRfTKBRmsIniLASXrG5Q= 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-511-20h8hIN2MDemDpI5kdMj1Q-1; Mon, 02 Nov 2020 16:45:42 -0500 X-MC-Unique: 20h8hIN2MDemDpI5kdMj1Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C123D802B61; Mon, 2 Nov 2020 21:45:40 +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 49A0C68433; Mon, 2 Nov 2020 21:45:37 +0000 (UTC) Date: Mon, 2 Nov 2020 14:45:36 -0700 From: Alex Williamson To: Diana Craciun Cc: Dan Carpenter , 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: <20201102144536.42a0e066@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.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks, Dan. Diana, can I get an ack for this? Thanks, Alex 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(-) > > 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: > {