Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp507518imm; Thu, 13 Sep 2018 03:29:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaVwPfI6+/T5puGmSXPK8ER7bKRCJi5sfVN9ZVHxbu4OxYzSxL57iQvWuHwUMYwVc8J6tuI X-Received: by 2002:a17:902:145:: with SMTP id 63-v6mr6438037plb.329.1536834588674; Thu, 13 Sep 2018 03:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536834588; cv=none; d=google.com; s=arc-20160816; b=vNM+b2fVatzgzgN+J1HZQ5ABjrbI3t0L9shm/0R7N72/9Im0OfEdSuEH6qbOGsjQBK 3t5FkpJ7fdpIwfceW9wT9Scl9IwVqKodH2B0afz8MvmR7UIiQghotIPiCHM0DSHogsHy xSIwu6Z8pDP4K1Ts0ogRb/u3xQOi7xs8gumUKQWozjZXEkjyf4sa37Nfq1SvFFpIawAi KEgdUoEidkm5rJRSwIzKCZMBYrr4GOeaaRu3VRPQ4eRmI+rJ0vnKegOkUZlQSaZ/iP+Z Sf46eEfc02+/643wiQq4sOwA8cguV3Xxj9ActwitmPDRZ23bZmXz+8ZlgtRXmcOY9WSQ yOZw== 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=d3syHV27SIXgKwY6Ph9XLOevIOx6TOILxBDaFeGQ94c=; b=fQ8tIbWTcfpFM05G6iQsfpPAP5Ot+wpy1RQyYCiMBvPkB6aWIUgVbuY43hyLQFxnXK FPBxL34RGWhn8Z1E0Zr9gGfTkYqltGe4AZ6M0XtUMGUbLq3etZa3Ow+fFEsfsWK0FYXq SsMlYjaTgZIiiyeu5BMQwBOqHm/sRmYoWTJlRnSdWuIBjHMGAeWD+DpkwexA/lo+vp3w 0n/U6vEyaC+CH12l8A7FzEs+YpoA18RkdtQc0rep7LaaF/7L2e/OuvQFAR5SHKvg4Pzn c5ahtRihgchBmcDFKPBMUkNnLRoJr4wYBdXTU14d+P80lBgkGmfawWCSecouquoMOfX3 paDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 k14-v6si3783325pga.149.2018.09.13.03.29.34; Thu, 13 Sep 2018 03:29:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727534AbeIMPiJ (ORCPT + 99 others); Thu, 13 Sep 2018 11:38:09 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:37027 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726797AbeIMPiJ (ORCPT ); Thu, 13 Sep 2018 11:38:09 -0400 Received: by mail-qt0-f194.google.com with SMTP id n6-v6so4822652qtl.4; Thu, 13 Sep 2018 03:29:19 -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=d3syHV27SIXgKwY6Ph9XLOevIOx6TOILxBDaFeGQ94c=; b=I2DcdjegwOtxVQTnA8Ja2tm0Sk9mGo81fUqRRLJLCZ6uLP/XaMuKKwH8pAJ33MhHOQ ght6rH6rDvlxMHG7Rt80VsHyj2WasbO0B0esW+eZmZxyXo1mCEKWLzY3zRmDXP7siWAe VRj2BsvVS4OrNIOVZ6ib//VGJKUg4nYzp7d4lDy2JS1IH5Oa4xjmPx2sKwsQ6jCTyO4M wkpkUhlfvLsznbjwkxovOvJbaEtk0m6TnKqcM+YwUUZD0uCLd7bjfr5bBvfriKpL86CV jv11vf8NK0/p4hEffhkNMWuiwehWRYSzWT2DPqXArnm1Oj8dMGVUqWXngZyJFVS6spbH /A4g== X-Gm-Message-State: APzg51CsM8Nflzjk17TCDlFcu67+ZS+6nOGX0/UTuSLHSug+0Rt9VaBZ mEKGXuxuF7ocGtQ4HBcoVV1IYYCaUvQX4z9aUGkmiHbX X-Received: by 2002:a0c:fb08:: with SMTP id c8-v6mr4576342qvp.149.1536834558305; Thu, 13 Sep 2018 03:29:18 -0700 (PDT) MIME-Version: 1.0 References: <20180912150142.157913-1-arnd@arndb.de> <20180913020757.GP19965@ZenIV.linux.org.uk> In-Reply-To: <20180913020757.GP19965@ZenIV.linux.org.uk> From: Arnd Bergmann Date: Thu, 13 Sep 2018 12:29:02 +0200 Message-ID: Subject: Re: [PATCH v2 01/17] compat_ioctl: add generic_compat_ioctl_ptrarg() To: Al Viro Cc: Linux FS-devel Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 13, 2018 at 4:07 AM Al Viro wrote: > > On Wed, Sep 12, 2018 at 05:01:02PM +0200, Arnd Bergmann wrote: > > Many drivers have ioctl() handlers that are completely compatible > > between 32-bit and 64-bit architectures, except for the argument > > that is passed down from user space and may have to be passed > > through compat_ptr() in order to become a valid 64-bit pointer. > > > > Using ".compat_ptr=generic_compat_ioctl_ptrarg" in file operations > > should let us simplify a lot of those drivers to avoid #ifdef > > checks, and convert additional drivers that don't have proper > > compat handling yet. > > Just keep in mind that this should *only* be used when all > ioctls implemented in a given instance do take pointers. > Because otherwise you are asking for trouble - e.g. if one of > them takes an u32 used as a bitmap, this will run into trouble > as soon as somebody uses bit 31. With no visible warnings. > > IOW, it shouldn't be used blindly and it should come with big > fat warning. I was hoping that the _ptrarg suffix gives enough warning here, but maybe not. I was careful to only use it in cases that I checked are safe, either using only pointer arguments, or no arguments. What we might do for further clarification (besides adding a comment next to the declaration), would be to add a complementary generic_compat_ioctl_intarg() that skips the compat_ptr(). There are only a handful of drivers that would use this though. Arnd