Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp711437pxb; Tue, 3 Nov 2020 10:22:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwohOESApXAHnlQ0S7Al6wDFO54QqDKAxltOVykwryq8IpJNDUQbtEvM/Lh8zJpwvF4Fh5x X-Received: by 2002:a50:8ada:: with SMTP id k26mr22995615edk.281.1604427779117; Tue, 03 Nov 2020 10:22:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604427779; cv=none; d=google.com; s=arc-20160816; b=Dl1CoRN1MUkVA131sERNblxn7XWBZZL2KUKQu8WW0JNnt+dvExuRZW3+549iJt3Kso SKg840lIax344M2ud25p6RvN3S/pe+HtOuvpbpvrrCHHZ6h+H4R9eVayjB13WqvLpjFO OHMIF2a7k2iNHplFGs+pkuAI8EA6RjSgGQLZnSUNWOvv8TDMRXrrw59AmBcrzaRP3TTZ Oe0Xwcxz68b6Yxq6Agu7cI9tom13zOAOZi74KONQt6aqLo242Nrz6lDPTZSAQhw40tfJ 9ILWW1L69JpV6rdTxHEdaZ+U5DCTfwidhVTyHmsRdiQHZYQ5SuV0PttHuXBMLzyQISy7 Mc2g== 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=d/hWu+N+wOTe562y79WDJHfHrZYi3ZnAqNsDEEWdHNM=; b=ngC4gF1J5E7xBtOeZiwIBXWdOV+JrQgJGuJLw1RCkcH4uDX0wuiNUSlfumT9ycofV7 Zf/BpS25mRn98sMjKE3/7z9GhTS9AVaHXv8UaaZbiSR5O75t+bjYDvrFRR5hbIH601hj TMAqhLUE75ZKTHQXUa6KFEQpQWw/lRcOOmYj+cW/Ty0owcP23lGHopHXBAxHPbs8e7PJ ZXL85YehsXNot3w5Y9wSfhlzGTO36QafmKIBDPcpaKNf+lsLG1+aGPqxXjN75kXTVBZE 7kECI6vOJLcOVEXm05ROSrFa65VhRbigupl2Xn9KSuHLXfOA0YlIiqU3LonESO6yUV9h +m5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ijWnBu82; 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 f18si4918277edw.32.2020.11.03.10.22.36; Tue, 03 Nov 2020 10:22:59 -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=ijWnBu82; 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 S1729136AbgKCSTO (ORCPT + 99 others); Tue, 3 Nov 2020 13:19:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58243 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729072AbgKCSTN (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: linux-kernel@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: > {