From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 References: <20190416202013.4034148-1-arnd@arndb.de> <20190416202701.127745-1-arnd@arndb.de> <20190425122153.450fc094@coco.lan> <20190425153534.GS2217@ZenIV.linux.org.uk> <5511420228cb38d08a67c0f6a614b7671d7d23d4.camel@sipsolutions.net> In-Reply-To: <5511420228cb38d08a67c0f6a614b7671d7d23d4.camel@sipsolutions.net> From: Arnd Bergmann Date: Fri, 26 Apr 2019 09:46:13 +0200 Message-ID: Subject: Re: [PATCH v3 12/26] compat_ioctl: move more drivers to compat_ptr_ioctl Content-Type: text/plain; charset="UTF-8" To: Johannes Berg Cc: Al Viro , Mauro Carvalho Chehab , Linux FS-devel Mailing List , y2038 Mailman List , Linux Kernel Mailing List , Jason Gunthorpe , Daniel Vetter , Greg Kroah-Hartman , David Sterba , Darren Hart , Jonathan Cameron , Bjorn Andersson , driverdevel , qat-linux@intel.com, "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Linux Media Mailing List , dri-devel , linaro-mm-sig@lists.linaro.org, amd-gfx@lists.freedesktop.org, "open list:HID CORE LAYER" , linux-iio@vger.kernel.org, linux-rdma , linux-nvdimm@lists.01.org, linux-nvme@lists.infradead.org, linux-pci , Platform Driver , linux-remoteproc@vger.kernel.org, sparclinux , linux-scsi , USB list , linux-btrfs , ceph-devel , linux-wireless , Networking , Sean Young List-ID: On Thu, Apr 25, 2019 at 11:25 PM Johannes Berg wrote: > On Thu, 2019-04-25 at 17:55 +0200, Arnd Bergmann wrote: > > On Thu, Apr 25, 2019 at 5:35 PM Al Viro wrote: > > > > > > On Thu, Apr 25, 2019 at 12:21:53PM -0300, Mauro Carvalho Chehab wrote: > > > > > > > If I understand your patch description well, using compat_ptr_ioctl > > > > only works if the driver is not for s390, right? > > > > > > No; s390 is where "oh, just set ->compat_ioctl same as ->unlocked_ioctl > > > and be done with that; compat_ptr() is a no-op anyway" breaks. IOW, > > > s390 is the reason for having compat_ptr_ioctl() in the first place; > > > that thing works on all biarch architectures, as long as all stuff > > > handled by ->ioctl() takes pointer to arch-independent object as > > > argument. IOW, > > > argument ignored => OK > > > any arithmetical type => no go, compat_ptr() would bugger it > > > pointer to int => OK > > > pointer to string => OK > > > pointer to u64 => OK > > > pointer to struct {u64 addr; char s[11];} => OK > > > > To be extra pedantic, the 'struct {u64 addr; char s[11];} ' > > case is also broken on x86, because sizeof (obj) is smaller > > on i386, even though the location of the members are > > the same. i.e. you can copy_from_user() this > > Actually, you can't even do that because the struct might sit at the end > of a page and then you'd erroneously fault in this case. > > We had this a while ago with struct ifreq, see commit 98406133dd and its > parents. Yes, you are right. Very rare to hit with real-life code, but easily reproduced by intentionally hitting it and clearly a bug. As the saying goes | the difference between "always works" and "almost always works" | is called data corruption here the difference is an -EFAULT. Arnd