From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Subject: Re: [PATCH v3 12/26] compat_ioctl: move more drivers to compat_ptr_ioctl Date: Thu, 25 Apr 2019 17:55:23 +0200 Message-ID: References: <20190416202013.4034148-1-arnd@arndb.de> <20190416202701.127745-1-arnd@arndb.de> <20190425122153.450fc094@coco.lan> <20190425153534.GS2217@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20190425153534.GS2217-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org Sender: "Linux-nvdimm" To: Al Viro Cc: Sean Young , linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Daniel Vetter , linux-pci , dri-devel , Bjorn Andersson , sparclinux , Mauro Carvalho Chehab , driverdevel , linux-scsi , linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org, y2038 Mailman List , qat-linux-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, Jason Gunthorpe , "open list:HID CORE LAYER" , Darren Hart , Linux Media Mailing List , linux-remoteproc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linaro-mm-sig-cunTk1MwBs8s++Sfvej+rw@public.gmane.org, linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Jonathan Cameron , David Sterba List-Id: linux-nvdimm@lists.01.org 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, but not copy_to_user(), which overwrites 4 bytes after the end of the 20-byte user structure. Arnd 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> In-Reply-To: <20190425153534.GS2217@ZenIV.linux.org.uk> From: Arnd Bergmann Date: Thu, 25 Apr 2019 17:55:23 +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: Al Viro Cc: 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 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, but not copy_to_user(), which overwrites 4 bytes after the end of the 20-byte user structure. Arnd 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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=unavailable 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 A0476C43219 for ; Thu, 25 Apr 2019 15:55:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EAD0D2088F for ; Thu, 25 Apr 2019 15:55:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729376AbfDYPzo (ORCPT ); Thu, 25 Apr 2019 11:55:44 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:43713 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727137AbfDYPzn (ORCPT ); Thu, 25 Apr 2019 11:55:43 -0400 Received: by mail-qt1-f195.google.com with SMTP id g4so604936qtq.10; Thu, 25 Apr 2019 08:55:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zkwopJCM5aWIxk1QBblXCx0FKSBr5++vETUbB1hTeEs=; b=NlFeIDqca1cphh1upv/cDvlCmoF3HGt9HAeTxX4mddA/iM+S/tVwkvKF/kGj0UjUS6 NrEz4HIfUbW0toeWqqgP6WykwBwrZXLqbB6Gf6WXQRQex61VKLGV4z7FqIf5z6epxlDA Zv6YT0xVBX4JXNVzfiLQkRVgx7ZxCgZCcx6YGw7ZiQNKvWVoE2MZjdk29nY9hWl10OxW yAE81CZ2r95sOz6SCvFgjobX+lYYBFMn6RP5xtON6VBegCcJl0BWI//Epf0VQR/m3M1i fO+vLQD6vYsIVNmtqkDsRUoT1LVLB77F/7RpXaY1QsscJYaj8m55g74xVtdoLQi4J+CB +Qlg== X-Gm-Message-State: APjAAAUUJhjzP/nzNWGRi13/QF447CE8eBjeq7u2Iw7AolrPIWsq/zVY yehVaa+rTyWhqJhrPiIN5UwhzSnp3AGTpY3tt3w= X-Google-Smtp-Source: APXvYqwupzbYTiLjLfqIarqoXDi4frJzR/cv4HqO21AQp9/xhogJt2aa2zuSHYZLMoMxRTXJvQmzyoVA0Y0H4v8cQsw= X-Received: by 2002:a0c:d2fa:: with SMTP id x55mr32105048qvh.161.1556207741117; Thu, 25 Apr 2019 08:55:41 -0700 (PDT) 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> In-Reply-To: <20190425153534.GS2217@ZenIV.linux.org.uk> From: Arnd Bergmann Date: Thu, 25 Apr 2019 17:55:23 +0200 Message-ID: Subject: Re: [PATCH v3 12/26] compat_ioctl: move more drivers to compat_ptr_ioctl To: Al Viro Cc: 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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, but not copy_to_user(), which overwrites 4 bytes after the end of the 20-byte user structure. Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Subject: [v3,12/26] compat_ioctl: move more drivers to compat_ptr_ioctl From: Arnd Bergmann Message-Id: Date: Thu, 25 Apr 2019 17:55:23 +0200 To: Al Viro Cc: 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: T24gVGh1LCBBcHIgMjUsIDIwMTkgYXQgNTozNSBQTSBBbCBWaXJvIDx2aXJvQHplbml2LmxpbnV4 Lm9yZy51az4gd3JvdGU6Cj4KPiBPbiBUaHUsIEFwciAyNSwgMjAxOSBhdCAxMjoyMTo1M1BNIC0w MzAwLCBNYXVybyBDYXJ2YWxobyBDaGVoYWIgd3JvdGU6Cj4KPiA+IElmIEkgdW5kZXJzdGFuZCB5 b3VyIHBhdGNoIGRlc2NyaXB0aW9uIHdlbGwsIHVzaW5nIGNvbXBhdF9wdHJfaW9jdGwKPiA+IG9u bHkgd29ya3MgaWYgdGhlIGRyaXZlciBpcyBub3QgZm9yIHMzOTAsIHJpZ2h0Pwo+Cj4gTm87IHMz OTAgaXMgd2hlcmUgIm9oLCBqdXN0IHNldCAtPmNvbXBhdF9pb2N0bCBzYW1lIGFzIC0+dW5sb2Nr ZWRfaW9jdGwKPiBhbmQgYmUgZG9uZSB3aXRoIHRoYXQ7IGNvbXBhdF9wdHIoKSBpcyBhIG5vLW9w IGFueXdheSIgYnJlYWtzLiAgSU9XLAo+IHMzOTAgaXMgd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gQXJuZAo= From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Date: Thu, 25 Apr 2019 15:55:23 +0000 Subject: Re: [PATCH v3 12/26] compat_ioctl: move more drivers to compat_ptr_ioctl Message-Id: List-Id: References: <20190416202013.4034148-1-arnd@arndb.de> <20190416202701.127745-1-arnd@arndb.de> <20190425122153.450fc094@coco.lan> <20190425153534.GS2217@ZenIV.linux.org.uk> In-Reply-To: <20190425153534.GS2217-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Al Viro Cc: Sean Young , linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Daniel Vetter , linux-pci , dri-devel , Bjorn Andersson , sparclinux , Mauro Carvalho Chehab , driverdevel , linux-scsi , linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org, y2038 Mailman List , qat-linux-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, Jason Gunthorpe , "open list:HID CORE LAYER" , Darren Hart , Linux Media Mailing List , linux-remoteproc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linaro-mm-sig-cunTk1MwBs8s++Sfvej+rw@public.gmane.org, linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Jonathan Cameron , David Sterba 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, but not copy_to_user(), which overwrites 4 bytes after the end of the 20-byte user structure. Arnd