From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Carpenter Subject: Re: [PATCH for-4.5] vfio: fix ioctl error handling Date: Fri, 26 Feb 2016 16:47:48 +0300 Message-ID: <20160226134748.GL5273@mwanda> References: <1456399902-7352-1-git-send-email-mst@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Alex Williamson , Baptiste Reynal , Eric Auger , Antonios Motakis , Julia Lawall , kvm@vger.kernel.org To: "Michael S. Tsirkin" Return-path: Content-Disposition: inline In-Reply-To: <1456399902-7352-1-git-send-email-mst@redhat.com> Sender: stable-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Thu, Feb 25, 2016 at 01:34:43PM +0200, Michael S. Tsirkin wrote: > Calling return copy_to_user(...) in an ioctl will not > do the right thing if there's a pagefault: > copy_to_user returns the number of bytes not copied > in this case. > > Fix up vfio to do > if (copy_to_user(...)) > return -EFAULT; > > everywhere. > > Reported-by: Dan Carpenter Heh. I don't exactly deserve this credit. I have updated Smatch to check for this (will push next week probably). I wouldn't have caught the issues in vfio_platform_common.c because that's ARM only. regards, dan carpenter