Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp347662yba; Fri, 26 Apr 2019 00:47:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzk6LeNBMG9PKZG+RNeE1nL7WKb35YwB4AbDEQwJNqMkyrArG4veoQFK00a8an2PsvIIcjr X-Received: by 2002:a63:da4e:: with SMTP id l14mr39544915pgj.96.1556264829201; Fri, 26 Apr 2019 00:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556264829; cv=none; d=google.com; s=arc-20160816; b=Txeks3D+bqGM3pTB5pXK2Iav8MSB0AjmVg9PcN3W5H+rfGS+v8wId9jPOqbz5g9JIT lUVgkpl5mcvrYECzKEIUJrWTE03N3VQuvczMDZyOk1DCB+Ckq2kHqdafG8QfkTyP3PNp F4IAT+mfRrAL887FJDMefZCsLYsXcnjysTUS6oL5+pjuOSZuCH/sJ3YrCJCJTMeqs4XK l2GYjmzfnEXqdfNtEyhSoWIzVvlVpjTLJNzOhEJZUTXWc7/tvKAGav+bCDQsXMCGhzHy zTYF+cYTDO6a2FQMH5Iq+y5APy9VnJwwa8iXE0899VQXoINBgV8gtdrpXle1CYh6tq5n ulyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=Ai+vP/B94Ve42WDYthMy68WDqGtKeGDhz8vwsuWoKYY=; b=RH30QyeODvKwx39jg0sHzLdAG6C7+FxIdQA4Ekp+5aIj/VgmtGRPnbeVM+cXIJj+6x aqZR24dNvFZb4TG6gtDOxdShi5X3Uf+So1Nf8PCSTdnja31GsenDllX2gvK9DZCJsKEl ZTq8wjRqZ/EDHsyQghDScocqBw3K0BaXJn5wpLJ7bA1tWE92YjwmxKmWYKjKGRHQbf2N iRlZEnOoEZqwhVfQ7ISNKPi1ejPM4L5Si8DRJ6wsrX7RUcxD4S2+CNFNIkfrF2H2r36B YjcAhzCFGS5+kpgcHvEm8zm7WEKMmlqy8oNY9z9rycDl1d+EBqzRHWfLxVoIEChQNlsI bUMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si5812957pfb.172.2019.04.26.00.46.45; Fri, 26 Apr 2019 00:47:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726272AbfDZHqd (ORCPT + 99 others); Fri, 26 Apr 2019 03:46:33 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:38494 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725944AbfDZHqc (ORCPT ); Fri, 26 Apr 2019 03:46:32 -0400 Received: by mail-qt1-f193.google.com with SMTP id d13so3099026qth.5; Fri, 26 Apr 2019 00:46:30 -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=Ai+vP/B94Ve42WDYthMy68WDqGtKeGDhz8vwsuWoKYY=; b=FG7fOj59wwyOPVaYrKZUOZkuiWAvC9akOixlTflJRlZBaD5Nk1Q5lt4sNCVKQ0Ymoj 52Mw/cEb5bga48QDfZ25/IosOd7f4DVtReblKt78Tddb6JbvCOKlsnW4ZPHxwbqCcDWl AQM/p3uZiav0jkbogyOgR/4xxAbV+hxPuEvbksaoHrj3hkC5yYwUQGGxb0feSPNshzXf S+dmruYGKTPfi7MC8NPxeUYIYDBmFZwedMocX20dgkFMvHU+dhbQkTwmaEk2O8qXcQ6g uJAGfAJII+Qyt2ArmRK2SZ3h6YsW8oPqMVHZ/GGnoBbS0uiS7s2iVgur4G88lQugZgI8 33hw== X-Gm-Message-State: APjAAAVBrPBraidJkoagVa/Iqi808354m7O7uJIVMSDvP510mK1VadoD QO8l3m/Yer2pZRboxgbgjpAGH2eZtedEhQ8mJXg= X-Received: by 2002:ac8:276b:: with SMTP id h40mr35193967qth.319.1556264790155; Fri, 26 Apr 2019 00:46:30 -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> <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 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 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 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