From patchwork Wed Aug 14 20:42:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094527 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A75D513AC for ; Wed, 14 Aug 2019 20:44:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96DB72883C for ; Wed, 14 Aug 2019 20:44:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88CE628842; Wed, 14 Aug 2019 20:44:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DDBE2883C for ; Wed, 14 Aug 2019 20:44:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727975AbfHNUn7 (ORCPT ); Wed, 14 Aug 2019 16:43:59 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:50389 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727414AbfHNUn7 (ORCPT ); Wed, 14 Aug 2019 16:43:59 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MiaLn-1iSeBA1QPf-00fn6k; Wed, 14 Aug 2019 22:43:47 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, "Darrick J. Wong" , linux-xfs@vger.kernel.org Cc: Arnd Bergmann , Brian Foster , Allison Collins , Nick Bowler , Eric Sandeen , Dave Chinner Subject: [PATCH v5 01/18] xfs: compat_ioctl: use compat_ptr() Date: Wed, 14 Aug 2019 22:42:28 +0200 Message-Id: <20190814204259.120942-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:sNo6mKYpnmSZN5AlXqVADdaOJq7MPq3SaOmLM1H/CuxqgrcCVf8 2YSUJHmWE9awUdZ1xWV2chJQhpNMTxERfy48/uOA4nMXImoW5puUJJdd47twsIaPl4BFmD1 wKmpCznhwYW60h8bbwBNrmaQxSUyotCMx6YiJNzqmhdaFwuJp9p4OMt5lO4jkNNkjEhlwNm PbA/cpynZI66g/mEvvdRQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:q3aew6AlwJ4=:ixRs8Mf5aY/UJ9Vn/Hkcj/ +4ya2F/k0c5RLxn7JzJ+q/nFSoIdHix7z0JIdEDTZY2fL1TDA5xGRCEyR9q3VuIGN6S5hHYv8 7B+L6v3E+3dlde75Ftb4UcDd1rz1NS0AZ/F3RwleJHV8GkrSykJW5MbEEujWbRrOVWte7gkZ/ gt3qjaH7dF3L95ZIfHfD8IbOjwGDV7EazbEEOAIBgdXQSPLkrMiGkhboWt2mJbuLf+Vu3vaxN l0zyau97oPkkCh4ifXlArBOu5qXiZAXpj8q2wify14jO2rQb5m5CYM4W1Myb9I8FoOEtdJ/91 Pgq/O2pMaA0Wks+a5PYV7NJLeq+N/FiqwT5kXYinZ+K0X1iTmMs4gtcTKDALUy1cE4GzQYNbP 85xHtVqKP80iGykVntL/Q7oTAXNCbrmtQUQoRyuiU+j9hQ2j3nnVtzoXhyhska2S0GW2cNHlV PoSYBoV3mMn3bxomoc2SxDl2qWcWtwlR6rhUJNZBCiFXd7U8vLeiGxC0hBZsEQPpTTDmNSWBS l0MDM4Ng0Ywvapx2OZBgWjoW6NC4KAzDZKypalCHYvIeWqh96BAPqQtxqQCM3u2S7SbGjmosl OhzEk+FCpJD5yW9p70jZi17kA7tOnaPGqZMbIyfWCVg4T/Yhu9yhfs2xXTXk3bB5MhVOSkmgT p9sZgPKd6Lu5qfhhxprD/d85Q007A8rmJbJOo85jFix5C2VMbImBoYghcHa5rmaiJCytIN5eS sUsQiYYI3whKvtZQTO+lFbiMu3fN3QKH+pElHg== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For 31-bit s390 user space, we have to pass pointer arguments through compat_ptr() in the compat_ioctl handler. Signed-off-by: Arnd Bergmann --- fs/xfs/xfs_ioctl32.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 7fcf7569743f..ad91e81a2fcf 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -547,7 +547,7 @@ xfs_file_compat_ioctl( struct inode *inode = file_inode(filp); struct xfs_inode *ip = XFS_I(inode); struct xfs_mount *mp = ip->i_mount; - void __user *arg = (void __user *)p; + void __user *arg = compat_ptr(p); int error; trace_xfs_file_compat_ioctl(ip); @@ -576,7 +576,7 @@ xfs_file_compat_ioctl( case XFS_IOC_SCRUB_METADATA: case XFS_IOC_BULKSTAT: case XFS_IOC_INUMBERS: - return xfs_file_ioctl(filp, cmd, p); + return xfs_file_ioctl(filp, cmd, (unsigned long)arg); #if !defined(BROKEN_X86_ALIGNMENT) || defined(CONFIG_X86_X32) /* * These are handled fine if no alignment issues. To support x32 @@ -602,7 +602,7 @@ xfs_file_compat_ioctl( */ case XFS_IOC_SWAPEXT: #endif - return xfs_file_ioctl(filp, cmd, p); + return xfs_file_ioctl(filp, cmd, (unsigned long)arg); #endif #if defined(BROKEN_X86_ALIGNMENT) case XFS_IOC_ALLOCSP_32: @@ -653,7 +653,7 @@ xfs_file_compat_ioctl( case XFS_IOC_SETXFLAGS_32: case XFS_IOC_GETVERSION_32: cmd = _NATIVE_IOC(cmd, long); - return xfs_file_ioctl(filp, cmd, p); + return xfs_file_ioctl(filp, cmd, (unsigned long)arg); case XFS_IOC_SWAPEXT_32: { struct xfs_swapext sxp; struct compat_xfs_swapext __user *sxu = arg; From patchwork Wed Aug 14 20:42:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E684A6C5 for ; Wed, 14 Aug 2019 20:44:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5E992883C for ; Wed, 14 Aug 2019 20:44:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA6EF28842; Wed, 14 Aug 2019 20:44:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86A092883C for ; Wed, 14 Aug 2019 20:44:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729734AbfHNUoL (ORCPT ); Wed, 14 Aug 2019 16:44:11 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:48999 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727414AbfHNUoL (ORCPT ); Wed, 14 Aug 2019 16:44:11 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1M7sUE-1hu8FB2YJ0-0055JL; Wed, 14 Aug 2019 22:43:59 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, "Darrick J. Wong" , linux-xfs@vger.kernel.org Cc: Arnd Bergmann , stable@vger.kernel.org, Eric Sandeen , Brian Foster , Nick Bowler , Allison Collins , Eric Sandeen , Dave Chinner Subject: [PATCH v5 02/18] xfs: compat_ioctl: add missing conversions Date: Wed, 14 Aug 2019 22:42:29 +0200 Message-Id: <20190814204259.120942-3-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:BLux4Grpb9eaMSbIUHaQDxbpUbrvASwJg7DjSBmbDM1mEh+OQSl G5n/FRAlhpcI0Sn7b9m1K0M1bvF39TcpRlT3CSGFl7+bY+KEO6/rjDcP9KSqU+5SOAFZN1u Ui5FCJaccug7SCmAt9JgOshsonVvlK697uQkOLkrX2ItPyAMgMpdRzWF2sTnSwRy6q9IT+B vD7ThUPi2YJlmDVS6BIww== X-UI-Out-Filterresults: notjunk:1;V03:K0:j12Xhrp5sIs=:AcxvEsaYOH6PkuvTGntmR9 rBstK/TIT+tpcug7Gtvy3sx8T18TYIS1QNsHzsO7opM4MdvAyRQ1V4skOOIgSlrGs3uBeEATu /N+yQKqh2Gu+2GbVYX0nff3AQUL86sCBbN7G4JifKUsgEMPHFydi+Hmcyny7tZZbhP7++ncih fpsI2yzVH6Lnpy3A9z3mck/PxWig+lwGeUZt5MDJsX9HlxJ/kFTcpwVKN4BPCc/3IZ27XgOXQ HH5TaXVkv8VI8YHQCYI6SBQAmRV9RoXRoSIqyFyegh330OEmMuAnP9EReovhA05uOQ8OW0XP5 xh2ytmeOS2tRrdJARoUnKb5xbD+nYMaYPi7+b4kMJl196CCptyCefwvUbziLAPr4ts9iiCiqs O1e6cJUptwG/2NA7z6akcuZ06wk3DmFQaav41eBF9gIkMlcNgNvpLh/jlKKfd0xEz5gB3N5S6 DXhbGKUWiNf+855BcAuf0kc0w0GgIvx7lj8hhbJdxUN6aWHfOq7JPnHAt8QBl8R7fPGIqS0BS ECc0EtMgsqvGz3C0pg/V7dudPnK1nNFUp+aU+i402P3pu5XPsUwRCz8rY/ibQjm2Lio2Mxmax sq4jjrMpF9qbB9Sh3zPov66UEVbUIkfFNJkaJAFGjq6aOu43e1l6X7mDcZwhfjihaRCGfmVCo mtEJYVporJWn+f9fQkLw37RF4eVZR37mnkEcQ77mc0dJa597PDGmwzgVloGPpFGa20ap9mu1I L90m3jpTIa7fD6mAaFYIMPPayNuFFuuNZRWOmA== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP FS_IOC_GETFSLABEL/FS_IOC_SETFSLABEL were added in linux-4.18 in xfs, but not in the compat_ioctl case, so add them here. FITRIM was added earlier and also lacks a line the same function, but this is ok because there is an entry in fs/compat_ioctl.c for it. Adding all three here to keep the native and compat ioctl handlers in sync. Cc: stable@vger.kernel.org Fixes: f7664b31975b ("xfs: implement online get/set fs label") Signed-off-by: Arnd Bergmann --- fs/xfs/xfs_ioctl32.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index ad91e81a2fcf..63bdc4c1535b 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -576,6 +576,9 @@ xfs_file_compat_ioctl( case XFS_IOC_SCRUB_METADATA: case XFS_IOC_BULKSTAT: case XFS_IOC_INUMBERS: + case FITRIM: + case FS_IOC_GETFSLABEL: + case FS_IOC_SETFSLABEL: return xfs_file_ioctl(filp, cmd, (unsigned long)arg); #if !defined(BROKEN_X86_ALIGNMENT) || defined(CONFIG_X86_X32) /* From patchwork Wed Aug 14 20:42:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 593851395 for ; Wed, 14 Aug 2019 20:45:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42FAD2883C for ; Wed, 14 Aug 2019 20:45:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3344B28842; Wed, 14 Aug 2019 20:45:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2290C2883C for ; Wed, 14 Aug 2019 20:45:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729755AbfHNUpA (ORCPT ); Wed, 14 Aug 2019 16:45:00 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:56681 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728682AbfHNUpA (ORCPT ); Wed, 14 Aug 2019 16:45:00 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1M7Jj2-1huhHR2fpk-007orl; Wed, 14 Aug 2019 22:44:25 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Bob Peterson , Andreas Gruenbacher Cc: Arnd Bergmann , Steve Whitehouse , Jan Kara , NeilBrown , "Darrick J. Wong" , cluster-devel@redhat.com Subject: [PATCH v5 03/18] gfs2: add compat_ioctl support Date: Wed, 14 Aug 2019 22:42:30 +0200 Message-Id: <20190814204259.120942-4-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:hGXDAxI7hFLVZ85cfnbZ5sHaSt06xrX/1XrFOyFm8J2VKLQB1xL hBlQ8eE8iy72h9XotCxexOE5vXgZNGCjvcELLBjVkIB7tPAfgy8TLWA63BTsyMQCgpafBDx jZ0RNjuG6UZOVeDWg0FNwnOOT9H3LwypCg9fmWIZJhiGV5jDAyBZ3xyqwXFe+8CVyaerHC9 lXslO82tG51uc8cuCC8kQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:8ZMJQ62I2nQ=:8iOcgb599uCKvsk3CfwfHr YoBxiVH0msauRk9nhPND2dv96UWgpbxfbtP0w7F0QLjQy+K7o2h8T55mcoXKv8Mvrn5JSOFp4 HLq6u++mmMvVXYbiUKJ3ES+7vWWuqHvfTDmoKdgrAp2asQssIy33P4wB2gTDK++1sx7jHg7Ae Oltncw5miJqx9TiiAcurDTKS7cWDsghzKMj3p7DwOuHePlbBJsdlzFRA7vDVyXT7dnexHt6vI C2IIoLYYN7ed8Q0df/gag9j/niysF3ESIFJvD/VU59ml0s608eo3BMIcT3tCG5ONFeXBUTMwk TWcKN0L3Fyr9SMCepXxl8AT9rouJfNz/+RrWskxCCkwTNhcVrk4eDHudyfWBUZabK9WnUXHxh VdTvIXRpQ1jyJMy0/Yj9nLqD4kb1YU2XezLvq3XCmjlOHKNwYDUd+mOfv6YtNCBNeI6nDL2UC 5yriW4CxBZFiK6v79N8PSdAz98Ptoj0rZhbBRQccgW5dQ1lShmYa33cnLeujFYa5CsKsZmwvN oUEtYpDHWfs/RqgrZsTlePvMiETsUyKFhfiwJff6a8NjMfPXeeeknzbV1ufnYLnd3cSjiy1YT DVLrx2CqRzP9SHu0PgvhzdVUz3N4NulhDKwD8HXcORdRnZ7AZEYN2/IoxrenMtsqyD3wcHiAh ClbX2gXgbHQ1QvW9E1H43hcUJ831wxWHZ4l3iEgImJs6HwoaiJmG6kDFyliA8n7l7bBskqj+m 64cSfdymf8LL2fgPCbtKM8TB2Etv4Oo8Kq1A4g== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Out of the four ioctl commands supported on gfs2, only FITRIM works in compat mode. Add a proper handler based on the ext4 implementation. Fixes: 6ddc5c3ddf25 ("gfs2: getlabel support") Signed-off-by: Arnd Bergmann Reviewed-by: Bob Peterson --- fs/gfs2/file.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 52fa1ef8400b..49287f0b96d0 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -354,6 +355,25 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) return -ENOTTY; } +#ifdef CONFIG_COMPAT +static long gfs2_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +{ + /* These are just misnamed, they actually get/put from/to user an int */ + switch(cmd) { + case FS_IOC32_GETFLAGS: + cmd = FS_IOC_GETFLAGS; + break; + case FS_IOC32_SETFLAGS: + cmd = FS_IOC_SETFLAGS; + break; + } + + return gfs2_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); +} +#else +#define gfs2_compat_ioctl NULL +#endif + /** * gfs2_size_hint - Give a hint to the size of a write request * @filep: The struct file @@ -1294,6 +1314,7 @@ const struct file_operations gfs2_file_fops = { .write_iter = gfs2_file_write_iter, .iopoll = iomap_dio_iopoll, .unlocked_ioctl = gfs2_ioctl, + .compat_ioctl = gfs2_compat_ioctl, .mmap = gfs2_mmap, .open = gfs2_open, .release = gfs2_release, @@ -1309,6 +1330,7 @@ const struct file_operations gfs2_file_fops = { const struct file_operations gfs2_dir_fops = { .iterate_shared = gfs2_readdir, .unlocked_ioctl = gfs2_ioctl, + .compat_ioctl = gfs2_compat_ioctl, .open = gfs2_open, .release = gfs2_release, .fsync = gfs2_fsync, @@ -1325,6 +1347,7 @@ const struct file_operations gfs2_file_fops_nolock = { .write_iter = gfs2_file_write_iter, .iopoll = iomap_dio_iopoll, .unlocked_ioctl = gfs2_ioctl, + .compat_ioctl = gfs2_compat_ioctl, .mmap = gfs2_mmap, .open = gfs2_open, .release = gfs2_release, @@ -1338,6 +1361,7 @@ const struct file_operations gfs2_file_fops_nolock = { const struct file_operations gfs2_dir_fops_nolock = { .iterate_shared = gfs2_readdir, .unlocked_ioctl = gfs2_ioctl, + .compat_ioctl = gfs2_compat_ioctl, .open = gfs2_open, .release = gfs2_release, .fsync = gfs2_fsync, From patchwork Wed Aug 14 20:42:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A81321395 for ; Wed, 14 Aug 2019 20:46:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9665A27FA3 for ; Wed, 14 Aug 2019 20:46:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 897B628845; Wed, 14 Aug 2019 20:46:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17E3627FA3 for ; Wed, 14 Aug 2019 20:46:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729901AbfHNUqJ (ORCPT ); Wed, 14 Aug 2019 16:46:09 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:44517 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729252AbfHNUqE (ORCPT ); Wed, 14 Aug 2019 16:46:04 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1McXwD-1iYj0E0IkX-00d0se; Wed, 14 Aug 2019 22:45:19 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Tyler Hicks , "Theodore Ts'o" , Andreas Dilger , Jaegeuk Kim , Chao Yu , Mikulas Patocka , Ryusuke Konishi , Mark Fasheh , Joel Becker , Joseph Qi Cc: Arnd Bergmann , Mauro Carvalho Chehab , "Darrick J. Wong" , yangerkun , Jan Kara , Wang Shilong , Chandan Rajendra , Eric Biggers , ecryptfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-nilfs@vger.kernel.org, ocfs2-devel@oss.oracle.com Subject: [PATCH v5 04/18] fs: compat_ioctl: move FITRIM emulation into file systems Date: Wed, 14 Aug 2019 22:42:31 +0200 Message-Id: <20190814204259.120942-5-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:z3dV4EMHHVTIqB6irmOt7mALlth6pUBx39cxp1q/MXyyb5my9TD Ei9tu/20oLbXQdeGubAGFUglD7gSy7sRkwU20qqoaC5wM3V/cZvdLqBCQqcct//zQrEBTpY PgotaPI/UqE9QOt6pD+oJC4mYA33c2x1Cmk05o5y4PekAgaxo/Ot1QZSZphz0pO284DyXEV DWM5bnpXU7W9zHwvWm6+g== X-UI-Out-Filterresults: notjunk:1;V03:K0:qJAN7Jtr+50=:Hn6FCDiPj6NPOBPlxdGPcD u/sYhAF03jaoyRBk1JTzPSJhVA6sz1jenvAB2hCYhY8rJaynQ1wNziuco+p8X1rl9Kp67cMlD 1KGuR6lzD1ZizOXIPdQ4gceT+kxjp8IdGN7ZrpkS0gKq9MoqQi3B0PxS5ThXI0Ng2kg6OLgdw j63zI6RZs2sN2dyRoehSpkkplSL3gjKQ0ehTyzU4LRVfqWnqjCX3UVgTgPTMZc8mfZmVMthy8 cANIHtG1l+urhmm4NAoZd6sPkIeYchZlep67j9X/ZJ2+NNctF1pMbqGirTbZuMTPDtqAmCGhM OJ3oW67vdkpUTnkySAOptMGqDCEuDkcVM7GWrRCs/sWNmrmxIuoRZh4uN5zlnY+iZh8soANqG U4MZd09RCFAlvrtX/5sWC17n9SnT4LwmejHRG8lW6W/Q4cKOSEdsZSOsu93ymdZinsB5vTfuW E28Jz9wFCu5Lw4QArUqwVjq5OYs0Cwrsx572RE2TgpMNPCg2vyehiqTcJ5RtlVG2yJW8IG5kH +BqVGr47E8eINr6zbAHdgUVVu/MREg9NCspFJfr/kBeroTLhDyhys0jz/ewjHdYOY78CoFamB Er8mGksHdLDynfrxBPfQGKoypEd2p1tUAebqYCMwga+G6h9oScx/lOvsvxPbWr8rBG+/9EJtl gGAZjlTxh6MhDvFAH+dCwH4+fMDRQDlQ8lxqtUxTCBJ4VdpHcV+rzDKHjAz4Vflex8v/o40te v8sereCDav9jt6NTEZnegE8b/RzQevTpcA27uQ== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove the special case for FITRIM, and make file systems handle that like all other ioctl commands with their own handlers. Signed-off-by: Arnd Bergmann --- fs/compat_ioctl.c | 2 -- fs/ecryptfs/file.c | 1 + fs/ext4/ioctl.c | 1 + fs/f2fs/file.c | 1 + fs/hpfs/dir.c | 1 + fs/hpfs/file.c | 1 + fs/nilfs2/ioctl.c | 1 + fs/ocfs2/ioctl.c | 1 + 8 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 1e740f4406d3..b20228c19ccd 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -345,8 +345,6 @@ static int ppp_scompress(struct file *file, unsigned int cmd, static unsigned int ioctl_pointer[] = { /* Little t */ COMPATIBLE_IOCTL(TIOCOUTQ) -/* 'X' - originally XFS but some now in the VFS */ -COMPATIBLE_IOCTL(FITRIM) #ifdef CONFIG_BLOCK /* Big S */ COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index feecb57defa7..5fb45d865ce5 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c @@ -378,6 +378,7 @@ ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return rc; switch (cmd) { + case FITRIM: case FS_IOC32_GETFLAGS: case FS_IOC32_SETFLAGS: case FS_IOC32_GETVERSION: diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 442f7ef873fc..7a6e0f0f69e2 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -1227,6 +1227,7 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } case EXT4_IOC_MOVE_EXT: case EXT4_IOC_RESIZE_FS: + case FITRIM: case EXT4_IOC_PRECACHE_EXTENTS: case EXT4_IOC_SET_ENCRYPTION_POLICY: case EXT4_IOC_GET_ENCRYPTION_PWSALT: diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 3e58a6f697dd..befd2692160c 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3216,6 +3216,7 @@ long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case F2FS_IOC_RELEASE_VOLATILE_WRITE: case F2FS_IOC_ABORT_VOLATILE_WRITE: case F2FS_IOC_SHUTDOWN: + case FITRIM: case F2FS_IOC_SET_ENCRYPTION_POLICY: case F2FS_IOC_GET_ENCRYPTION_PWSALT: case F2FS_IOC_GET_ENCRYPTION_POLICY: diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c index d85230c84ef2..f32f15669996 100644 --- a/fs/hpfs/dir.c +++ b/fs/hpfs/dir.c @@ -325,4 +325,5 @@ const struct file_operations hpfs_dir_ops = .release = hpfs_dir_release, .fsync = hpfs_file_fsync, .unlocked_ioctl = hpfs_ioctl, + .compat_ioctl = compat_ptr_ioctl, }; diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c index 1ecec124e76f..b36abf9cb345 100644 --- a/fs/hpfs/file.c +++ b/fs/hpfs/file.c @@ -215,6 +215,7 @@ const struct file_operations hpfs_file_ops = .fsync = hpfs_file_fsync, .splice_read = generic_file_splice_read, .unlocked_ioctl = hpfs_ioctl, + .compat_ioctl = compat_ptr_ioctl, }; const struct inode_operations hpfs_file_iops = diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c index 91b9dac6b2cc..4ba73dbf3e8d 100644 --- a/fs/nilfs2/ioctl.c +++ b/fs/nilfs2/ioctl.c @@ -1354,6 +1354,7 @@ long nilfs_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) case NILFS_IOCTL_SYNC: case NILFS_IOCTL_RESIZE: case NILFS_IOCTL_SET_ALLOC_RANGE: + case FITRIM: break; default: return -ENOIOCTLCMD; diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c index d6f7b299eb23..2d517b5ec6ac 100644 --- a/fs/ocfs2/ioctl.c +++ b/fs/ocfs2/ioctl.c @@ -985,6 +985,7 @@ long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg) return -EFAULT; return ocfs2_info_handle(inode, &info, 1); + case FITRIM: case OCFS2_IOC_MOVE_EXT: break; default: From patchwork Wed Aug 14 20:42:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 798856C5 for ; Wed, 14 Aug 2019 20:46:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6843F27FA3 for ; Wed, 14 Aug 2019 20:46:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C8BC285A0; Wed, 14 Aug 2019 20:46:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B66E27FA3 for ; Wed, 14 Aug 2019 20:46:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729873AbfHNUqE (ORCPT ); Wed, 14 Aug 2019 16:46:04 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:35369 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725895AbfHNUqD (ORCPT ); Wed, 14 Aug 2019 16:46:03 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1N3bnP-1iPFzy0qGp-010ZeU; Wed, 14 Aug 2019 22:45:41 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Wim Van Sebroeck , Guenter Roeck Cc: Arnd Bergmann , linux-watchdog@vger.kernel.org Subject: [PATCH v5 05/18] watchdog: cpwd: use generic compat_ptr_ioctl Date: Wed, 14 Aug 2019 22:42:32 +0200 Message-Id: <20190814204259.120942-6-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:3a4T0+6d97+aohDNW/FtRRy0OL3GUoodnLsBOLxtmzvxYHD4nsU luMbWfHIl5BcsdlVHGK5m+/bWCtSjslqMmO0AuL6u0+1oNKgoWMdj1Eld5ELQNoNlyNLQKC zVp2goGJq19LaFW42VqCYrhFLWr2I7j5Uvog04XNttVJ4FfNpg241HZlZYV2vGqzh939Tw+ yopb/D3+LbbYSDvFLqrsA== X-UI-Out-Filterresults: notjunk:1;V03:K0:83dwGx/HYvo=:APkpK2EDgzEki9/bZwgwND A99E1l5pNDtDf3RPKP4Ek2PjpdG5dN8qa5s732xBWIBGtLLil+F3mi9BrGnk8BOr9cCwNHqPS K1STEn4T9rgarD9uHPla+WlYSqjGQfUsKRAsArAzLpMxwLmzQvcXoEN00hoKeNmI2cD3b/LB0 iP6v/6qP71QTVl5CZn89I3iQqWnXMzn8mV65/SgHEtd1YpcovXZcrFoHYEF43a82cHVBuOM+B /71RlU0gi9/MqjY+K0nCPfipm8V136v/wsdNIpFSlg6hCF167yal5lGIs1f0VhzViizQ9dvQP Lp35ipf5J4D7GXOVWCJ2JCoXFjgbsuEPclPOLydazGxwIV2WwugQz2qpI3Qk5trLSFT28cEji 2PjSRFu1XXJ+bpN4f4io4BtXjRcy2JQrSPxWQZ2ULD1eZ1j53AB72dVM+gLNeRGpxNWEw5NNY Ef67jpDJqbJGUti0VXjlM0D8eO4VJPyVoNsy/iCeC3mAR5Hh2cEe5IWcE6k8/I1PwGM25yana hcZwAn7lCxBOxJyKqMBKSkI9vEC4CKHQweMQDL/s4xIEoe3gku1JxxDoV+xiqLEpD5CqMn9zY ag1QjS8r421e+NCHyYH0jXUBTk5uqYnD/AKbJ279d7pkaVThbeP5BZ0wTRc4Q4mcRwyxe27Ag QhRNIAb+KVw2vAIn8ivYxpAJneBOdH7O2R9tdP2zLMoUPDLLIsy4DLPPUzvPkAZjkF0shMFCq 4+/bk3paNofJmv0FMYM7UXA366Ajon2TEW5vGg== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The cpwd_compat_ioctl() contains a bogus mutex that dates back to a leftover BKL instance. Simplify the implementation by using the new compat_ptr_ioctl() helper function that will do the right thing for all calls here. Note that WIOCSTART/WIOCSTOP don't take any arguments, so the compat_ptr() conversion is not needed here, but it also doesn't hurt. Signed-off-by: Arnd Bergmann Reviewed-by: Guenter Roeck --- drivers/watchdog/cpwd.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/drivers/watchdog/cpwd.c b/drivers/watchdog/cpwd.c index b973b31179df..9393be584e72 100644 --- a/drivers/watchdog/cpwd.c +++ b/drivers/watchdog/cpwd.c @@ -473,29 +473,6 @@ static long cpwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return 0; } -static long cpwd_compat_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - int rval = -ENOIOCTLCMD; - - switch (cmd) { - /* solaris ioctls are specific to this driver */ - case WIOCSTART: - case WIOCSTOP: - case WIOCGSTAT: - mutex_lock(&cpwd_mutex); - rval = cpwd_ioctl(file, cmd, arg); - mutex_unlock(&cpwd_mutex); - break; - - /* everything else is handled by the generic compat layer */ - default: - break; - } - - return rval; -} - static ssize_t cpwd_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { @@ -520,7 +497,7 @@ static ssize_t cpwd_read(struct file *file, char __user *buffer, static const struct file_operations cpwd_fops = { .owner = THIS_MODULE, .unlocked_ioctl = cpwd_ioctl, - .compat_ioctl = cpwd_compat_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = cpwd_open, .write = cpwd_write, .read = cpwd_read, From patchwork Wed Aug 14 20:49:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6864112C for ; Wed, 14 Aug 2019 20:54:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94DA628849 for ; Wed, 14 Aug 2019 20:54:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8807D2886A; Wed, 14 Aug 2019 20:54:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42C7728849 for ; Wed, 14 Aug 2019 20:53:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729743AbfHNUxx (ORCPT ); Wed, 14 Aug 2019 16:53:53 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:35795 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728277AbfHNUxx (ORCPT ); Wed, 14 Aug 2019 16:53:53 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MelWf-1iWVfO0Obl-00amXq; Wed, 14 Aug 2019 22:52:55 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Wim Van Sebroeck Cc: Arnd Bergmann , Anatolij Gustschin , Jean Delvare , Guenter Roeck , Alexandre Belloni , Nicolas Ferre , Ludovic Desroches , Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, linuxppc-dev@lists.ozlabs.org, linux-um@lists.infradead.org, openipmi-developer@lists.sourceforge.net, linux-hwmon@vger.kernel.org, linux-rtc@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 06/18] compat_ioctl: move WDIOC handling into wdt drivers Date: Wed, 14 Aug 2019 22:49:18 +0200 Message-Id: <20190814205245.121691-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:a6kAScvsv50hT1NELen7zAYH9qygDTRzq1l9QB7DcbqRWok0RWQ ue90k8BQu/iaOBvJiZpGQ4f8Qcii148hcNCyHmrKkDg1K/LvLxg9qh4ubKNoDcivd00xmKV 68EjYkfBau/0VehiF7Lf2PMrPnWQgzusdxqX1nghtietn4gso6kKEotTpUqEQJkQsPJm/h3 sIym8X71cQ6aQ3pXHLs/w== X-UI-Out-Filterresults: notjunk:1;V03:K0:xe708eNlWTM=:5mcJGKR0M21Xu7L9P8i4ws EqevnUp0rVDZRF/GEUDIeyCThi9e33Zn10+WtS5tDrNc0PpLqO1C2N4AsYj0s5ZYU+V5NmIBN 6231Y+/z+rlUnwMY3vYo0oQMy5gEwDaKMV2aWktbzbBkYx444oc/4jgvIhAZcPzITvReBVUz0 PldJ4dE3xSQ8rcPUirJtrZxTeoTpe29COSnWvhlkwT8BT6rWaZd9Jq3NfhyRi7DCML738eroU M1cvYp+Cr6nnguHul8kp/d/9PRI/I4zVbDDDHlfXuUhEbidREePuupFw8uiDQm+EKkUOSdIgD 4C4MCp3JanFScoKYiXS+8/hf9ARjtNrkgPaxPctPqxQtlsGDbYplXf5AN8LX5b1u4HRBOUPIR Db4aS0v76bZoqRDMh9iSDMaUCCZpnABVVnykRabcUcRdi9sonR855xiiJYftDTWeLjj2+Sgqm 6z6JuCvPIXV//TOhZAxbLiRZPwKJqYD3eCM+8+AUGw7B6YWOgUi1M3cBoMNlzvWM/uc0Qwwdz afoTxofedf+SBSeBfYvI6KgJFngAm8FZ8HvKXjE9SpTI8IU6102qSK9Twd8vfX9ozRxohxj4G 26qS9w7frot2eCo876CnMAnBZtgIZUA0GUa7xQonNSsMABq16q27v/Z6b9cvmmF5mGHWGG8Xo cHRRE53XhfTZXY/kGKp79geBvghUtOCKomrlWp/OIv939aPMk0mM35Jrp0jkjg1XDOKpnMqBG mNYrKrxMKnNxKqwsIYHEIoa0Uoh2LfvQeQnjvw== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All watchdog drivers implement the same set of ioctl commands, and fortunately all of them are compatible between 32-bit and 64-bit architectures. Modern drivers always go through drivers/watchdog/wdt.c as an abstraction layer, but older ones implement their own file_operations on a character device for this. Move the handling from fs/compat_ioctl.c into the individual drivers. Note that most of the legacy drivers will never be used on 64-bit hardware, because they are for an old 32-bit SoC implementation, but doing them all at once is safer than trying to guess which ones do or do not need the compat_ioctl handling. Signed-off-by: Arnd Bergmann Reviewed-by: Guenter Roeck --- arch/powerpc/platforms/52xx/mpc52xx_gpt.c | 1 + arch/um/drivers/harddog_kern.c | 1 + drivers/char/ipmi/ipmi_watchdog.c | 1 + drivers/hwmon/fschmd.c | 1 + drivers/rtc/rtc-ds1374.c | 1 + drivers/watchdog/acquirewdt.c | 1 + drivers/watchdog/advantechwdt.c | 1 + drivers/watchdog/alim1535_wdt.c | 1 + drivers/watchdog/alim7101_wdt.c | 1 + drivers/watchdog/ar7_wdt.c | 1 + drivers/watchdog/at91rm9200_wdt.c | 1 + drivers/watchdog/ath79_wdt.c | 1 + drivers/watchdog/bcm63xx_wdt.c | 1 + drivers/watchdog/cpu5wdt.c | 1 + drivers/watchdog/eurotechwdt.c | 1 + drivers/watchdog/f71808e_wdt.c | 1 + drivers/watchdog/gef_wdt.c | 1 + drivers/watchdog/geodewdt.c | 1 + drivers/watchdog/ib700wdt.c | 1 + drivers/watchdog/ibmasr.c | 1 + drivers/watchdog/indydog.c | 1 + drivers/watchdog/intel_scu_watchdog.c | 1 + drivers/watchdog/iop_wdt.c | 1 + drivers/watchdog/it8712f_wdt.c | 1 + drivers/watchdog/ixp4xx_wdt.c | 1 + drivers/watchdog/ks8695_wdt.c | 1 + drivers/watchdog/m54xx_wdt.c | 1 + drivers/watchdog/machzwd.c | 1 + drivers/watchdog/mixcomwd.c | 1 + drivers/watchdog/mtx-1_wdt.c | 1 + drivers/watchdog/mv64x60_wdt.c | 1 + drivers/watchdog/nuc900_wdt.c | 1 + drivers/watchdog/nv_tco.c | 1 + drivers/watchdog/pc87413_wdt.c | 1 + drivers/watchdog/pcwd.c | 1 + drivers/watchdog/pcwd_pci.c | 1 + drivers/watchdog/pcwd_usb.c | 1 + drivers/watchdog/pika_wdt.c | 1 + drivers/watchdog/pnx833x_wdt.c | 1 + drivers/watchdog/rc32434_wdt.c | 1 + drivers/watchdog/rdc321x_wdt.c | 1 + drivers/watchdog/riowd.c | 1 + drivers/watchdog/sa1100_wdt.c | 1 + drivers/watchdog/sb_wdog.c | 1 + drivers/watchdog/sbc60xxwdt.c | 1 + drivers/watchdog/sbc7240_wdt.c | 1 + drivers/watchdog/sbc_epx_c3.c | 1 + drivers/watchdog/sbc_fitpc2_wdt.c | 1 + drivers/watchdog/sc1200wdt.c | 1 + drivers/watchdog/sc520_wdt.c | 1 + drivers/watchdog/sch311x_wdt.c | 1 + drivers/watchdog/scx200_wdt.c | 1 + drivers/watchdog/smsc37b787_wdt.c | 1 + drivers/watchdog/w83877f_wdt.c | 1 + drivers/watchdog/w83977f_wdt.c | 1 + drivers/watchdog/wafer5823wdt.c | 1 + drivers/watchdog/watchdog_dev.c | 1 + drivers/watchdog/wdrtas.c | 1 + drivers/watchdog/wdt.c | 1 + drivers/watchdog/wdt285.c | 1 + drivers/watchdog/wdt977.c | 1 + drivers/watchdog/wdt_pci.c | 1 + fs/compat_ioctl.c | 11 ----------- 63 files changed, 62 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c index ba12dc14a3d1..8c0d324f657e 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c @@ -650,6 +650,7 @@ static const struct file_operations mpc52xx_wdt_fops = { .llseek = no_llseek, .write = mpc52xx_wdt_write, .unlocked_ioctl = mpc52xx_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = mpc52xx_wdt_open, .release = mpc52xx_wdt_release, }; diff --git a/arch/um/drivers/harddog_kern.c b/arch/um/drivers/harddog_kern.c index 000cb69ba0bc..e6d4f43deba8 100644 --- a/arch/um/drivers/harddog_kern.c +++ b/arch/um/drivers/harddog_kern.c @@ -165,6 +165,7 @@ static const struct file_operations harddog_fops = { .owner = THIS_MODULE, .write = harddog_write, .unlocked_ioctl = harddog_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = harddog_open, .release = harddog_release, .llseek = no_llseek, diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 74c6d1f34132..55986e10a124 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c @@ -893,6 +893,7 @@ static const struct file_operations ipmi_wdog_fops = { .poll = ipmi_poll, .write = ipmi_write, .unlocked_ioctl = ipmi_unlocked_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = ipmi_open, .release = ipmi_close, .fasync = ipmi_fasync, diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c index fa0c2f1fb443..4136643d8e0c 100644 --- a/drivers/hwmon/fschmd.c +++ b/drivers/hwmon/fschmd.c @@ -954,6 +954,7 @@ static const struct file_operations watchdog_fops = { .release = watchdog_release, .write = watchdog_write, .unlocked_ioctl = watchdog_ioctl, + .compat_ioctl = compat_ptr_ioctl, }; diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index 225a8df1d4e9..7e73be9898ac 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c @@ -586,6 +586,7 @@ static const struct file_operations ds1374_wdt_fops = { .owner = THIS_MODULE, .read = ds1374_wdt_read, .unlocked_ioctl = ds1374_wdt_unlocked_ioctl, + .compat_ioctl = compat_ptr_ioctl, .write = ds1374_wdt_write, .open = ds1374_wdt_open, .release = ds1374_wdt_release, diff --git a/drivers/watchdog/acquirewdt.c b/drivers/watchdog/acquirewdt.c index 848db958411e..bc6f333565d3 100644 --- a/drivers/watchdog/acquirewdt.c +++ b/drivers/watchdog/acquirewdt.c @@ -221,6 +221,7 @@ static const struct file_operations acq_fops = { .llseek = no_llseek, .write = acq_write, .unlocked_ioctl = acq_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = acq_open, .release = acq_close, }; diff --git a/drivers/watchdog/advantechwdt.c b/drivers/watchdog/advantechwdt.c index 0d02bb275b3d..0e4c18a2aa42 100644 --- a/drivers/watchdog/advantechwdt.c +++ b/drivers/watchdog/advantechwdt.c @@ -220,6 +220,7 @@ static const struct file_operations advwdt_fops = { .llseek = no_llseek, .write = advwdt_write, .unlocked_ioctl = advwdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = advwdt_open, .release = advwdt_close, }; diff --git a/drivers/watchdog/alim1535_wdt.c b/drivers/watchdog/alim1535_wdt.c index c157dd3d92a3..42338c7d4540 100644 --- a/drivers/watchdog/alim1535_wdt.c +++ b/drivers/watchdog/alim1535_wdt.c @@ -362,6 +362,7 @@ static const struct file_operations ali_fops = { .llseek = no_llseek, .write = ali_write, .unlocked_ioctl = ali_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = ali_open, .release = ali_release, }; diff --git a/drivers/watchdog/alim7101_wdt.c b/drivers/watchdog/alim7101_wdt.c index c8e3ab056767..5af0358f4390 100644 --- a/drivers/watchdog/alim7101_wdt.c +++ b/drivers/watchdog/alim7101_wdt.c @@ -294,6 +294,7 @@ static const struct file_operations wdt_fops = { .open = fop_open, .release = fop_close, .unlocked_ioctl = fop_ioctl, + .compat_ioctl = compat_ptr_ioctl, }; static struct miscdevice wdt_miscdev = { diff --git a/drivers/watchdog/ar7_wdt.c b/drivers/watchdog/ar7_wdt.c index 668a1c704f28..c087027ffd5d 100644 --- a/drivers/watchdog/ar7_wdt.c +++ b/drivers/watchdog/ar7_wdt.c @@ -250,6 +250,7 @@ static const struct file_operations ar7_wdt_fops = { .owner = THIS_MODULE, .write = ar7_wdt_write, .unlocked_ioctl = ar7_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = ar7_wdt_open, .release = ar7_wdt_release, .llseek = no_llseek, diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c index 907a4545dee6..6d751eb8191d 100644 --- a/drivers/watchdog/at91rm9200_wdt.c +++ b/drivers/watchdog/at91rm9200_wdt.c @@ -213,6 +213,7 @@ static const struct file_operations at91wdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .unlocked_ioctl = at91_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = at91_wdt_open, .release = at91_wdt_close, .write = at91_wdt_write, diff --git a/drivers/watchdog/ath79_wdt.c b/drivers/watchdog/ath79_wdt.c index 2e09981fe978..9ca8e5117dd8 100644 --- a/drivers/watchdog/ath79_wdt.c +++ b/drivers/watchdog/ath79_wdt.c @@ -234,6 +234,7 @@ static const struct file_operations ath79_wdt_fops = { .llseek = no_llseek, .write = ath79_wdt_write, .unlocked_ioctl = ath79_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = ath79_wdt_open, .release = ath79_wdt_release, }; diff --git a/drivers/watchdog/bcm63xx_wdt.c b/drivers/watchdog/bcm63xx_wdt.c index e2af37c9a266..8a043b52aa2f 100644 --- a/drivers/watchdog/bcm63xx_wdt.c +++ b/drivers/watchdog/bcm63xx_wdt.c @@ -221,6 +221,7 @@ static const struct file_operations bcm63xx_wdt_fops = { .llseek = no_llseek, .write = bcm63xx_wdt_write, .unlocked_ioctl = bcm63xx_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = bcm63xx_wdt_open, .release = bcm63xx_wdt_release, }; diff --git a/drivers/watchdog/cpu5wdt.c b/drivers/watchdog/cpu5wdt.c index d6d53014cb68..9867a3a936df 100644 --- a/drivers/watchdog/cpu5wdt.c +++ b/drivers/watchdog/cpu5wdt.c @@ -187,6 +187,7 @@ static const struct file_operations cpu5wdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .unlocked_ioctl = cpu5wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = cpu5wdt_open, .write = cpu5wdt_write, .release = cpu5wdt_release, diff --git a/drivers/watchdog/eurotechwdt.c b/drivers/watchdog/eurotechwdt.c index 3a83a48abcae..f5ffa7be066e 100644 --- a/drivers/watchdog/eurotechwdt.c +++ b/drivers/watchdog/eurotechwdt.c @@ -371,6 +371,7 @@ static const struct file_operations eurwdt_fops = { .llseek = no_llseek, .write = eurwdt_write, .unlocked_ioctl = eurwdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = eurwdt_open, .release = eurwdt_release, }; diff --git a/drivers/watchdog/f71808e_wdt.c b/drivers/watchdog/f71808e_wdt.c index ff5cf1b48a4d..a30ac5b120c9 100644 --- a/drivers/watchdog/f71808e_wdt.c +++ b/drivers/watchdog/f71808e_wdt.c @@ -657,6 +657,7 @@ static const struct file_operations watchdog_fops = { .release = watchdog_release, .write = watchdog_write, .unlocked_ioctl = watchdog_ioctl, + .compat_ioctl = compat_ptr_ioctl, }; static struct miscdevice watchdog_miscdev = { diff --git a/drivers/watchdog/gef_wdt.c b/drivers/watchdog/gef_wdt.c index 7d5f56994f09..f6541d1b65e3 100644 --- a/drivers/watchdog/gef_wdt.c +++ b/drivers/watchdog/gef_wdt.c @@ -248,6 +248,7 @@ static const struct file_operations gef_wdt_fops = { .llseek = no_llseek, .write = gef_wdt_write, .unlocked_ioctl = gef_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = gef_wdt_open, .release = gef_wdt_release, }; diff --git a/drivers/watchdog/geodewdt.c b/drivers/watchdog/geodewdt.c index 8d105d98908e..9914a4283cb2 100644 --- a/drivers/watchdog/geodewdt.c +++ b/drivers/watchdog/geodewdt.c @@ -201,6 +201,7 @@ static const struct file_operations geodewdt_fops = { .llseek = no_llseek, .write = geodewdt_write, .unlocked_ioctl = geodewdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = geodewdt_open, .release = geodewdt_release, }; diff --git a/drivers/watchdog/ib700wdt.c b/drivers/watchdog/ib700wdt.c index 92fd7f33bc4d..2b65ea9451d1 100644 --- a/drivers/watchdog/ib700wdt.c +++ b/drivers/watchdog/ib700wdt.c @@ -259,6 +259,7 @@ static const struct file_operations ibwdt_fops = { .llseek = no_llseek, .write = ibwdt_write, .unlocked_ioctl = ibwdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = ibwdt_open, .release = ibwdt_close, }; diff --git a/drivers/watchdog/ibmasr.c b/drivers/watchdog/ibmasr.c index 897f7eda9e6a..4a22fe152086 100644 --- a/drivers/watchdog/ibmasr.c +++ b/drivers/watchdog/ibmasr.c @@ -344,6 +344,7 @@ static const struct file_operations asr_fops = { .llseek = no_llseek, .write = asr_write, .unlocked_ioctl = asr_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = asr_open, .release = asr_release, }; diff --git a/drivers/watchdog/indydog.c b/drivers/watchdog/indydog.c index 550358528084..9857bb74a723 100644 --- a/drivers/watchdog/indydog.c +++ b/drivers/watchdog/indydog.c @@ -152,6 +152,7 @@ static const struct file_operations indydog_fops = { .llseek = no_llseek, .write = indydog_write, .unlocked_ioctl = indydog_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = indydog_open, .release = indydog_release, }; diff --git a/drivers/watchdog/intel_scu_watchdog.c b/drivers/watchdog/intel_scu_watchdog.c index 1c85103b750b..6ad5bf3451ec 100644 --- a/drivers/watchdog/intel_scu_watchdog.c +++ b/drivers/watchdog/intel_scu_watchdog.c @@ -412,6 +412,7 @@ static const struct file_operations intel_scu_fops = { .llseek = no_llseek, .write = intel_scu_write, .unlocked_ioctl = intel_scu_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = intel_scu_open, .release = intel_scu_release, }; diff --git a/drivers/watchdog/iop_wdt.c b/drivers/watchdog/iop_wdt.c index a9ccdb9a9159..6bf68d4750de 100644 --- a/drivers/watchdog/iop_wdt.c +++ b/drivers/watchdog/iop_wdt.c @@ -202,6 +202,7 @@ static const struct file_operations iop_wdt_fops = { .llseek = no_llseek, .write = iop_wdt_write, .unlocked_ioctl = iop_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = iop_wdt_open, .release = iop_wdt_release, }; diff --git a/drivers/watchdog/it8712f_wdt.c b/drivers/watchdog/it8712f_wdt.c index 2fe1a3c499ed..2fed40d14007 100644 --- a/drivers/watchdog/it8712f_wdt.c +++ b/drivers/watchdog/it8712f_wdt.c @@ -345,6 +345,7 @@ static const struct file_operations it8712f_wdt_fops = { .llseek = no_llseek, .write = it8712f_wdt_write, .unlocked_ioctl = it8712f_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = it8712f_wdt_open, .release = it8712f_wdt_release, }; diff --git a/drivers/watchdog/ixp4xx_wdt.c b/drivers/watchdog/ixp4xx_wdt.c index 9067998759e3..09886616fd21 100644 --- a/drivers/watchdog/ixp4xx_wdt.c +++ b/drivers/watchdog/ixp4xx_wdt.c @@ -163,6 +163,7 @@ static const struct file_operations ixp4xx_wdt_fops = { .llseek = no_llseek, .write = ixp4xx_wdt_write, .unlocked_ioctl = ixp4xx_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = ixp4xx_wdt_open, .release = ixp4xx_wdt_release, }; diff --git a/drivers/watchdog/ks8695_wdt.c b/drivers/watchdog/ks8695_wdt.c index 1550ce3c5702..6f375f302135 100644 --- a/drivers/watchdog/ks8695_wdt.c +++ b/drivers/watchdog/ks8695_wdt.c @@ -221,6 +221,7 @@ static const struct file_operations ks8695wdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .unlocked_ioctl = ks8695_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = ks8695_wdt_open, .release = ks8695_wdt_close, .write = ks8695_wdt_write, diff --git a/drivers/watchdog/m54xx_wdt.c b/drivers/watchdog/m54xx_wdt.c index 752d03620f0a..22f335e1e164 100644 --- a/drivers/watchdog/m54xx_wdt.c +++ b/drivers/watchdog/m54xx_wdt.c @@ -183,6 +183,7 @@ static const struct file_operations m54xx_wdt_fops = { .llseek = no_llseek, .write = m54xx_wdt_write, .unlocked_ioctl = m54xx_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = m54xx_wdt_open, .release = m54xx_wdt_release, }; diff --git a/drivers/watchdog/machzwd.c b/drivers/watchdog/machzwd.c index cef2baf59dda..80ff94688487 100644 --- a/drivers/watchdog/machzwd.c +++ b/drivers/watchdog/machzwd.c @@ -361,6 +361,7 @@ static const struct file_operations zf_fops = { .llseek = no_llseek, .write = zf_write, .unlocked_ioctl = zf_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = zf_open, .release = zf_close, }; diff --git a/drivers/watchdog/mixcomwd.c b/drivers/watchdog/mixcomwd.c index a86faa5000f1..d387bad377c4 100644 --- a/drivers/watchdog/mixcomwd.c +++ b/drivers/watchdog/mixcomwd.c @@ -227,6 +227,7 @@ static const struct file_operations mixcomwd_fops = { .llseek = no_llseek, .write = mixcomwd_write, .unlocked_ioctl = mixcomwd_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = mixcomwd_open, .release = mixcomwd_release, }; diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c index 25a92857b217..8aa1cb4a295f 100644 --- a/drivers/watchdog/mtx-1_wdt.c +++ b/drivers/watchdog/mtx-1_wdt.c @@ -181,6 +181,7 @@ static const struct file_operations mtx1_wdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .unlocked_ioctl = mtx1_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = mtx1_wdt_open, .write = mtx1_wdt_write, .release = mtx1_wdt_release, diff --git a/drivers/watchdog/mv64x60_wdt.c b/drivers/watchdog/mv64x60_wdt.c index 74bf7144a970..0bc72dd69b70 100644 --- a/drivers/watchdog/mv64x60_wdt.c +++ b/drivers/watchdog/mv64x60_wdt.c @@ -241,6 +241,7 @@ static const struct file_operations mv64x60_wdt_fops = { .llseek = no_llseek, .write = mv64x60_wdt_write, .unlocked_ioctl = mv64x60_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = mv64x60_wdt_open, .release = mv64x60_wdt_release, }; diff --git a/drivers/watchdog/nuc900_wdt.c b/drivers/watchdog/nuc900_wdt.c index db124cebe838..bfe3e4e5d159 100644 --- a/drivers/watchdog/nuc900_wdt.c +++ b/drivers/watchdog/nuc900_wdt.c @@ -225,6 +225,7 @@ static const struct file_operations nuc900wdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .unlocked_ioctl = nuc900_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = nuc900_wdt_open, .release = nuc900_wdt_close, .write = nuc900_wdt_write, diff --git a/drivers/watchdog/nv_tco.c b/drivers/watchdog/nv_tco.c index 5f0082e300bd..d7a560e348d5 100644 --- a/drivers/watchdog/nv_tco.c +++ b/drivers/watchdog/nv_tco.c @@ -267,6 +267,7 @@ static const struct file_operations nv_tco_fops = { .llseek = no_llseek, .write = nv_tco_write, .unlocked_ioctl = nv_tco_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = nv_tco_open, .release = nv_tco_release, }; diff --git a/drivers/watchdog/pc87413_wdt.c b/drivers/watchdog/pc87413_wdt.c index 2af1a8b3f973..73fbfc99083b 100644 --- a/drivers/watchdog/pc87413_wdt.c +++ b/drivers/watchdog/pc87413_wdt.c @@ -473,6 +473,7 @@ static const struct file_operations pc87413_fops = { .llseek = no_llseek, .write = pc87413_write, .unlocked_ioctl = pc87413_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = pc87413_open, .release = pc87413_release, }; diff --git a/drivers/watchdog/pcwd.c b/drivers/watchdog/pcwd.c index c3c93e00b320..7a0587fdc52c 100644 --- a/drivers/watchdog/pcwd.c +++ b/drivers/watchdog/pcwd.c @@ -752,6 +752,7 @@ static const struct file_operations pcwd_fops = { .llseek = no_llseek, .write = pcwd_write, .unlocked_ioctl = pcwd_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = pcwd_open, .release = pcwd_close, }; diff --git a/drivers/watchdog/pcwd_pci.c b/drivers/watchdog/pcwd_pci.c index e30c1f762045..81508a42a90c 100644 --- a/drivers/watchdog/pcwd_pci.c +++ b/drivers/watchdog/pcwd_pci.c @@ -646,6 +646,7 @@ static const struct file_operations pcipcwd_fops = { .llseek = no_llseek, .write = pcipcwd_write, .unlocked_ioctl = pcipcwd_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = pcipcwd_open, .release = pcipcwd_release, }; diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c index 6727f8ab2d18..2f44af1831d0 100644 --- a/drivers/watchdog/pcwd_usb.c +++ b/drivers/watchdog/pcwd_usb.c @@ -550,6 +550,7 @@ static const struct file_operations usb_pcwd_fops = { .llseek = no_llseek, .write = usb_pcwd_write, .unlocked_ioctl = usb_pcwd_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = usb_pcwd_open, .release = usb_pcwd_release, }; diff --git a/drivers/watchdog/pika_wdt.c b/drivers/watchdog/pika_wdt.c index 205c3c68fca1..a98abd0d3146 100644 --- a/drivers/watchdog/pika_wdt.c +++ b/drivers/watchdog/pika_wdt.c @@ -214,6 +214,7 @@ static const struct file_operations pikawdt_fops = { .release = pikawdt_release, .write = pikawdt_write, .unlocked_ioctl = pikawdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, }; static struct miscdevice pikawdt_miscdev = { diff --git a/drivers/watchdog/pnx833x_wdt.c b/drivers/watchdog/pnx833x_wdt.c index aa53babf2bab..4097d076aab8 100644 --- a/drivers/watchdog/pnx833x_wdt.c +++ b/drivers/watchdog/pnx833x_wdt.c @@ -215,6 +215,7 @@ static const struct file_operations pnx833x_wdt_fops = { .llseek = no_llseek, .write = pnx833x_wdt_write, .unlocked_ioctl = pnx833x_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = pnx833x_wdt_open, .release = pnx833x_wdt_release, }; diff --git a/drivers/watchdog/rc32434_wdt.c b/drivers/watchdog/rc32434_wdt.c index a8a4b3a41a90..1dfede0abf18 100644 --- a/drivers/watchdog/rc32434_wdt.c +++ b/drivers/watchdog/rc32434_wdt.c @@ -245,6 +245,7 @@ static const struct file_operations rc32434_wdt_fops = { .llseek = no_llseek, .write = rc32434_wdt_write, .unlocked_ioctl = rc32434_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = rc32434_wdt_open, .release = rc32434_wdt_release, }; diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c index 2e608ae6cbc7..57187efeb86f 100644 --- a/drivers/watchdog/rdc321x_wdt.c +++ b/drivers/watchdog/rdc321x_wdt.c @@ -199,6 +199,7 @@ static const struct file_operations rdc321x_wdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .unlocked_ioctl = rdc321x_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = rdc321x_wdt_open, .write = rdc321x_wdt_write, .release = rdc321x_wdt_release, diff --git a/drivers/watchdog/riowd.c b/drivers/watchdog/riowd.c index b35f7be20c00..dc3c06a92f93 100644 --- a/drivers/watchdog/riowd.c +++ b/drivers/watchdog/riowd.c @@ -163,6 +163,7 @@ static const struct file_operations riowd_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .unlocked_ioctl = riowd_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = riowd_open, .write = riowd_write, .release = riowd_release, diff --git a/drivers/watchdog/sa1100_wdt.c b/drivers/watchdog/sa1100_wdt.c index cbd8c957182f..9b93be00109f 100644 --- a/drivers/watchdog/sa1100_wdt.c +++ b/drivers/watchdog/sa1100_wdt.c @@ -141,6 +141,7 @@ static const struct file_operations sa1100dog_fops = { .llseek = no_llseek, .write = sa1100dog_write, .unlocked_ioctl = sa1100dog_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = sa1100dog_open, .release = sa1100dog_release, }; diff --git a/drivers/watchdog/sb_wdog.c b/drivers/watchdog/sb_wdog.c index 202fc8d8ca5f..da2dad00d473 100644 --- a/drivers/watchdog/sb_wdog.c +++ b/drivers/watchdog/sb_wdog.c @@ -237,6 +237,7 @@ static const struct file_operations sbwdog_fops = { .llseek = no_llseek, .write = sbwdog_write, .unlocked_ioctl = sbwdog_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = sbwdog_open, .release = sbwdog_release, }; diff --git a/drivers/watchdog/sbc60xxwdt.c b/drivers/watchdog/sbc60xxwdt.c index c3151642694c..f2cbe6d880a8 100644 --- a/drivers/watchdog/sbc60xxwdt.c +++ b/drivers/watchdog/sbc60xxwdt.c @@ -280,6 +280,7 @@ static const struct file_operations wdt_fops = { .open = fop_open, .release = fop_close, .unlocked_ioctl = fop_ioctl, + .compat_ioctl = compat_ptr_ioctl, }; static struct miscdevice wdt_miscdev = { diff --git a/drivers/watchdog/sbc7240_wdt.c b/drivers/watchdog/sbc7240_wdt.c index 12cdee7d5069..0bf583b76e6b 100644 --- a/drivers/watchdog/sbc7240_wdt.c +++ b/drivers/watchdog/sbc7240_wdt.c @@ -211,6 +211,7 @@ static const struct file_operations wdt_fops = { .open = fop_open, .release = fop_close, .unlocked_ioctl = fop_ioctl, + .compat_ioctl = compat_ptr_ioctl, }; static struct miscdevice wdt_miscdev = { diff --git a/drivers/watchdog/sbc_epx_c3.c b/drivers/watchdog/sbc_epx_c3.c index 86828c28843f..5e3a9ddb952e 100644 --- a/drivers/watchdog/sbc_epx_c3.c +++ b/drivers/watchdog/sbc_epx_c3.c @@ -156,6 +156,7 @@ static const struct file_operations epx_c3_fops = { .llseek = no_llseek, .write = epx_c3_write, .unlocked_ioctl = epx_c3_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = epx_c3_open, .release = epx_c3_release, }; diff --git a/drivers/watchdog/sbc_fitpc2_wdt.c b/drivers/watchdog/sbc_fitpc2_wdt.c index 3822a60a8d2b..1b20b33879c4 100644 --- a/drivers/watchdog/sbc_fitpc2_wdt.c +++ b/drivers/watchdog/sbc_fitpc2_wdt.c @@ -186,6 +186,7 @@ static const struct file_operations fitpc2_wdt_fops = { .llseek = no_llseek, .write = fitpc2_wdt_write, .unlocked_ioctl = fitpc2_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = fitpc2_wdt_open, .release = fitpc2_wdt_release, }; diff --git a/drivers/watchdog/sc1200wdt.c b/drivers/watchdog/sc1200wdt.c index 960385a766b3..9673eb12dacd 100644 --- a/drivers/watchdog/sc1200wdt.c +++ b/drivers/watchdog/sc1200wdt.c @@ -307,6 +307,7 @@ static const struct file_operations sc1200wdt_fops = { .llseek = no_llseek, .write = sc1200wdt_write, .unlocked_ioctl = sc1200wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = sc1200wdt_open, .release = sc1200wdt_release, }; diff --git a/drivers/watchdog/sc520_wdt.c b/drivers/watchdog/sc520_wdt.c index a612128c5f80..fbe79bcc9297 100644 --- a/drivers/watchdog/sc520_wdt.c +++ b/drivers/watchdog/sc520_wdt.c @@ -336,6 +336,7 @@ static const struct file_operations wdt_fops = { .open = fop_open, .release = fop_close, .unlocked_ioctl = fop_ioctl, + .compat_ioctl = compat_ptr_ioctl, }; static struct miscdevice wdt_miscdev = { diff --git a/drivers/watchdog/sch311x_wdt.c b/drivers/watchdog/sch311x_wdt.c index 3612f1df381b..83949a385f62 100644 --- a/drivers/watchdog/sch311x_wdt.c +++ b/drivers/watchdog/sch311x_wdt.c @@ -337,6 +337,7 @@ static const struct file_operations sch311x_wdt_fops = { .llseek = no_llseek, .write = sch311x_wdt_write, .unlocked_ioctl = sch311x_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = sch311x_wdt_open, .release = sch311x_wdt_close, }; diff --git a/drivers/watchdog/scx200_wdt.c b/drivers/watchdog/scx200_wdt.c index 46268309ee9b..c94098acb78f 100644 --- a/drivers/watchdog/scx200_wdt.c +++ b/drivers/watchdog/scx200_wdt.c @@ -201,6 +201,7 @@ static const struct file_operations scx200_wdt_fops = { .llseek = no_llseek, .write = scx200_wdt_write, .unlocked_ioctl = scx200_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = scx200_wdt_open, .release = scx200_wdt_release, }; diff --git a/drivers/watchdog/smsc37b787_wdt.c b/drivers/watchdog/smsc37b787_wdt.c index f5713030d0f7..43de56acd767 100644 --- a/drivers/watchdog/smsc37b787_wdt.c +++ b/drivers/watchdog/smsc37b787_wdt.c @@ -505,6 +505,7 @@ static const struct file_operations wb_smsc_wdt_fops = { .llseek = no_llseek, .write = wb_smsc_wdt_write, .unlocked_ioctl = wb_smsc_wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = wb_smsc_wdt_open, .release = wb_smsc_wdt_release, }; diff --git a/drivers/watchdog/w83877f_wdt.c b/drivers/watchdog/w83877f_wdt.c index 6eb5185d6ea6..6b3b667e6f23 100644 --- a/drivers/watchdog/w83877f_wdt.c +++ b/drivers/watchdog/w83877f_wdt.c @@ -304,6 +304,7 @@ static const struct file_operations wdt_fops = { .open = fop_open, .release = fop_close, .unlocked_ioctl = fop_ioctl, + .compat_ioctl = compat_ptr_ioctl, }; static struct miscdevice wdt_miscdev = { diff --git a/drivers/watchdog/w83977f_wdt.c b/drivers/watchdog/w83977f_wdt.c index 16e9cbe72acc..5212e68c6b01 100644 --- a/drivers/watchdog/w83977f_wdt.c +++ b/drivers/watchdog/w83977f_wdt.c @@ -446,6 +446,7 @@ static const struct file_operations wdt_fops = { .llseek = no_llseek, .write = wdt_write, .unlocked_ioctl = wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = wdt_open, .release = wdt_release, }; diff --git a/drivers/watchdog/wafer5823wdt.c b/drivers/watchdog/wafer5823wdt.c index 6d2071a0590d..a6925847f76f 100644 --- a/drivers/watchdog/wafer5823wdt.c +++ b/drivers/watchdog/wafer5823wdt.c @@ -230,6 +230,7 @@ static const struct file_operations wafwdt_fops = { .llseek = no_llseek, .write = wafwdt_write, .unlocked_ioctl = wafwdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = wafwdt_open, .release = wafwdt_close, }; diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index dbd2ad4c9294..3858094ca6ba 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -933,6 +933,7 @@ static const struct file_operations watchdog_fops = { .owner = THIS_MODULE, .write = watchdog_write, .unlocked_ioctl = watchdog_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = watchdog_open, .release = watchdog_release, }; diff --git a/drivers/watchdog/wdrtas.c b/drivers/watchdog/wdrtas.c index 6ad7edb4a712..184a06a74f83 100644 --- a/drivers/watchdog/wdrtas.c +++ b/drivers/watchdog/wdrtas.c @@ -472,6 +472,7 @@ static const struct file_operations wdrtas_fops = { .llseek = no_llseek, .write = wdrtas_write, .unlocked_ioctl = wdrtas_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = wdrtas_open, .release = wdrtas_close, }; diff --git a/drivers/watchdog/wdt.c b/drivers/watchdog/wdt.c index 7d278b37e083..f9054cb0f8e2 100644 --- a/drivers/watchdog/wdt.c +++ b/drivers/watchdog/wdt.c @@ -523,6 +523,7 @@ static const struct file_operations wdt_fops = { .llseek = no_llseek, .write = wdt_write, .unlocked_ioctl = wdt_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = wdt_open, .release = wdt_release, }; diff --git a/drivers/watchdog/wdt285.c b/drivers/watchdog/wdt285.c index 4eacfb1ce1ac..4ec0580da76d 100644 --- a/drivers/watchdog/wdt285.c +++ b/drivers/watchdog/wdt285.c @@ -181,6 +181,7 @@ static const struct file_operations watchdog_fops = { .llseek = no_llseek, .write = watchdog_write, .unlocked_ioctl = watchdog_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = watchdog_open, .release = watchdog_release, }; diff --git a/drivers/watchdog/wdt977.c b/drivers/watchdog/wdt977.c index 5c52c73e1839..066a4fb4d75b 100644 --- a/drivers/watchdog/wdt977.c +++ b/drivers/watchdog/wdt977.c @@ -422,6 +422,7 @@ static const struct file_operations wdt977_fops = { .llseek = no_llseek, .write = wdt977_write, .unlocked_ioctl = wdt977_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = wdt977_open, .release = wdt977_release, }; diff --git a/drivers/watchdog/wdt_pci.c b/drivers/watchdog/wdt_pci.c index 66303ab95685..e528024faa41 100644 --- a/drivers/watchdog/wdt_pci.c +++ b/drivers/watchdog/wdt_pci.c @@ -566,6 +566,7 @@ static const struct file_operations wdtpci_fops = { .llseek = no_llseek, .write = wdtpci_write, .unlocked_ioctl = wdtpci_ioctl, + .compat_ioctl = compat_ptr_ioctl, .open = wdtpci_open, .release = wdtpci_release, }; diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index b20228c19ccd..10ba2d9e20bc 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -412,17 +412,6 @@ COMPATIBLE_IOCTL(PPPIOCDISCONN) COMPATIBLE_IOCTL(PPPIOCATTCHAN) COMPATIBLE_IOCTL(PPPIOCGCHAN) COMPATIBLE_IOCTL(PPPIOCGL2TPSTATS) -/* Watchdog */ -COMPATIBLE_IOCTL(WDIOC_GETSUPPORT) -COMPATIBLE_IOCTL(WDIOC_GETSTATUS) -COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS) -COMPATIBLE_IOCTL(WDIOC_GETTEMP) -COMPATIBLE_IOCTL(WDIOC_SETOPTIONS) -COMPATIBLE_IOCTL(WDIOC_KEEPALIVE) -COMPATIBLE_IOCTL(WDIOC_SETTIMEOUT) -COMPATIBLE_IOCTL(WDIOC_GETTIMEOUT) -COMPATIBLE_IOCTL(WDIOC_SETPRETIMEOUT) -COMPATIBLE_IOCTL(WDIOC_GETPRETIMEOUT) }; /* From patchwork Wed Aug 14 20:49:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3BD5B112C for ; Wed, 14 Aug 2019 20:54:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A58928857 for ; Wed, 14 Aug 2019 20:54:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BE4328864; Wed, 14 Aug 2019 20:54:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E23B2886F for ; Wed, 14 Aug 2019 20:54:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729820AbfHNUyQ (ORCPT ); Wed, 14 Aug 2019 16:54:16 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:42871 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727975AbfHNUyP (ORCPT ); Wed, 14 Aug 2019 16:54:15 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MnWx3-1ifH7b3rC1-00jcFW; Wed, 14 Aug 2019 22:53:43 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Jens Axboe , Doug Gilbert , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Arnd Bergmann , Chaitanya Kulkarni , Thomas Gleixner , Mauro Carvalho Chehab , Omar Sandoval , linux-block@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [PATCH v5 07/18] compat_ioctl: reimplement SG_IO handling Date: Wed, 14 Aug 2019 22:49:19 +0200 Message-Id: <20190814205245.121691-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:/JQAz9jbmNi46KdiXkmQBzuzdZGvU7yA4i2fYTIxsCWcn54Byn+ cZSLNL4wecRpJeB91mHzyKN9NNSJ3ULDskRlMVxYXOTO+ptqPBOWuE58W/Zey9cnvoZ/ovy UtgaVm4/NG8hfni+6Js5WJEi9KApQ25Y7TnAG3cmdBsqsQ8OO8jvecnRbTxzrYgpjHl8s0+ 1ND4U/lB+ZPB8uDowQj2A== X-UI-Out-Filterresults: notjunk:1;V03:K0:8FuODb/6KPU=:gOdtUHMZdpbvut9olHBgd6 DkWH+wqXU9cvMxiHCdC7DpM+xeDBjcinYvg6WNWYeaj+wYQbEzD5y2kIWP3/YI+QE8X4JlbWa HHzWST7F5eSSyDYa6Lyqw52NH+kE7eiZrsE9XK6u7RgELNEYIsUPJaNgBLRcHEVaxMmUIsYrF B/0PGqDsjudRd9blhA+aVRqYyOD34HrfPcw9NvRuao434oNgDHXaz3mH0gceEbaDf1NTP4M5w rrAJqJd6Ph/Dq2cOqKVMA1Cj93HScfjd6FKChJzpSKo1uf2Qc+TbstnF17fkRyzaMcERJqafW LKAzVdDVRG+H1nD+8BIIxwzJFBetCVeSsXvXzq4VNE/8R1UxjnePVJCsm53Hfj+qNmlq98xAY zaHRxnP0YfP0JZcv5U53SGBr2kb6jRaFdBSczcpsofU1h94f8BuVhWEMlGCIFMpkiP53xNL0A mYO44gp5h+PsmbqExAuPH0Ib88cJpIpjxWN13J5h4biRGxb/CN7uVR/OfmFv2pkiVGGBXeQ8w YJ+GWIeoiP0tUNkgQDI2bWuYc/avQYRsR3iwOcfnL0re5lBCGK0IQ/oeP/PSkScluXXYukOnJ 6Yy6wC1JZfnd+oJ/YqNobNEOdq4AvN6HOOqP7tkIgJ9oELugIb4ZWxPVtfDypetursZmtMZJa WsmPAITMwAtWde59K0qUUhAcAuQB1IOgNkSeqCCzJA7cvi/Ac7gFPsNaLizPQegTo0twTblmG DnjtAd4YwQ+B78088p9b4g9buz+WkDP4iR238A== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are two code locations that implement the SG_IO ioctl: the old sg.c driver, and the generic scsi_ioctl helper that is in turn used by multiple drivers. To eradicate the old compat_ioctl conversion handler for the SG_IO command, I implement a readable pair of put_sg_io_hdr() /get_sg_io_hdr() helper functions that can be used for both compat and native mode, and then I call this from both drivers. For the iovec handling, there is already a compat_import_iovec() function that can simply be called in place of import_iovec(). To avoid having to pass the compat/native state through multiple indirections, I mark the SG_IO command itself as compatible in fs/compat_ioctl.c and use in_compat_syscall() to figure out where we are called from. As a side-effect of this, the sg.c driver now also accepts the 32-bit sg_io_hdr format in compat mode using the read/write interface, not just ioctl. This should improve compatiblity with old 32-bit binaries, but it would break if any application intentionally passes the 64-bit data structure in compat mode here. Signed-off-by: Arnd Bergmann --- block/scsi_ioctl.c | 132 ++++++++++++++++++++++++++++++++++-- drivers/scsi/sg.c | 19 +++--- fs/compat_ioctl.c | 148 +---------------------------------------- include/linux/blkdev.h | 2 + lib/iov_iter.c | 1 + 5 files changed, 143 insertions(+), 159 deletions(-) diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index f5e0ad65e86a..cbeb629ee917 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c @@ -2,6 +2,7 @@ /* * Copyright (C) 2001 Jens Axboe */ +#include #include #include #include @@ -327,7 +328,14 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk, struct iov_iter i; struct iovec *iov = NULL; - ret = import_iovec(rq_data_dir(rq), +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) + ret = compat_import_iovec(rq_data_dir(rq), + hdr->dxferp, hdr->iovec_count, + 0, &iov, &i); + else +#endif + ret = import_iovec(rq_data_dir(rq), hdr->dxferp, hdr->iovec_count, 0, &iov, &i); if (ret < 0) @@ -542,6 +550,122 @@ static inline int blk_send_start_stop(struct request_queue *q, return __blk_send_generic(q, bd_disk, GPCMD_START_STOP_UNIT, data); } +#ifdef CONFIG_COMPAT +struct compat_sg_io_hdr { + compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */ + compat_int_t dxfer_direction; /* [i] data transfer direction */ + unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */ + unsigned char mx_sb_len; /* [i] max length to write to sbp */ + unsigned short iovec_count; /* [i] 0 implies no scatter gather */ + compat_uint_t dxfer_len; /* [i] byte count of data transfer */ + compat_uint_t dxferp; /* [i], [*io] points to data transfer memory + or scatter gather list */ + compat_uptr_t cmdp; /* [i], [*i] points to command to perform */ + compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */ + compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */ + compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */ + compat_int_t pack_id; /* [i->o] unused internally (normally) */ + compat_uptr_t usr_ptr; /* [i->o] unused internally */ + unsigned char status; /* [o] scsi status */ + unsigned char masked_status; /* [o] shifted, masked scsi status */ + unsigned char msg_status; /* [o] messaging level data (optional) */ + unsigned char sb_len_wr; /* [o] byte count actually written to sbp */ + unsigned short host_status; /* [o] errors from host adapter */ + unsigned short driver_status; /* [o] errors from software driver */ + compat_int_t resid; /* [o] dxfer_len - actual_transferred */ + compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */ + compat_uint_t info; /* [o] auxiliary information */ +}; +#endif + +int put_sg_io_hdr(const struct sg_io_hdr *hdr, void __user *argp) +{ +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) { + struct compat_sg_io_hdr hdr32 = { + .interface_id = hdr->interface_id, + .dxfer_direction = hdr->dxfer_direction, + .cmd_len = hdr->cmd_len, + .mx_sb_len = hdr->mx_sb_len, + .iovec_count = hdr->iovec_count, + .dxfer_len = hdr->dxfer_len, + .dxferp = (uintptr_t)hdr->dxferp, + .cmdp = (uintptr_t)hdr->cmdp, + .sbp = (uintptr_t)hdr->sbp, + .timeout = hdr->timeout, + .flags = hdr->flags, + .pack_id = hdr->pack_id, + .usr_ptr = (uintptr_t)hdr->usr_ptr, + .status = hdr->status, + .masked_status = hdr->masked_status, + .msg_status = hdr->msg_status, + .sb_len_wr = hdr->sb_len_wr, + .host_status = hdr->host_status, + .driver_status = hdr->driver_status, + .resid = hdr->resid, + .duration = hdr->duration, + .info = hdr->info, + }; + + if (copy_to_user(argp, &hdr32, sizeof(hdr))) + return -EFAULT; + + return 0; + } +#endif + + if (copy_to_user(argp, &hdr, sizeof(hdr))) + return -EFAULT; + + return 0; +} +EXPORT_SYMBOL(put_sg_io_hdr); + +int get_sg_io_hdr(struct sg_io_hdr *hdr, const void __user *argp) +{ +#ifdef CONFIG_COMPAT + struct compat_sg_io_hdr hdr32; + + if (in_compat_syscall()) { + if (copy_from_user(&hdr32, argp, sizeof(hdr32))) + return -EFAULT; + + *hdr = (struct sg_io_hdr) { + .interface_id = hdr32.interface_id, + .dxfer_direction = hdr32.dxfer_direction, + .cmd_len = hdr32.cmd_len, + .mx_sb_len = hdr32.mx_sb_len, + .iovec_count = hdr32.iovec_count, + .dxfer_len = hdr32.dxfer_len, + .dxferp = compat_ptr(hdr32.dxferp), + .cmdp = compat_ptr(hdr32.cmdp), + .sbp = compat_ptr(hdr32.sbp), + .timeout = hdr32.timeout, + .flags = hdr32.flags, + .pack_id = hdr32.pack_id, + .usr_ptr = compat_ptr(hdr32.usr_ptr), + .status = hdr32.status, + .masked_status = hdr32.masked_status, + .msg_status = hdr32.msg_status, + .sb_len_wr = hdr32.sb_len_wr, + .host_status = hdr32.host_status, + .driver_status = hdr32.driver_status, + .resid = hdr32.resid, + .duration = hdr32.duration, + .info = hdr32.info, + }; + + return 0; + } +#endif + + if (copy_from_user(&hdr, argp, sizeof(hdr))) + return -EFAULT; + + return 0; +} +EXPORT_SYMBOL(get_sg_io_hdr); + int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t mode, unsigned int cmd, void __user *arg) { @@ -581,14 +705,14 @@ int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t mod case SG_IO: { struct sg_io_hdr hdr; - err = -EFAULT; - if (copy_from_user(&hdr, arg, sizeof(hdr))) + err = get_sg_io_hdr(&hdr, arg); + if (err) break; err = sg_io(q, bd_disk, &hdr, mode); if (err == -EFAULT) break; - if (copy_to_user(arg, &hdr, sizeof(hdr))) + if (put_sg_io_hdr(&hdr, arg)) err = -EFAULT; break; } diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index cce757506383..8ae096af2667 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -447,8 +447,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) retval = -ENOMEM; goto free_old_hdr; } - retval =__copy_from_user - (new_hdr, buf, SZ_SG_IO_HDR); + retval = get_sg_io_hdr(new_hdr, buf); req_pack_id = new_hdr->pack_id; kfree(new_hdr); if (retval) { @@ -589,10 +588,7 @@ sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) } if (hp->masked_status || hp->host_status || hp->driver_status) hp->info |= SG_INFO_CHECK; - if (copy_to_user(buf, hp, SZ_SG_IO_HDR)) { - err = -EFAULT; - goto err_out; - } + err = put_sg_io_hdr(hp, buf); err_out: err2 = sg_finish_rem_req(srp); sg_remove_request(sfp, srp); @@ -735,7 +731,7 @@ sg_new_write(Sg_fd *sfp, struct file *file, const char __user *buf, } srp->sg_io_owned = sg_io_owned; hp = &srp->header; - if (__copy_from_user(hp, buf, SZ_SG_IO_HDR)) { + if (get_sg_io_hdr(hp, buf)) { sg_remove_request(sfp, srp); return -EFAULT; } @@ -1797,7 +1793,14 @@ sg_start_req(Sg_request *srp, unsigned char *cmd) struct iovec *iov = NULL; struct iov_iter i; - res = import_iovec(rw, hp->dxferp, iov_count, 0, &iov, &i); +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) + res = compat_import_iovec(rw, hp->dxferp, iov_count, + 0, &iov, &i); + else +#endif + res = import_iovec(rw, hp->dxferp, iov_count, + 0, &iov, &i); if (res < 0) return res; diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 10ba2d9e20bc..f279e77df256 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -64,151 +64,6 @@ static int do_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } #ifdef CONFIG_BLOCK -typedef struct sg_io_hdr32 { - compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */ - compat_int_t dxfer_direction; /* [i] data transfer direction */ - unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */ - unsigned char mx_sb_len; /* [i] max length to write to sbp */ - unsigned short iovec_count; /* [i] 0 implies no scatter gather */ - compat_uint_t dxfer_len; /* [i] byte count of data transfer */ - compat_uint_t dxferp; /* [i], [*io] points to data transfer memory - or scatter gather list */ - compat_uptr_t cmdp; /* [i], [*i] points to command to perform */ - compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */ - compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */ - compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */ - compat_int_t pack_id; /* [i->o] unused internally (normally) */ - compat_uptr_t usr_ptr; /* [i->o] unused internally */ - unsigned char status; /* [o] scsi status */ - unsigned char masked_status; /* [o] shifted, masked scsi status */ - unsigned char msg_status; /* [o] messaging level data (optional) */ - unsigned char sb_len_wr; /* [o] byte count actually written to sbp */ - unsigned short host_status; /* [o] errors from host adapter */ - unsigned short driver_status; /* [o] errors from software driver */ - compat_int_t resid; /* [o] dxfer_len - actual_transferred */ - compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */ - compat_uint_t info; /* [o] auxiliary information */ -} sg_io_hdr32_t; /* 64 bytes long (on sparc32) */ - -typedef struct sg_iovec32 { - compat_uint_t iov_base; - compat_uint_t iov_len; -} sg_iovec32_t; - -static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count) -{ - sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1); - sg_iovec32_t __user *iov32 = dxferp; - int i; - - for (i = 0; i < iovec_count; i++) { - u32 base, len; - - if (get_user(base, &iov32[i].iov_base) || - get_user(len, &iov32[i].iov_len) || - put_user(compat_ptr(base), &iov[i].iov_base) || - put_user(len, &iov[i].iov_len)) - return -EFAULT; - } - - if (put_user(iov, &sgio->dxferp)) - return -EFAULT; - return 0; -} - -static int sg_ioctl_trans(struct file *file, unsigned int cmd, - sg_io_hdr32_t __user *sgio32) -{ - sg_io_hdr_t __user *sgio; - u16 iovec_count; - u32 data; - void __user *dxferp; - int err; - int interface_id; - - if (get_user(interface_id, &sgio32->interface_id)) - return -EFAULT; - if (interface_id != 'S') - return do_ioctl(file, cmd, (unsigned long)sgio32); - - if (get_user(iovec_count, &sgio32->iovec_count)) - return -EFAULT; - - { - void __user *top = compat_alloc_user_space(0); - void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) + - (iovec_count * sizeof(sg_iovec_t))); - if (new > top) - return -EINVAL; - - sgio = new; - } - - /* Ok, now construct. */ - if (copy_in_user(&sgio->interface_id, &sgio32->interface_id, - (2 * sizeof(int)) + - (2 * sizeof(unsigned char)) + - (1 * sizeof(unsigned short)) + - (1 * sizeof(unsigned int)))) - return -EFAULT; - - if (get_user(data, &sgio32->dxferp)) - return -EFAULT; - dxferp = compat_ptr(data); - if (iovec_count) { - if (sg_build_iovec(sgio, dxferp, iovec_count)) - return -EFAULT; - } else { - if (put_user(dxferp, &sgio->dxferp)) - return -EFAULT; - } - - { - unsigned char __user *cmdp; - unsigned char __user *sbp; - - if (get_user(data, &sgio32->cmdp)) - return -EFAULT; - cmdp = compat_ptr(data); - - if (get_user(data, &sgio32->sbp)) - return -EFAULT; - sbp = compat_ptr(data); - - if (put_user(cmdp, &sgio->cmdp) || - put_user(sbp, &sgio->sbp)) - return -EFAULT; - } - - if (copy_in_user(&sgio->timeout, &sgio32->timeout, - 3 * sizeof(int))) - return -EFAULT; - - if (get_user(data, &sgio32->usr_ptr)) - return -EFAULT; - if (put_user(compat_ptr(data), &sgio->usr_ptr)) - return -EFAULT; - - err = do_ioctl(file, cmd, (unsigned long) sgio); - - if (err >= 0) { - void __user *datap; - - if (copy_in_user(&sgio32->pack_id, &sgio->pack_id, - sizeof(int)) || - get_user(datap, &sgio->usr_ptr) || - put_user((u32)(unsigned long)datap, - &sgio32->usr_ptr) || - copy_in_user(&sgio32->status, &sgio->status, - (4 * sizeof(unsigned char)) + - (2 * sizeof(unsigned short)) + - (3 * sizeof(int)))) - err = -EFAULT; - } - - return err; -} - struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */ char req_state; char orphan; @@ -358,6 +213,7 @@ COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI) #endif #ifdef CONFIG_BLOCK /* SG stuff */ +COMPATIBLE_IOCTL(SG_IO) COMPATIBLE_IOCTL(SG_SET_TIMEOUT) COMPATIBLE_IOCTL(SG_GET_TIMEOUT) COMPATIBLE_IOCTL(SG_EMULATED_HOST) @@ -435,8 +291,6 @@ static long do_ioctl_trans(unsigned int cmd, case PPPIOCSACTIVE32: return ppp_sock_fprog_ioctl_trans(file, cmd, argp); #ifdef CONFIG_BLOCK - case SG_IO: - return sg_ioctl_trans(file, cmd, argp); case SG_GET_REQUEST_TABLE: return sg_grt_trans(file, cmd, argp); #endif diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1ef375dafb1c..a1050710d846 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -853,6 +853,8 @@ extern int scsi_cmd_ioctl(struct request_queue *, struct gendisk *, fmode_t, unsigned int, void __user *); extern int sg_scsi_ioctl(struct request_queue *, struct gendisk *, fmode_t, struct scsi_ioctl_command __user *); +extern int get_sg_io_hdr(struct sg_io_hdr *hdr, const void __user *argp); +extern int put_sg_io_hdr(const struct sg_io_hdr *hdr, void __user *argp); extern int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags); extern void blk_queue_exit(struct request_queue *q); diff --git a/lib/iov_iter.c b/lib/iov_iter.c index f1e0569b4539..7baaa989404b 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -1678,6 +1678,7 @@ ssize_t compat_import_iovec(int type, *iov = p == *iov ? NULL : p; return n; } +EXPORT_SYMBOL(compat_import_iovec); #endif int import_single_range(int rw, void __user *buf, size_t len, From patchwork Wed Aug 14 20:49:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E299713B1 for ; Wed, 14 Aug 2019 20:54:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D062628832 for ; Wed, 14 Aug 2019 20:54:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4D2D28849; Wed, 14 Aug 2019 20:54:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F5DB28847 for ; Wed, 14 Aug 2019 20:54:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729878AbfHNUyh (ORCPT ); Wed, 14 Aug 2019 16:54:37 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:41269 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727975AbfHNUyh (ORCPT ); Wed, 14 Aug 2019 16:54:37 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MCGag-1i7JwP394U-009SLt; Wed, 14 Aug 2019 22:54:19 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, "David S. Miller" Cc: Arnd Bergmann , Andrei Vagin , Paolo Abeni , Karsten Graul , netdev@vger.kernel.org Subject: [PATCH v5 08/18] af_unix: add compat_ioctl support Date: Wed, 14 Aug 2019 22:49:20 +0200 Message-Id: <20190814205245.121691-3-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:dUwT27CGBzz/z/iFH7wewdkdSdvlLNShWdUVQTkek3EQgS+uX41 aO37xQVV8lWb9dpiuE9I0ZERJa0FPqHjpCmKZcj+ir9N0xu8yGVdjouxyfOO1paebssUffr qFIHUeVXWToAu8bKY3jH4J6oM4rGBFcXxXSFocM5VlJMwtQfpm55zq71c40+LSOfL0EYM2P 0XPvByCAI47ETbx9fBHBQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:0WxWARh94sE=:Xue4xB86x6UmElprkOCTSD B0RU7Mme+fjdmZ+UPPS2sKwrd2CYgFR4rYrhGGPancYREaRFpTTf10oGWOo9c5WzmnNTWPEBW W0NUM3i0+I9uW64voo+O98IaKs30Y/134CBA98kYEm2XCWqBejFBQSdkfP+b2qVQXonZ9J63w HTPUMSnEU0DwBx7HvTz4xSiEULjGwulNRBHP/60rEY5klusHk0/K3sEPIlFGd8wae9sI/C83O IcF2Tq0dKVYgr8ujwHsZQt1lLEYLYD8+Kl6XjG+XWWhVdqV8vdRpn/klbbeCDRvXds5zbE+pT 6cPvUfJba/JAo/rzo/eu9Lkj8A2ro2Bo3L03C7XgrdMxSVMkGypXj8McDLEAu+NiWKXNgnSa2 Ea97VnXxEMEC1Q4eOiO5N8qz7cvG9EiCBZs0er/Wi+u6Eit1V8xxVLKUaQjLpXXnmoEmc0PQx QU4iW/syVkmeCAqSn5bT/06wb9X6WfEid1nWh/1ffRug8iQlJHLJU9QPqf2NHMP0Bl0J5ZGuN att+5GYO+07SYP75QjqK+1zRlgNf8haRXKDxXgXaPa+WwjF7wtOL9m82KWcWOLkq6cAi433rc Cgpk8kbUP8rf8H/psu300gdUx+hYbNH9ikM9+I0pOh8++YfRHDVPnteW2ccwiaXSRWTor0W0g 3qO3beKoId/KctsJlWNQjkXuSzhc4dkBQoujd1kux0Y+Oi3oW6xWZ4d8ZUEtJfAP7Nt70yTz8 KQSbA0x9pRDYgXWraziR1x2GYMR+eXSaLZ/F0w== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The af_unix protocol family has a custom ioctl command (inexplicibly based on SIOCPROTOPRIVATE), but never had a compat_ioctl handler for 32-bit applications. Since all commands are compatible here, add a trivial wrapper that performs the compat_ptr() conversion for SIOCOUTQ/SIOCINQ. SIOCUNIXFILE does not use the argument, but it doesn't hurt to also use compat_ptr() here. Fixes: ba94f3088b79 ("unix: add ioctl to open a unix socket file with O_PATH") Signed-off-by: Arnd Bergmann --- net/unix/af_unix.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 67e87db5877f..e18ca6d9f3d4 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -646,6 +646,9 @@ static __poll_t unix_poll(struct file *, struct socket *, poll_table *); static __poll_t unix_dgram_poll(struct file *, struct socket *, poll_table *); static int unix_ioctl(struct socket *, unsigned int, unsigned long); +#ifdef CONFIG_COMPAT +static int unix_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); +#endif static int unix_shutdown(struct socket *, int); static int unix_stream_sendmsg(struct socket *, struct msghdr *, size_t); static int unix_stream_recvmsg(struct socket *, struct msghdr *, size_t, int); @@ -687,6 +690,9 @@ static const struct proto_ops unix_stream_ops = { .getname = unix_getname, .poll = unix_poll, .ioctl = unix_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = unix_compat_ioctl, +#endif .listen = unix_listen, .shutdown = unix_shutdown, .setsockopt = sock_no_setsockopt, @@ -710,6 +716,9 @@ static const struct proto_ops unix_dgram_ops = { .getname = unix_getname, .poll = unix_dgram_poll, .ioctl = unix_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = unix_compat_ioctl, +#endif .listen = sock_no_listen, .shutdown = unix_shutdown, .setsockopt = sock_no_setsockopt, @@ -732,6 +741,9 @@ static const struct proto_ops unix_seqpacket_ops = { .getname = unix_getname, .poll = unix_dgram_poll, .ioctl = unix_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = unix_compat_ioctl, +#endif .listen = unix_listen, .shutdown = unix_shutdown, .setsockopt = sock_no_setsockopt, @@ -2582,6 +2594,13 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) return err; } +#ifdef CONFIG_COMPAT +static int unix_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) +{ + return unix_ioctl(sock, cmd, (unsigned long)compat_ptr(arg)); +} +#endif + static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wait) { struct sock *sk = sock->sk; From patchwork Wed Aug 14 20:49:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39B14112C for ; Wed, 14 Aug 2019 20:55:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27FE62884E for ; Wed, 14 Aug 2019 20:55:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C21E28864; Wed, 14 Aug 2019 20:55:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8EEA28867 for ; Wed, 14 Aug 2019 20:55:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729707AbfHNUzD (ORCPT ); Wed, 14 Aug 2019 16:55:03 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:47591 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726505AbfHNUzD (ORCPT ); Wed, 14 Aug 2019 16:55:03 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1N7gfa-1iKZYU3lUA-014jrh; Wed, 14 Aug 2019 22:54:45 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, "David S. Miller" Cc: Arnd Bergmann , Mario Schuknecht , Steffen Sledz , Willem de Bruijn , Johannes Berg , Deepa Dinamani , netdev@vger.kernel.org Subject: [PATCH v5 09/18] compat_ioctl: handle SIOCOUTQNSD Date: Wed, 14 Aug 2019 22:49:21 +0200 Message-Id: <20190814205245.121691-4-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:PR2kN+3b7Ibxtnk41q7Nxz/FfJzjWkTqKtlwh7QP5DaHQ4nbRYc NiBXcxAA5hJaBn1P+Fpve4A5y3aKag9gv5v2r7+a/cpLhPgwYCDqwREb86JtUgNOePqKqwO 9PFoe0Dmlm8ahvvWkFp4laELhzMZjpcMcXd+WxVvuyWNmbvw5Mmsj2C7vmluBXGG9G9Xb6L o1ewHcZ3o87tDYhM10iqw== X-UI-Out-Filterresults: notjunk:1;V03:K0:U+fzLfynvBw=:1jD0thGH+ZMq+c9jiboTLb BlplpqEkAj9npkOADezy/rfKW9RRddQR26ODkc5xHQZIs+Fy0kZq/ZLe432CGs3a0VwRwnjx0 VqDkkvkoEfFlpRC01EB5r/i9jDrEx9sixAHF6qNWlJh6EiYP9fUhr0F9RPRlDma5rD4DtKIE/ zPwg9l0mNNBuBAy+Q9qQ8AjM94seaols/Y18YZg8U3H2zUdxYQqv6NJ+4S34APo/xl2l4KYTU 5NjF2m4BbUz4WuY4WqrjJGsRc7Tu/Hzozj+8ggRZT5Fsy6cZZDd7l9hPYC2yltVnLFvfrcmuy fsU4VHZree9L45yKMAcpb3ij45dL0r1b9Ue24Z7F1wvJI4BrgJp9ENvacPx1nUmqg59tQCQ9s caHyYBeDSE0S3u4xboxsO3AkS3QomjAMQlKGMRL//NGUbIK51oqEqa8VT/259Qi1QjeqVmRHn UWRFw4Sp0v5tDl5CQhLG7/fVT2oOR6/ydrhssMiE02yfoUHC+PPGXVoBEK3dDKJ2T4jOOcv36 FtQzODhYoF073qsHUsHjrxo5L58edg/7a38nDUNPJqnuRlN9Suu40Rg4GvjaI/ESf7bx3vbPn ht3BaBZYhM3ojviYfFnuYvIVLEv/UPJBQfZ+gopabMNu30gaxLDURPasEZVGqA0YaxbBU880j vShZr4VPbPVQiHAGupjPf/3hXFS9ObrabfhHuLICA954HFV3rj5R8i0WLntB+FAhW+GBiDuM7 GHEUzvsNfRmYXh5/TzEkUp2uWojN4dFfly316Y5bcuOxOLAKUH4miD+ftlu/PGboQVXU4WsV7 uIQbo6ccew25RiZi9c12pCLbuULQg== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Unlike the normal SIOCOUTQ, SIOCOUTQNSD was never handled in compat mode. Add it to the common socket compat handler along with similar ones. Fixes: 2f4e1b397097 ("tcp: ioctl type SIOCOUTQNSD returns amount of data not sent") Signed-off-by: Arnd Bergmann --- net/socket.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/socket.c b/net/socket.c index 6a9ab7a8b1d2..a60f48ab2130 100644 --- a/net/socket.c +++ b/net/socket.c @@ -3452,6 +3452,7 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock, case SIOCSARP: case SIOCGARP: case SIOCDARP: + case SIOCOUTQNSD: case SIOCATMARK: return sock_do_ioctl(net, sock, cmd, arg); } From patchwork Wed Aug 14 20:54:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094587 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2EACA13B1 for ; Wed, 14 Aug 2019 20:55:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D46C1FE95 for ; Wed, 14 Aug 2019 20:55:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11E12287AB; Wed, 14 Aug 2019 20:55:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B231C1FE95 for ; Wed, 14 Aug 2019 20:55:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729066AbfHNUze (ORCPT ); Wed, 14 Aug 2019 16:55:34 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:41385 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbfHNUzd (ORCPT ); Wed, 14 Aug 2019 16:55:33 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1M1YtP-1i12RD37Ot-0037Zk; Wed, 14 Aug 2019 22:55:24 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby , "David S. Miller" Cc: Arnd Bergmann , netdev@vger.kernel.org Subject: [PATCH v5 10/18] compat_ioctl: move SIOCOUTQ out of compat_ioctl.c Date: Wed, 14 Aug 2019 22:54:45 +0200 Message-Id: <20190814205521.122180-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:v7fqYyRWcR/L7MO3acdXThwZvUt3754+rVJBd6ZPhL9Cl1yCVvn gRvBNyPrVt7LggG5Mq05U6BexgSi81BDnlkZvRL/ICitCUpf6PVr5WcQZfsm/JhRu14RonY JhpbPU1GooKwIudtCHSrXnUkk/6+lXaSUMxSer9mvbS7NoTAnAgkpn/4YMDl4BnUDFMoKG2 3BBh2VXHqJZ7obI2kNDLA== X-UI-Out-Filterresults: notjunk:1;V03:K0:OTDXPZE8Xv4=:2E5DZr6+h1yfYpY7TjG80/ yhaFAIdO01y38tSn7GreEwX8NdvikpQpZfsIESNDvncaZbULO1bAPcmV7icJ5SF6ZOY5MsyPo bp3ohRoxLmSPoAFk46duttwNRbrSxWbow3oILp6NpCjLoQ43RgdlvexlnuoF2oQhNLJ7EqSoA art5XsD/ibmvn6WAlp5ZZqt89xbypOiHfexeM0nyYEzX/McqmGrhH9RA//+Z6u7dWEk9P6LE/ 95hQqHRWBukJ243V84AIgtuGFTex/EOTfc1W5KxacBjUAQ/3Loe0WD0RLoK9P6g0NxnehY+c7 e74i2abMntXSY1mZRq6BKdBu3o6oC5cxvvCNw0fLarRGAMnrubCiz2aKARjSrXgFz1WMUryql kqAAIz0Vdg/zFfRNwQsuGz8HeMRBzyjpy2pXao8rfrGi4ptSHSRmrFSGJZrukgZpA3hXhPp6u K1URqKozcgtOyJMC6t4ScNFuG1XHXfLcZi8ncN8NMY9tjly4eJZZYvvFTBbLtPmNQMmcw5LaX JJAMd+2YF4KyljlxlDeZg7HQ9o5dKVHFFsSGWLrZsfoAwhdXqF4MfB2jxnNVgPpNDMR93kaqr eovNP8hFJ2xBN76Xez8054dCcmPmcKyGzbl2TrDZ5m6qgQuPXaDwN/HjQeVBMF5lq6scjvnbO nEtvlIrfNp8l5TQtY1t0UT48rdEa7JvMFa/eTUvsCEGeMSjmcTopo/HHNxi4o8Yux37kaM8Jl 3lzVNYUVo/wApcOiXf0Lag2HQHFdDWwtKieNST6f96M53tj9SUkv0sD0Dm5CWHoDkYtRCKc1M vUePiAWE6CkZkP9zEkMye3C0e5GDQ== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All users of this call are in socket or tty code, so handling it there means we can avoid the table entry in fs/compat_ioctl.c. Signed-off-by: Arnd Bergmann Reviewed-by: Greg Kroah-Hartman --- drivers/tty/tty_io.c | 1 + fs/compat_ioctl.c | 2 -- net/socket.c | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 566728fbaf3c..cee8b69c6f72 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -2755,6 +2755,7 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd, int retval = -ENOIOCTLCMD; switch (cmd) { + case TIOCOUTQ: case TIOCSTI: case TIOCGWINSZ: case TIOCSWINSZ: diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index f279e77df256..d537888f3660 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -198,8 +198,6 @@ static int ppp_scompress(struct file *file, unsigned int cmd, #define COMPATIBLE_IOCTL(cmd) XFORM((u32)cmd), static unsigned int ioctl_pointer[] = { -/* Little t */ -COMPATIBLE_IOCTL(TIOCOUTQ) #ifdef CONFIG_BLOCK /* Big S */ COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) diff --git a/net/socket.c b/net/socket.c index a60f48ab2130..371999a024fa 100644 --- a/net/socket.c +++ b/net/socket.c @@ -100,6 +100,7 @@ #include #include #include +#include #include #include #include @@ -3452,6 +3453,7 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock, case SIOCSARP: case SIOCGARP: case SIOCDARP: + case SIOCOUTQ: case SIOCOUTQNSD: case SIOCATMARK: return sock_do_ioctl(net, sock, cmd, arg); From patchwork Wed Aug 14 20:54:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F011C13B1 for ; Wed, 14 Aug 2019 20:55:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE2382884E for ; Wed, 14 Aug 2019 20:55:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D27652886A; Wed, 14 Aug 2019 20:55:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7501C2884E for ; Wed, 14 Aug 2019 20:55:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729791AbfHNUzp (ORCPT ); Wed, 14 Aug 2019 16:55:45 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:51841 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbfHNUzp (ORCPT ); Wed, 14 Aug 2019 16:55:45 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MTRAS-1hqCnc1bOG-00TlOd; Wed, 14 Aug 2019 22:55:36 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby Cc: Arnd Bergmann , Dmitry Safonov , Johan Hovold Subject: [PATCH v5 11/18] tty: handle compat PPP ioctls Date: Wed, 14 Aug 2019 22:54:46 +0200 Message-Id: <20190814205521.122180-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:y1TEGeFNHzbv3ETSzk+Ge7p4uSUBKqjD+pi67GZ8vNmcEncSU+X 1IQY9Q6UrEwfRXHUMi3/6VO1B4JiA7auIN8FTuZkAd0aan9A+Sv1fJHZCOh8CaLkgr3WNe/ mb/zuw5Ipe5QabrBL0ZBpELKzmAg9ssO4IfGKeaazgB/e3vl2JjE+Z0l3MRiYRWXE7IVYzd f6S52cChTD9gcOj6xchjg== X-UI-Out-Filterresults: notjunk:1;V03:K0:BcyhzUX7r0k=:36Bg5SmEhv6QI58j05fqOJ zRFzfLjnx2+NXJ94g6sbAlbxkt1G1kfNu0ThXI689mhlP4PlymW33q6B9YxfN8SiSfj9vsK2s NDiRg6SPt/oBWnGC9F2NZO7kGrPcTePqAOCRUd0u5Qt3BrdgMJSaNEhErHlJzKYIV6sd4cfag Vu62mgxv/3rOljIz+64aaTKk16eXsLmKQ/Ntt6G5NvpZvXphS/sJ/YzePF+vH8/uS/4YYiIjw zuD5wUuhJQM9hStTJEjztHvwVSf0/CFUfqkuXzZSCsPP6fAVfxvCcgBLhSFqABLhBZt6dRw3H ndTiIsBSaCMPtBjCHDl3NLLBr1Ep7mvhiM14AeuTsLr2s1+/vLoOaIvZ0rikQIuxD8tjVFsAt SQmdxZn/VsACNHRoiAWHSLMRfHJdte4M7xWDS/OIB8LtZeGdWicfo7vP9zLg7EHs+ZlHrZCjk Abq0duqYJur3IPp/IoLRgHTC5puRC57dblZsM1kM9AxkBmsJZ0lAVCWUmvrYnAj5g3x48/6Kz dJSJeSkjS/rLCMoHoPRVLAK//powwIz7eDzqjEX9laHSwVh2K8rXS9ayRlbnSMt7GYJZZHR1J 7jIVvNng3jE+R8ywVzIiL4VyXBGqmuAAjTh4sEmfxTZmNKxu0sMHLO1qQbNPyYjwttARiDhzm XNek1pPVFmVUsKDNE/up0qrtWiQ9qr8Xq59cY6yKBjV2rQk26bttdYWcbsKLwKZm9TQNsISbw vmxc/G7hmEN1/rxyRj5ntic86Q7RX3JObMaWyA== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Multiple tty devices are have tty devices that handle the PPPIOCGUNIT and PPPIOCGCHAN ioctls. To avoid adding a compat_ioctl handler to each of those, add it directly in tty_compat_ioctl so we can remove the calls from fs/compat_ioctl.c. Signed-off-by: Arnd Bergmann Reviewed-by: Greg Kroah-Hartman --- drivers/tty/tty_io.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index cee8b69c6f72..bf5241e0d772 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -87,6 +87,7 @@ #include #include #include +#include #include #include #include @@ -2811,6 +2812,9 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd, #endif case TIOCGSOFTCAR: case TIOCSSOFTCAR: + + case PPPIOCGCHAN: + case PPPIOCGUNIT: return tty_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); case TIOCCONS: case TIOCEXCL: From patchwork Wed Aug 14 20:54:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094591 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7693112C for ; Wed, 14 Aug 2019 20:56:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93C1028868 for ; Wed, 14 Aug 2019 20:56:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8821228885; Wed, 14 Aug 2019 20:56:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE5AE28884 for ; Wed, 14 Aug 2019 20:56:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729968AbfHNU4G (ORCPT ); Wed, 14 Aug 2019 16:56:06 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:60957 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728443AbfHNU4G (ORCPT ); Wed, 14 Aug 2019 16:56:06 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1M4K2r-1hyHIH0iDh-000MQ2; Wed, 14 Aug 2019 22:56:00 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Paul Mackerras , "David S. Miller" Cc: Arnd Bergmann , linux-ppp@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v5 12/18] compat_ioctl: unify copy-in of ppp filters Date: Wed, 14 Aug 2019 22:54:47 +0200 Message-Id: <20190814205521.122180-3-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:gweRwe3qoOfci1cVCHomKaMjKCeIGffZck0PcdeiHARYsh64WGz upSLT8xxKvAMj7GeXMKh8qZRYj3HKzPwEtlBatIM5V0lJdkWWu++ZDiIQiqWKMKxQF528up diRaGWM7UeH9O7Ovc54jU3fY41LJbxW6jks8NGuvhbepvO3gMuTbwycWxAstgnQkLEWs5IL 2QFLdzKY58dgL7NzJLu7g== X-UI-Out-Filterresults: notjunk:1;V03:K0:qbgXzQj+UpM=:nbb7CErS1GX4es59ymPfuC hKqDGMbDByRk6H8a/qM4epEHrtxYj3vUP2bIvviABQZXMrheOHOLMpQUQ/aZf1PJlsCN6pNxs yAq3JDSkqGcg5g8UGWYygW2wlZhbKM9LgyCZf3qAdeLbP405B+fuFGO+ocrwXc/DC4KD9REfm fXx6vyK7H3ilGKG/00ErzYhLgSLge+3yH/9RDw8IQNfbq1JH4M/BnrlbQdVgoN5NILd9oITbC 2yTXyRgnUi8LrA2uuKURV0P2t1yImAiTMZPqVUywP9V2CZYJbQX3wGmbuEkW56BYzcL8140vj j0nhZ2kTvZo2ADBcJ+50wF0i9mdvqNmFON2gWzG9IJCmXqsQdOf9TsT63S5AMits+gQ0FVGg/ mV/va9xv0ZtOHfB0EeyCpEkBiCyKPK961+U0xcp5TRiRrxapcVm0a6si6xnZ2+HMfpdcxQcJK 4/wdQPRTBy9ec7rXvl4f/Ui9240L463MhLw3sigcLr91FCmJqe8Wpv16UgaGODTfPNNjmZomX SHIzG8Yujp2ClNw0VVSe6mlla++Kc0Si5aUyD8vkFna56GaZXDdBrGlzUsNKd5nwkjf3eENRY YSR4LwMq9suARgyqclDMiCgUaV1nYe84vyCZ9V/f6TfR5z+Jbz6h90j7M6OUnLJW++wNUsYHs SV0m709ZFcB8JkvIvDCiG6WcG5wNRAqnlcA9dblULrNtwK0bEub5dQN+I4fwmdMPMkQU4WZ3K p0pOKIa2dCzMyTozjBZZy+cHBQyWhgA1+N4QuA== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Al Viro Now that isdn4linux is gone, the is only one implementation of PPPIOCSPASS and PPPIOCSACTIVE in ppp_generic.c, so this is where the compat_ioctl support should be implemented. The two commands are implemented in very similar ways, so introduce new helpers to allow sharing between the two and between native and compat mode. Signed-off-by: Al Viro [arnd: rebased, and added changelog text] Signed-off-by: Arnd Bergmann --- drivers/net/ppp/ppp_generic.c | 169 ++++++++++++++++++++++------------ fs/compat_ioctl.c | 37 -------- 2 files changed, 108 insertions(+), 98 deletions(-) diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index a30e41a56085..e3f207767589 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -554,29 +554,58 @@ static __poll_t ppp_poll(struct file *file, poll_table *wait) } #ifdef CONFIG_PPP_FILTER -static int get_filter(void __user *arg, struct sock_filter **p) +static struct bpf_prog *get_filter(struct sock_fprog *uprog) +{ + struct sock_fprog_kern fprog; + struct bpf_prog *res = NULL; + int err; + + if (!uprog->len) + return NULL; + + /* uprog->len is unsigned short, so no overflow here */ + fprog.len = uprog->len * sizeof(struct sock_filter); + fprog.filter = memdup_user(uprog->filter, fprog.len); + if (IS_ERR(fprog.filter)) + return ERR_CAST(fprog.filter); + + err = bpf_prog_create(&res, &fprog); + kfree(fprog.filter); + + return err ? ERR_PTR(err) : res; +} + +static struct bpf_prog *ppp_get_filter(struct sock_fprog __user *p) { struct sock_fprog uprog; - struct sock_filter *code = NULL; - int len; - if (copy_from_user(&uprog, arg, sizeof(uprog))) - return -EFAULT; + if (copy_from_user(&uprog, p, sizeof(struct sock_fprog))) + return ERR_PTR(-EFAULT); + return get_filter(&uprog); +} - if (!uprog.len) { - *p = NULL; - return 0; - } +#ifdef CONFIG_COMPAT +struct sock_fprog32 { + unsigned short len; + compat_caddr_t filter; +}; - len = uprog.len * sizeof(struct sock_filter); - code = memdup_user(uprog.filter, len); - if (IS_ERR(code)) - return PTR_ERR(code); +#define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32) +#define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32) - *p = code; - return uprog.len; +static struct bpf_prog *compat_ppp_get_filter(struct sock_fprog32 __user *p) +{ + struct sock_fprog32 uprog32; + struct sock_fprog uprog; + + if (copy_from_user(&uprog32, p, sizeof(struct sock_fprog32))) + return ERR_PTR(-EFAULT); + uprog.len = uprog32.len; + uprog.filter = compat_ptr(uprog32.filter); + return get_filter(&uprog); } -#endif /* CONFIG_PPP_FILTER */ +#endif +#endif static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -753,55 +782,25 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) #ifdef CONFIG_PPP_FILTER case PPPIOCSPASS: - { - struct sock_filter *code; - - err = get_filter(argp, &code); - if (err >= 0) { - struct bpf_prog *pass_filter = NULL; - struct sock_fprog_kern fprog = { - .len = err, - .filter = code, - }; - - err = 0; - if (fprog.filter) - err = bpf_prog_create(&pass_filter, &fprog); - if (!err) { - ppp_lock(ppp); - if (ppp->pass_filter) - bpf_prog_destroy(ppp->pass_filter); - ppp->pass_filter = pass_filter; - ppp_unlock(ppp); - } - kfree(code); - } - break; - } case PPPIOCSACTIVE: { - struct sock_filter *code; + struct bpf_prog *filter = ppp_get_filter(argp); + struct bpf_prog **which; - err = get_filter(argp, &code); - if (err >= 0) { - struct bpf_prog *active_filter = NULL; - struct sock_fprog_kern fprog = { - .len = err, - .filter = code, - }; - - err = 0; - if (fprog.filter) - err = bpf_prog_create(&active_filter, &fprog); - if (!err) { - ppp_lock(ppp); - if (ppp->active_filter) - bpf_prog_destroy(ppp->active_filter); - ppp->active_filter = active_filter; - ppp_unlock(ppp); - } - kfree(code); + if (IS_ERR(filter)) { + err = PTR_ERR(filter); + break; } + if (cmd == PPPIOCSPASS) + which = &ppp->pass_filter; + else + which = &ppp->active_filter; + ppp_lock(ppp); + if (*which) + bpf_prog_destroy(*which); + *which = filter; + ppp_unlock(ppp); + err = 0; break; } #endif /* CONFIG_PPP_FILTER */ @@ -827,6 +826,51 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return err; } +#ifdef CONFIG_COMPAT +static long ppp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct ppp_file *pf; + int err = -ENOIOCTLCMD; + void __user *argp = (void __user *)arg; + + mutex_lock(&ppp_mutex); + + pf = file->private_data; + if (pf && pf->kind == INTERFACE) { + struct ppp *ppp = PF_TO_PPP(pf); + switch (cmd) { +#ifdef CONFIG_PPP_FILTER + case PPPIOCSPASS32: + case PPPIOCSACTIVE32: + { + struct bpf_prog *filter = compat_ppp_get_filter(argp); + struct bpf_prog **which; + + if (IS_ERR(filter)) { + err = PTR_ERR(filter); + break; + } + if (cmd == PPPIOCSPASS32) + which = &ppp->pass_filter; + else + which = &ppp->active_filter; + ppp_lock(ppp); + if (*which) + bpf_prog_destroy(*which); + *which = filter; + ppp_unlock(ppp); + err = 0; + break; + } +#endif /* CONFIG_PPP_FILTER */ + } + } + mutex_unlock(&ppp_mutex); + + return err; +} +#endif + static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf, struct file *file, unsigned int cmd, unsigned long arg) { @@ -895,6 +939,9 @@ static const struct file_operations ppp_device_fops = { .write = ppp_write, .poll = ppp_poll, .unlocked_ioctl = ppp_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = ppp_compat_ioctl, +#endif .open = ppp_open, .release = ppp_release, .llseek = noop_llseek, diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index d537888f3660..eda41b2537f0 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -99,40 +99,6 @@ static int sg_grt_trans(struct file *file, } #endif /* CONFIG_BLOCK */ -struct sock_fprog32 { - unsigned short len; - compat_caddr_t filter; -}; - -#define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32) -#define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32) - -static int ppp_sock_fprog_ioctl_trans(struct file *file, - unsigned int cmd, struct sock_fprog32 __user *u_fprog32) -{ - struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog)); - void __user *fptr64; - u32 fptr32; - u16 flen; - - if (get_user(flen, &u_fprog32->len) || - get_user(fptr32, &u_fprog32->filter)) - return -EFAULT; - - fptr64 = compat_ptr(fptr32); - - if (put_user(flen, &u_fprog64->len) || - put_user(fptr64, &u_fprog64->filter)) - return -EFAULT; - - if (cmd == PPPIOCSPASS32) - cmd = PPPIOCSPASS; - else - cmd = PPPIOCSACTIVE; - - return do_ioctl(file, cmd, (unsigned long) u_fprog64); -} - struct ppp_option_data32 { compat_caddr_t ptr; u32 length; @@ -285,9 +251,6 @@ static long do_ioctl_trans(unsigned int cmd, return ppp_gidle(file, cmd, argp); case PPPIOCSCOMPRESS32: return ppp_scompress(file, cmd, argp); - case PPPIOCSPASS32: - case PPPIOCSACTIVE32: - return ppp_sock_fprog_ioctl_trans(file, cmd, argp); #ifdef CONFIG_BLOCK case SG_GET_REQUEST_TABLE: return sg_grt_trans(file, cmd, argp); From patchwork Wed Aug 14 20:54:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 296E2112C for ; Wed, 14 Aug 2019 20:56:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16C4C287BE for ; Wed, 14 Aug 2019 20:56:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8371287A6; Wed, 14 Aug 2019 20:56:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53F3528868 for ; Wed, 14 Aug 2019 20:56:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730016AbfHNU40 (ORCPT ); Wed, 14 Aug 2019 16:56:26 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:41555 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729547AbfHNU40 (ORCPT ); Wed, 14 Aug 2019 16:56:26 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1Mq33i-1icEwC2vac-00nBpN; Wed, 14 Aug 2019 22:56:18 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Paul Mackerras , "David S. Miller" Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-ppp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v5 13/18] compat_ioctl: move PPPIOCSCOMPRESS to ppp_generic Date: Wed, 14 Aug 2019 22:54:48 +0200 Message-Id: <20190814205521.122180-4-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:udnKTOM/1mbLHbQUn0rirIQLTUIu/NvLort76AdGfCbEvjij9Rk USgtylTUknlJaGhjBmz2nqZyCbQIYXNFPMTJH4ULrrssYAkJp/7sJL0fkltg22eIpao+6K1 umR/cMUFd8rXt7+qoI4/zk1KeaNniBK24hYWshdgcodDZpZNMuQqkkJFMqGTjT1JdCK30PL gV0B9aMZNrMeNMyw7OO7A== X-UI-Out-Filterresults: notjunk:1;V03:K0:zWgcd8uHvCo=:+3VhA5j2wTFJs1s/SEUYpw KCeo2xG4MKF0Be5k9nzt9GYHzSmwsPRm1t18w01/doFpLL9sfMWnYmwtTfySXJXJK8OjTbzXJ wr551CrrXcNf1Sj49t5jkpn0mf2mMXhvkPhu+CPOXk3ryranetpCWtnKQ7hAaGrLWeBYfg8dv lYujtQvHh4QTDUvzbeeB/JTlRr+ZoyX1hFnkuYl7eiMpXlhJR5RxpLsbEn66uZl5lZmdTsDzE jOkzQc4fnjOlZdaoqV6lHN2SVJBiArAVvWOLIbwTn/V2GMx+nGPUtpZc5HGBTHm3dRH+Apvnb /FcXrp+/KwOZLhfv6oKJlxScew6FX8f5kQ52PbOO5kNZCe9qPr4kXdeKeuzpyPI+iUpCbWwqA riH3MtzZWD8gl3nJi4G8fficgbzGALFBb08eQ0zJdWn5j8yJz2/8X2yqnok+zRgW5rAveI+Rt mAyqmFGBZ2To1bHW29VJ+tO17yZvpSmUPULfnl/+Id0HaISF4jnUlcW4fuLDPXHreLqlqo2Z+ Nk2nvBq3zCBxqxVaKOlA75Yqv7UDPQDaOnTCWQ5RafgvPPaijwAtOmEd+jvnw8H3XlD/0CbgY yG0JgXMi97/UYmQc5PZRAn2u+UpXLGh2gCsnZB/8GE43bCqqLHHpwsikQRNvOm5WOZ8cLzIMS JdmMrqe4OzA+FL5BSNwjOAfxVEgPcDwhrAunKJGsgtmUW1E0xIjRbVZMET0oQyaGG0XyWPAA5 3N3TXz1PUeM0DYfguvEPwrW8byNuVlZDcFRluQ== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Al Viro Rather than using a compat_alloc_user_space() buffer, moving this next to the native handler allows sharing most of the code, leaving only the user copy portion distinct. Signed-off-by: Al Viro Signed-off-by: Arnd Bergmann --- drivers/net/ppp/ppp_generic.c | 53 +++++++++++++++++++++++++---------- fs/compat_ioctl.c | 32 --------------------- 2 files changed, 38 insertions(+), 47 deletions(-) diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index e3f207767589..2ab67bad6224 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -270,7 +270,7 @@ static void ppp_mp_insert(struct ppp *ppp, struct sk_buff *skb); static struct sk_buff *ppp_mp_reconstruct(struct ppp *ppp); static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb); #endif /* CONFIG_PPP_MULTILINK */ -static int ppp_set_compress(struct ppp *ppp, unsigned long arg); +static int ppp_set_compress(struct ppp *ppp, struct ppp_option_data *data); static void ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound); static void ppp_ccp_closed(struct ppp *ppp); static struct compressor *find_compressor(int type); @@ -708,9 +708,14 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; case PPPIOCSCOMPRESS: - err = ppp_set_compress(ppp, arg); + { + struct ppp_option_data data; + if (copy_from_user(&data, argp, sizeof(data))) + err = -EFAULT; + else + err = ppp_set_compress(ppp, &data); break; - + } case PPPIOCGUNIT: if (put_user(ppp->file.index, p)) break; @@ -827,6 +832,13 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } #ifdef CONFIG_COMPAT +struct ppp_option_data32 { + compat_uptr_t ptr; + u32 length; + compat_int_t transmit; +}; +#define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32) + static long ppp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct ppp_file *pf; @@ -863,6 +875,21 @@ static long ppp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long break; } #endif /* CONFIG_PPP_FILTER */ + case PPPIOCSCOMPRESS32: + { + struct ppp_option_data32 data32; + if (copy_from_user(&data32, argp, sizeof(data32))) { + err = -EFAULT; + } else { + struct ppp_option_data data = { + .ptr = compat_ptr(data32.ptr), + .length = data32.length, + .transmit = data32.transmit + }; + err = ppp_set_compress(ppp, &data); + } + break; + } } } mutex_unlock(&ppp_mutex); @@ -2781,24 +2808,20 @@ ppp_output_wakeup(struct ppp_channel *chan) /* Process the PPPIOCSCOMPRESS ioctl. */ static int -ppp_set_compress(struct ppp *ppp, unsigned long arg) +ppp_set_compress(struct ppp *ppp, struct ppp_option_data *data) { - int err; + int err = -EFAULT; struct compressor *cp, *ocomp; - struct ppp_option_data data; void *state, *ostate; unsigned char ccp_option[CCP_MAX_OPTION_LENGTH]; - err = -EFAULT; - if (copy_from_user(&data, (void __user *) arg, sizeof(data))) - goto out; - if (data.length > CCP_MAX_OPTION_LENGTH) + if (data->length > CCP_MAX_OPTION_LENGTH) goto out; - if (copy_from_user(ccp_option, (void __user *) data.ptr, data.length)) + if (copy_from_user(ccp_option, data->ptr, data->length)) goto out; err = -EINVAL; - if (data.length < 2 || ccp_option[1] < 2 || ccp_option[1] > data.length) + if (data->length < 2 || ccp_option[1] < 2 || ccp_option[1] > data->length) goto out; cp = try_then_request_module( @@ -2808,8 +2831,8 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg) goto out; err = -ENOBUFS; - if (data.transmit) { - state = cp->comp_alloc(ccp_option, data.length); + if (data->transmit) { + state = cp->comp_alloc(ccp_option, data->length); if (state) { ppp_xmit_lock(ppp); ppp->xstate &= ~SC_COMP_RUN; @@ -2827,7 +2850,7 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg) module_put(cp->owner); } else { - state = cp->decomp_alloc(ccp_option, data.length); + state = cp->decomp_alloc(ccp_option, data->length); if (state) { ppp_recv_lock(ppp); ppp->rstate &= ~SC_DECOMP_RUN; diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index eda41b2537f0..0b5a732d7afd 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -99,13 +99,6 @@ static int sg_grt_trans(struct file *file, } #endif /* CONFIG_BLOCK */ -struct ppp_option_data32 { - compat_caddr_t ptr; - u32 length; - compat_int_t transmit; -}; -#define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32) - struct ppp_idle32 { compat_time_t xmit_idle; compat_time_t recv_idle; @@ -133,29 +126,6 @@ static int ppp_gidle(struct file *file, unsigned int cmd, return err; } -static int ppp_scompress(struct file *file, unsigned int cmd, - struct ppp_option_data32 __user *odata32) -{ - struct ppp_option_data __user *odata; - __u32 data; - void __user *datap; - - odata = compat_alloc_user_space(sizeof(*odata)); - - if (get_user(data, &odata32->ptr)) - return -EFAULT; - - datap = compat_ptr(data); - if (put_user(datap, &odata->ptr)) - return -EFAULT; - - if (copy_in_user(&odata->length, &odata32->length, - sizeof(__u32) + sizeof(int))) - return -EFAULT; - - return do_ioctl(file, PPPIOCSCOMPRESS, (unsigned long) odata); -} - /* * simple reversible transform to make our table more evenly * distributed after sorting. @@ -249,8 +219,6 @@ static long do_ioctl_trans(unsigned int cmd, switch (cmd) { case PPPIOCGIDLE32: return ppp_gidle(file, cmd, argp); - case PPPIOCSCOMPRESS32: - return ppp_scompress(file, cmd, argp); #ifdef CONFIG_BLOCK case SG_GET_REQUEST_TABLE: return sg_grt_trans(file, cmd, argp); From patchwork Wed Aug 14 20:54:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094597 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 815E013B1 for ; Wed, 14 Aug 2019 20:56:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7002F1FE95 for ; Wed, 14 Aug 2019 20:56:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6406728847; Wed, 14 Aug 2019 20:56:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF40828868 for ; Wed, 14 Aug 2019 20:56:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730048AbfHNU4x (ORCPT ); Wed, 14 Aug 2019 16:56:53 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:47397 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729385AbfHNU4x (ORCPT ); Wed, 14 Aug 2019 16:56:53 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MzR0i-1iBFr30hTU-00vKnH; Wed, 14 Aug 2019 22:56:45 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, "David S. Miller" , Jonathan Corbet , Paul Mackerras Cc: Arnd Bergmann , netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-ppp@vger.kernel.org Subject: [PATCH v5 14/18] compat_ioctl: handle PPPIOCGIDLE for 64-bit time_t Date: Wed, 14 Aug 2019 22:54:49 +0200 Message-Id: <20190814205521.122180-5-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:YPvpBTFvL5Y424x3E0kBMGJ6zBdgxHHTi8t4BTlVfozQmf4fZBs gNWQCBj+noYa2owNFNHhaYWiHeqIuSqzlhOYaXM30oDtyqr9+3pXgJqt6uGkm7wV8fHu9Qb w3b9neggVXVruCTqgepQhDDsUAyM9TfJcKPShiSbn9GGE4txA2DhblYD5oJve7Oeh1kbvp4 3puGfzaXWqPlnzHetdBMw== X-UI-Out-Filterresults: notjunk:1;V03:K0:enJiRsEo4Z8=:5wsBczWSevpQTgjH3Ir2mZ FPt66Ou8IFIN0Dn/7Ees/65xfnK1gxJD2Hq7kDwmc3WI76hI/RbjGCvFmwBXLUUSTy0rTqFNh Z6CqHm7xBqO2CckYzFTj6hO96kBuQbbvHle04hV7kikil8KbQ0/biobykbJXhqDt6uDHL7zLJ wugSmhc6xm2nRKPQsBb8saQoryrnYRuI3J+3utWhZdCTYK/6YZEJXTxkngZXYcU/cXVZZrpt9 SYry79DMmxm+niQupn+izUwrhRputcFqsUkeapfKFeOnsLzQhoPoFpN9D/YdivKD9upnKqeZl /4jon59vjn7WPti5guejqv9yjpV19uPsXmYUG6xJPttkOZ+BVoYdn/VJpjb5LLpKPVESBWuU2 nYS8pH9VF4NAq0++cAZLWMbTOrCKryB0t+1pIrb4H+HmcbGs4oyUiE2qPBy7pc3WRnwJKifTW e7jlRzITa0YntDssYNX4OnTZBBjNT8WKU4/XWzVNWAVnA8X4z4NEtcLBQgcQ7pBQ+6gJ+CboP pwiRWaH8LKVXNX0yCCt5tzC1sEG8tIrEsOx4qa86zHma0gsA9TAABi3Rr4X0xKNzwUaAO/D/m UGtZlIf1L3JMoWEK6eEZRlAmPpQUsjxyeqFiZHT+1F3lx7tyWwmORSA1bPr5SFtQRAKS1RsCD mB98iATggVu9t7ArnFSpq7GnUMneg1VM19bx/YNApcs8SJVvyrDRF98YTFMA/lyzqcrjZvVZJ p/XQOXv+Ybdyc0cgGfIMvu7NqsEtDrfaJ/A2YA== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ppp_idle structure is defined in terms of __kernel_time_t, which is defined as 'long' on all architectures, and this usage is not affected by the y2038 problem since it transports a time interval rather than an absolute time. However, the ppp user space defines the same structure as time_t, which may be 64-bit wide on new libc versions even on 32-bit architectures. It's easy enough to just handle both possible structure layouts on all architectures, to deal with the possibility that a user space ppp implementation comes with its own ppp_idle structure definition, as well as to document the fact that the driver is y2038-safe. Doing this also avoids the need for a special compat mode translation, since 32-bit and 64-bit kernels now support the same interfaces. The old 32-bit structure is also available on native 64-bit architectures now, but this is harmless. Signed-off-by: Arnd Bergmann --- Documentation/networking/ppp_generic.txt | 2 ++ drivers/net/ppp/ppp_generic.c | 19 ++++++++++---- fs/compat_ioctl.c | 32 ++---------------------- include/uapi/linux/ppp-ioctl.h | 2 ++ include/uapi/linux/ppp_defs.h | 14 +++++++++++ 5 files changed, 34 insertions(+), 35 deletions(-) diff --git a/Documentation/networking/ppp_generic.txt b/Documentation/networking/ppp_generic.txt index 61daf4b39600..fd563aff5fc9 100644 --- a/Documentation/networking/ppp_generic.txt +++ b/Documentation/networking/ppp_generic.txt @@ -378,6 +378,8 @@ an interface unit are: CONFIG_PPP_FILTER option is enabled, the set of packets which reset the transmit and receive idle timers is restricted to those which pass the `active' packet filter. + Two versions of this command exist, to deal with user space + expecting times as either 32-bit or 64-bit time_t seconds. * PPPIOCSMAXCID sets the maximum connection-ID parameter (and thus the number of connection slots) for the TCP header compressor and diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index 2ab67bad6224..6b4e227cb002 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -612,7 +612,8 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct ppp_file *pf; struct ppp *ppp; int err = -EFAULT, val, val2, i; - struct ppp_idle idle; + struct ppp_idle32 idle32; + struct ppp_idle64 idle64; struct npioctl npi; int unit, cflags; struct slcompress *vj; @@ -735,10 +736,18 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) err = 0; break; - case PPPIOCGIDLE: - idle.xmit_idle = (jiffies - ppp->last_xmit) / HZ; - idle.recv_idle = (jiffies - ppp->last_recv) / HZ; - if (copy_to_user(argp, &idle, sizeof(idle))) + case PPPIOCGIDLE32: + idle32.xmit_idle = (jiffies - ppp->last_xmit) / HZ; + idle32.recv_idle = (jiffies - ppp->last_recv) / HZ; + if (copy_to_user(argp, &idle32, sizeof(idle32))) + break; + err = 0; + break; + + case PPPIOCGIDLE64: + idle64.xmit_idle = (jiffies - ppp->last_xmit) / HZ; + idle64.recv_idle = (jiffies - ppp->last_recv) / HZ; + if (copy_to_user(argp, &idle64, sizeof(idle64))) break; err = 0; break; diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 0b5a732d7afd..f97cf698cfdd 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -99,33 +99,6 @@ static int sg_grt_trans(struct file *file, } #endif /* CONFIG_BLOCK */ -struct ppp_idle32 { - compat_time_t xmit_idle; - compat_time_t recv_idle; -}; -#define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32) - -static int ppp_gidle(struct file *file, unsigned int cmd, - struct ppp_idle32 __user *idle32) -{ - struct ppp_idle __user *idle; - __kernel_time_t xmit, recv; - int err; - - idle = compat_alloc_user_space(sizeof(*idle)); - - err = do_ioctl(file, PPPIOCGIDLE, (unsigned long) idle); - - if (!err) { - if (get_user(xmit, &idle->xmit_idle) || - get_user(recv, &idle->recv_idle) || - put_user(xmit, &idle32->xmit_idle) || - put_user(recv, &idle32->recv_idle)) - err = -EFAULT; - } - return err; -} - /* * simple reversible transform to make our table more evenly * distributed after sorting. @@ -192,7 +165,8 @@ COMPATIBLE_IOCTL(PPPIOCGDEBUG) COMPATIBLE_IOCTL(PPPIOCSDEBUG) /* PPPIOCSPASS is translated */ /* PPPIOCSACTIVE is translated */ -/* PPPIOCGIDLE is translated */ +COMPATIBLE_IOCTL(PPPIOCGIDLE32) +COMPATIBLE_IOCTL(PPPIOCGIDLE64) COMPATIBLE_IOCTL(PPPIOCNEWUNIT) COMPATIBLE_IOCTL(PPPIOCATTACH) COMPATIBLE_IOCTL(PPPIOCDETACH) @@ -217,8 +191,6 @@ static long do_ioctl_trans(unsigned int cmd, void __user *argp = compat_ptr(arg); switch (cmd) { - case PPPIOCGIDLE32: - return ppp_gidle(file, cmd, argp); #ifdef CONFIG_BLOCK case SG_GET_REQUEST_TABLE: return sg_grt_trans(file, cmd, argp); diff --git a/include/uapi/linux/ppp-ioctl.h b/include/uapi/linux/ppp-ioctl.h index 88b5f9990320..7bd2a5a75348 100644 --- a/include/uapi/linux/ppp-ioctl.h +++ b/include/uapi/linux/ppp-ioctl.h @@ -104,6 +104,8 @@ struct pppol2tp_ioc_stats { #define PPPIOCGDEBUG _IOR('t', 65, int) /* Read debug level */ #define PPPIOCSDEBUG _IOW('t', 64, int) /* Set debug level */ #define PPPIOCGIDLE _IOR('t', 63, struct ppp_idle) /* get idle time */ +#define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32) /* 32-bit times */ +#define PPPIOCGIDLE64 _IOR('t', 63, struct ppp_idle64) /* 64-bit times */ #define PPPIOCNEWUNIT _IOWR('t', 62, int) /* create new ppp unit */ #define PPPIOCATTACH _IOW('t', 61, int) /* attach to ppp unit */ #define PPPIOCDETACH _IOW('t', 60, int) /* obsolete, do not use */ diff --git a/include/uapi/linux/ppp_defs.h b/include/uapi/linux/ppp_defs.h index fff51b91b409..0039fa39a358 100644 --- a/include/uapi/linux/ppp_defs.h +++ b/include/uapi/linux/ppp_defs.h @@ -142,10 +142,24 @@ struct ppp_comp_stats { /* * The following structure records the time in seconds since * the last NP packet was sent or received. + * + * Linux implements both 32-bit and 64-bit time_t versions + * for compatibility with user space that defines ppp_idle + * based on the libc time_t. */ struct ppp_idle { __kernel_time_t xmit_idle; /* time since last NP packet sent */ __kernel_time_t recv_idle; /* time since last NP packet received */ }; +struct ppp_idle32 { + __s32 xmit_idle; /* time since last NP packet sent */ + __s32 recv_idle; /* time since last NP packet received */ +}; + +struct ppp_idle64 { + __s64 xmit_idle; /* time since last NP packet sent */ + __s64 recv_idle; /* time since last NP packet received */ +}; + #endif /* _UAPI_PPP_DEFS_H_ */ From patchwork Wed Aug 14 20:54:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC380112C for ; Wed, 14 Aug 2019 20:57:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7BA01FE95 for ; Wed, 14 Aug 2019 20:57:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB90F28832; Wed, 14 Aug 2019 20:57:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UPPERCASE_50_75 autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 752C128868 for ; Wed, 14 Aug 2019 20:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730076AbfHNU5H (ORCPT ); Wed, 14 Aug 2019 16:57:07 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:49863 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728871AbfHNU5H (ORCPT ); Wed, 14 Aug 2019 16:57:07 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1M9FSx-1htJE10LW3-006Opc; Wed, 14 Aug 2019 22:57:02 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Paul Mackerras , "David S. Miller" Cc: Arnd Bergmann , linux-ppp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v5 15/18] compat_ioctl: ppp: move simple commands into ppp_generic.c Date: Wed, 14 Aug 2019 22:54:50 +0200 Message-Id: <20190814205521.122180-6-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:fmDVahZ4CcjhOs+KQjFGAeeFwENq4LRdyWsKv0rqtggtBQdCebQ wWbcsq8NgjYrZwRjTsGXv1s7bwGqvAJ46xqweMWH/L+s61fs2bS+CYMfTP3CEAM38d/CkcJ CzWkG5VjpQaNdncFVHciiRkjivY5K925E6YiGJKoRpEBDbm2C0W2MErGEpJ7IJ8zYIDamTA en2pP+DG2us+rODng1uBA== X-UI-Out-Filterresults: notjunk:1;V03:K0:KdTmbrqSBxg=:7w6RP3+jpxgmEpOORfKjlK gA+ONjUM2BroK9CLZO4Yxbj1fimuLY+ync6FY/qLOZgahDHdFVskTUQWJbMlNrhuI6fLivyYb fe3BfGtukX4tiBfkyP4w6QV146OOpJj3ZaqKwHxyUfrFHMV9dpWmMKg5KUKsHINwIRKmjsZmD YpwYar1PCu/Fzyz3J1f45w5iLdJEKqM8hKP8H0dIW1fhqas9XCWbCMe/ACcrU19oz+oJhg4js 4ml32miZfdKjspapG2BJeCu0lLlUZ5V4TiCusWT6CGWF94kTue8F5pQ5P2HcfouOAaUDTMThs pzmJFWcbY1bXrtRkqOzn+EQJYKtZKP8ZxEBgmst5mWHkd9NMUpCO2SMBX/c/kD4Sl0JZdmq/w 7gW3Z/Wlre4fjGTJTzB22msi1HB8D2K7Jod6wwW9MICJQ5VU09YIrApjAUy5lRa5mcjMVZBU3 Ly0YOn5HCYEH8RK6iRPE29frvDvNlKvIG5NNCi2/XNBn3SFl3DsP2M/IlUUygUMT/oNg5Nndy binfmvbsmwtUNftdXBGj9k9qdH1ldhvkoGQGTPeZWxJZgKmOmAaaapN5yT7mbVBqlX4sSFMa6 wzVC5Wyp7nGpnKpijQ2XNIDd0jHUYejKM19MnbL8MXZK/cfeVMRjKY/b3ff3Ypa6bMtZLad0g +LqExuQ/M+TXYKLfyn61CFS7QjlzjbDOKY+qM2M+PfpMZUp+hjqI2GvuHB9uueKRsWMs7v3st R78SOXOPSGvt3SP+JW7IfhpEL+0T9QQNraQIK1xP2it4ovzDNJsFFhxyq5iLJp2xod3nYYyO3 MrY+PZ5DBc49CXAXtdnT1vhN5m4AA== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All ppp commands that are not already handled in ppp_compat_ioctl() are compatible, so they can now handled by calling the native ppp_ioctl() directly. Signed-off-by: Arnd Bergmann --- drivers/net/ppp/ppp_generic.c | 4 ++++ fs/compat_ioctl.c | 32 -------------------------------- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index 6b4e227cb002..ea1507c7c40e 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -903,6 +903,10 @@ static long ppp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long } mutex_unlock(&ppp_mutex); + /* all other commands have compatible arguments */ + if (err == -ENOIOCTLCMD) + err = ppp_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); + return err; } #endif diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index f97cf698cfdd..3d127bb6357a 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -144,38 +144,6 @@ COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE) COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN) COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN) #endif -/* PPP stuff */ -COMPATIBLE_IOCTL(PPPIOCGFLAGS) -COMPATIBLE_IOCTL(PPPIOCSFLAGS) -COMPATIBLE_IOCTL(PPPIOCGASYNCMAP) -COMPATIBLE_IOCTL(PPPIOCSASYNCMAP) -COMPATIBLE_IOCTL(PPPIOCGUNIT) -COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP) -COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP) -COMPATIBLE_IOCTL(PPPIOCGMRU) -COMPATIBLE_IOCTL(PPPIOCSMRU) -COMPATIBLE_IOCTL(PPPIOCSMAXCID) -COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP) -COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP) -COMPATIBLE_IOCTL(PPPIOCXFERUNIT) -/* PPPIOCSCOMPRESS is translated */ -COMPATIBLE_IOCTL(PPPIOCGNPMODE) -COMPATIBLE_IOCTL(PPPIOCSNPMODE) -COMPATIBLE_IOCTL(PPPIOCGDEBUG) -COMPATIBLE_IOCTL(PPPIOCSDEBUG) -/* PPPIOCSPASS is translated */ -/* PPPIOCSACTIVE is translated */ -COMPATIBLE_IOCTL(PPPIOCGIDLE32) -COMPATIBLE_IOCTL(PPPIOCGIDLE64) -COMPATIBLE_IOCTL(PPPIOCNEWUNIT) -COMPATIBLE_IOCTL(PPPIOCATTACH) -COMPATIBLE_IOCTL(PPPIOCDETACH) -COMPATIBLE_IOCTL(PPPIOCSMRRU) -COMPATIBLE_IOCTL(PPPIOCCONNECT) -COMPATIBLE_IOCTL(PPPIOCDISCONN) -COMPATIBLE_IOCTL(PPPIOCATTCHAN) -COMPATIBLE_IOCTL(PPPIOCGCHAN) -COMPATIBLE_IOCTL(PPPIOCGL2TPSTATS) }; /* From patchwork Wed Aug 14 20:54:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094611 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9691C1510 for ; Wed, 14 Aug 2019 20:58:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82DFF28895 for ; Wed, 14 Aug 2019 20:58:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77A6328867; Wed, 14 Aug 2019 20:58:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04D022885E for ; Wed, 14 Aug 2019 20:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730063AbfHNU6r (ORCPT ); Wed, 14 Aug 2019 16:58:47 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:54847 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729984AbfHNU6r (ORCPT ); Wed, 14 Aug 2019 16:58:47 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MWixU-1hmtSX2IDQ-00X2el; Wed, 14 Aug 2019 22:57:17 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Doug Gilbert , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Arnd Bergmann , Hannes Reinecke , linux-scsi@vger.kernel.org Subject: [PATCH v5 16/18] compat_ioctl: move SG_GET_REQUEST_TABLE handling Date: Wed, 14 Aug 2019 22:54:51 +0200 Message-Id: <20190814205521.122180-7-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Oh96NWxdPZEW/yuDMF44sbWZBSLaeWtZ7p1wHLQUZgKNUin6CaT SZsCIC9diZmfoU/GHahmeQsbLYDGVw9hBTHQoYo+YRxvApsSXI4/JvVsY94AYTDxLkf9CMi 5MpmJ74hVdE/JoAAlIpgiEZxJzKJTxI15YS2DiE/O5HamfDJ1XxqguJssl1WJOIVRNW2q/y cMHt+ifIU8CzvdCJuIrzw== X-UI-Out-Filterresults: notjunk:1;V03:K0:0HxL3DcyvMs=:Z7H2CT2juldoHXDfO9q1XL Fgz7raKdxxOXC6ou7IDYER15xW5hebo9Q0WrHIgFrXoe9Nj09LOZE1qAlCjGZk3l4H5hu+aPC DRBYOuEgMjUMonLNSKQfT3dxF11JNbxlSq0mEnrnFMpXgApAd+ceoP1pA3vOZ1p8V6mifgx5y iuJmYinYWHp0IqrhSRR5l/fdfslGO2rNu/iCpFOhHgtieX/nSqSrtKSLR60j86VsSGeWmT5+q 0vI3NSoUcZ6kQCjQ0hJjyx0OiP01uuKF3TgD7KYEn7UwKwECabMZFKmttvOG9A2I0fuxLe7lR ZgKFifwRqHJbeaPq6nwLPdBM4t9EKIw6OdbCm5IfLTmgp2w3owSEADl/GmXt42+JvYrfVG4m5 61b6jOlUBMZ/qz9xqITSIjoYcmo5+y4BgawmhjaghExwj+xro2w6uk9N2firAF8FTlnK042Oc yzFt+sEqUOqNZo8xi2RRPVAtiCtOOwRVKX9DRwxGsUEm1YUfV2OQ0AgH3BEF604YwN+igSTYL +V+Fuv3yn/h5SZahPgmffvZOj2V0pir7DGuZlTR0jZq91fgX7Fe0BhOrzsSNOlEvK8bWYtoSk YuTGG5BRHL4sNjiBwmwngw/U5fYLuwCB7SF32u7MH+MgftGGEGOpXYR1dNzCdUYt0MGESyhFp ZODj5N5oLP+p5bGOenb2BwLCrsx3quIlcHQ3swWCy/EaLhDiUQP3DnY9DhbbdhRR8nDjr7s26 bP625blLw14sfIHa1ovsph3fNpRQCgDMip3/n1ZXtiO2nlM95cS/5yeRoCpQ0hW1RP3HtfCU4 sGHgQtIR0OEy5FPnN2XiGMCtWisrQ== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP SG_GET_REQUEST_TABLE is now the last ioctl command that needs a conversion handler. This is only used in a single file, so the implementation should be there. I'm trying to simplify it in the process, to get rid of the compat_alloc_user_space() and extra copy, by adding a put_compat_request_table() function instead, which copies the data in the right format to user space. Signed-off-by: Arnd Bergmann --- drivers/scsi/sg.c | 40 ++++++++++++++++++++++++++++++----- fs/compat_ioctl.c | 54 +---------------------------------------------- 2 files changed, 36 insertions(+), 58 deletions(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 8ae096af2667..9e4ef22b3579 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -889,6 +889,33 @@ sg_fill_request_table(Sg_fd *sfp, sg_req_info_t *rinfo) } } +#ifdef CONFIG_COMPAT +struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */ + char req_state; + char orphan; + char sg_io_owned; + char problem; + int pack_id; + compat_uptr_t usr_ptr; + unsigned int duration; + int unused; +}; + +static int put_compat_request_table(struct compat_sg_req_info __user *o, + struct sg_req_info *rinfo) +{ + int i; + for (i = 0; i < SG_MAX_QUEUE; i++) { + if (copy_to_user(o + i, rinfo + i, offsetof(sg_req_info_t, usr_ptr)) || + put_user((uintptr_t)rinfo[i].usr_ptr, &o[i].usr_ptr) || + put_user(rinfo[i].duration, &o[i].duration) || + put_user(rinfo[i].unused, &o[i].unused)) + return -EFAULT; + } + return 0; +} +#endif + static long sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) { @@ -1069,9 +1096,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) val = (sdp->device ? 1 : 0); return put_user(val, ip); case SG_GET_REQUEST_TABLE: - if (!access_ok(p, SZ_SG_REQ_INFO * SG_MAX_QUEUE)) - return -EFAULT; - else { + { sg_req_info_t *rinfo; rinfo = kcalloc(SG_MAX_QUEUE, SZ_SG_REQ_INFO, @@ -1081,8 +1106,13 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) read_lock_irqsave(&sfp->rq_list_lock, iflags); sg_fill_request_table(sfp, rinfo); read_unlock_irqrestore(&sfp->rq_list_lock, iflags); - result = __copy_to_user(p, rinfo, - SZ_SG_REQ_INFO * SG_MAX_QUEUE); + #ifdef CONFIG_COMPAT + if (in_compat_syscall()) + result = put_compat_request_table(p, rinfo); + else + #endif + result = copy_to_user(p, rinfo, + SZ_SG_REQ_INFO * SG_MAX_QUEUE); result = result ? -EFAULT : 0; kfree(rinfo); return result; diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 3d127bb6357a..6837a3904b8c 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -52,53 +52,6 @@ #include -static int do_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - int err; - - err = security_file_ioctl(file, cmd, arg); - if (err) - return err; - - return vfs_ioctl(file, cmd, arg); -} - -#ifdef CONFIG_BLOCK -struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */ - char req_state; - char orphan; - char sg_io_owned; - char problem; - int pack_id; - compat_uptr_t usr_ptr; - unsigned int duration; - int unused; -}; - -static int sg_grt_trans(struct file *file, - unsigned int cmd, struct compat_sg_req_info __user *o) -{ - int err, i; - sg_req_info_t __user *r; - r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE); - err = do_ioctl(file, cmd, (unsigned long)r); - if (err < 0) - return err; - for (i = 0; i < SG_MAX_QUEUE; i++) { - void __user *ptr; - int d; - - if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) || - get_user(ptr, &r[i].usr_ptr) || - get_user(d, &r[i].duration) || - put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) || - put_user(d, &o[i].duration)) - return -EFAULT; - } - return err; -} -#endif /* CONFIG_BLOCK */ - /* * simple reversible transform to make our table more evenly * distributed after sorting. @@ -121,6 +74,7 @@ COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI) #ifdef CONFIG_BLOCK /* SG stuff */ COMPATIBLE_IOCTL(SG_IO) +COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE) COMPATIBLE_IOCTL(SG_SET_TIMEOUT) COMPATIBLE_IOCTL(SG_GET_TIMEOUT) COMPATIBLE_IOCTL(SG_EMULATED_HOST) @@ -156,13 +110,7 @@ COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN) static long do_ioctl_trans(unsigned int cmd, unsigned long arg, struct file *file) { - void __user *argp = compat_ptr(arg); - switch (cmd) { -#ifdef CONFIG_BLOCK - case SG_GET_REQUEST_TABLE: - return sg_grt_trans(file, cmd, argp); -#endif } return -ENOIOCTLCMD; From patchwork Wed Aug 14 20:54:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0EB113B1 for ; Wed, 14 Aug 2019 20:57:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E14D828847 for ; Wed, 14 Aug 2019 20:57:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D570F2887E; Wed, 14 Aug 2019 20:57:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C2E528848 for ; Wed, 14 Aug 2019 20:57:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729201AbfHNU5f (ORCPT ); Wed, 14 Aug 2019 16:57:35 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:50785 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbfHNU5f (ORCPT ); Wed, 14 Aug 2019 16:57:35 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MPowd-1hckJz13UB-00MpFs; Wed, 14 Aug 2019 22:57:32 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: Arnd Bergmann , Hannes Reinecke Subject: [PATCH v5 17/18] pktcdvd: add compat_ioctl handler Date: Wed, 14 Aug 2019 22:54:52 +0200 Message-Id: <20190814205521.122180-8-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:vtBRrSTbxRM+4N7JG/SqINjMT8OwhCCnfEV9GLfJMlj7zzHmXqL wFcQBgM7/r/60w0dHWdIX39QTgYM4f/6oLGxqnTXmb0CHbl9e834v0p2Rmzje1ZTzLFB0d4 ArUarrUL7+s3fgxa94yevKS1w3wmtdSr7o3Jo/MviF7gzdbq7Vr5Sa0PLjOc3+0XsDb7ayd Im2A9aO8g12wUfvh63IzQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:oXxoA9Saf5U=:wn2CxSLASoltE+VPtsKsmS DbM3bcSOL5toXC7kI5Wz6RafyaM3cAUqLlE3zjj3c2paNf19x+xqkxDbfmVmBPA63QSHuNvlo aNikgXHDUJ8bhRVl3ntnHP/QQQhffoJlfbuIOka54SfVt754KI6HKMfBnl1uLRKT5k4+4ItGZ /itPTJ3SDZA1hRH4ZojXudrHRYkPWnJmzt4GYzIPq3Ewf2uH0vIg2s4swG5LPGrVV4gMiUiXf 3b3TQPCWgpHmS4mBiAigr/vnrj7Ps7Lr3BVqSAR8ioWfzXjnFesSIO3H8YHlIB5VZCYnozlpK rpXwIG8gGgfZejIX2FD5CW+2QCT766pjpVsSiQlCWlsREd7u4WNA+CcS3CX7WaAIKx0z8vSe5 7obgtro6nmMuqzOTcjPLrfLt4NQNPitX7upsF5WWyhUiMBqMnhBb95qBmr61t1yaR30GgYaKa nmKXPddvpCL8Dx+/T2jw2Eh7FDG5rr/H6Sh/ti8cH0/L0PBate4GA8OTM6yV3dwtOdSIMJEmO GcI941L57d5nOl7fZDJe2DxZyjKA6RG9kcEr17w+Ff/hJ6CbTGBAhwHDt9WMZsplcRj7LdJoO yv14a5pkTALtpSrjJd9JhqIn1MVYvyoTPee7UiU5MUtw366JG52QkMRjoDzcC7CBKlnrDDJDX 47JwnZHHclHBGahHLCJehDayQgvWpgjncjEbJpYMi5AVfW8LQrzJZ1Ue1XnaOM4sMLkd2HJJb zRdDmZjFRSEBmUUiGjtz5uyZGpGQ34zVToeIOg== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP pkt_ioctl() implements the generic SCSI_IOCTL_SEND_COMMAND and some cdrom ioctls by forwarding to the underlying block device. For compat_ioctl handling, this always takes a roundtrip through fs/compat_ioctl.c that we should try to avoid, at least for the compatible commands. CDROM_SEND_PACKET is an exception here, it requires special translation in compat_blkdev_driver_ioctl(). CDROM_LAST_WRITTEN has no compat handling at the moment. Signed-off-by: Arnd Bergmann --- drivers/block/pktcdvd.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 024060165afa..b5950b7851b0 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2664,6 +2664,28 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, return ret; } +#ifdef CONFIG_COMPAT +static int pkt_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) +{ + switch (cmd) { + /* compatible */ + case CDROMEJECT: + case CDROMMULTISESSION: + case CDROMREADTOCENTRY: + case SCSI_IOCTL_SEND_COMMAND: + return pkt_ioctl(bdev, mode, cmd, (unsigned long)compat_ptr(arg)); + + + /* FIXME: no handler so far */ + case CDROM_LAST_WRITTEN: + /* handled in compat_blkdev_driver_ioctl */ + case CDROM_SEND_PACKET: + default: + return -ENOIOCTLCMD; + } +} +#endif + static unsigned int pkt_check_events(struct gendisk *disk, unsigned int clearing) { @@ -2685,6 +2707,9 @@ static const struct block_device_operations pktcdvd_ops = { .open = pkt_open, .release = pkt_close, .ioctl = pkt_ioctl, +#ifdef CONFIG_COMPAT + .ioctl = pkt_compat_ioctl, +#endif .check_events = pkt_check_events, }; From patchwork Wed Aug 14 20:54:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11094607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2C33112C for ; Wed, 14 Aug 2019 20:58:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C15D2287BE for ; Wed, 14 Aug 2019 20:58:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B52B128864; Wed, 14 Aug 2019 20:58:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E94428847 for ; Wed, 14 Aug 2019 20:58:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730097AbfHNU6I (ORCPT ); Wed, 14 Aug 2019 16:58:08 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:33739 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729752AbfHNU6I (ORCPT ); Wed, 14 Aug 2019 16:58:08 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1Mfpf7-1iVP9a30qP-00gHok; Wed, 14 Aug 2019 22:57:43 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" Cc: Arnd Bergmann , Christoph Hellwig , Tejun Heo , Bart Van Assche , Hannes Reinecke , Jens Axboe , linux-scsi@vger.kernel.org Subject: [PATCH v5 18/18] scsi: sd: enable compat ioctls for sed-opal Date: Wed, 14 Aug 2019 22:54:53 +0200 Message-Id: <20190814205521.122180-9-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190814204259.120942-1-arnd@arndb.de> References: <20190814204259.120942-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:GHU2BOUolFMuYU4JHf6S7Epw6n2I5F+s2JL2xcZ0QVFOtlz3LTM Cg1Y0P2DCMYs/77HHCx1SBY6ljRsMtpIZLwfU9oRltiVTFqbskRhozs7BR1P4kelS1oZQdf NO3WcQWcvIZWwBG0eNOOKMNkbslk2VdBMFzYBppBkPwj0oVa+cGYH4/9qltFy28mV3yE9NN os1WcG3Ajoz39bCTJnZgg== X-UI-Out-Filterresults: notjunk:1;V03:K0:zpxeGQV2Lis=:DxZ29hcJwmhH8cHBeJLpFh cbl964bB0IHU8mgW586im24i2LN4vSL9QCCunqRoHxS7JbPtdo5H45SQ6PWsw9mw/Ulb/ScC1 0wRZL4DfLEEd0+uxjvjXcsGHZWHGCFNQLqo4Q25G0MVi5VwZyzkAsDZ51/SJZ5+QyVes+Qt9I jpKCw8zab86I+Rl7XhCLexRa9CBJThsIiej6aL+7uuwzbweouesQv0N8hCkZYPSHT+ujCSWh0 kLdAOCE6Biopn5K/CGKUYmuSjZ9apaCSOVDn5i0Q6JdR0putP+DLV+uMO99uB7qL1273rW5AM aiOAT7BbnDBhLmofbzGwXZvCbgrWP9CBdLFxRXsB0Gh9sC8duzp3M3okSQ8EhDEBLKt7Xr82Y 69IHO+8bAGW0Avqxepran8c+dzq2jov2jsQrrxJqinBc6KXjj1lwSbbsVisl1WnukDYcN6k2l bXhBO2kcCQjrrjs8o/B2IdMo5vHHxsu883UHlrOuPk0+Pmdf4TrAwNirMNkik7rmJCC1VWD0M YZ4JfrKoykoTAIz6RHX4zUk0RvgX/5+6B3ms7hZ5+mWytecx9vFhvM6dbSTVopHsuOfKorbtd C/xUO8wK1iajpYzXGo+S0nhiHKBNVa/kboscA0C7kx3Ybwba60OSBHWJ1wHuQrvP5fihDvrMU 3yg76Yq3EpfucvHZpAOym5tAjj1kALpm3aXVMSJBtBSlqHml5cwYgTvD1OW8YuOeCwuxBz2fH 2hKYaB8bwrOK32MdonrxWgBxhRv5SfKCbUepsQ== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The sed_ioctl() function is written to be compatible between 32-bit and 64-bit processes, however compat mode is only wired up for nvme, not for sd. Add the missing call to sed_ioctl() in sd_compat_ioctl(). Fixes: d80210f25ff0 ("sd: add support for TCG OPAL self encrypting disks") Signed-off-by: Arnd Bergmann --- drivers/scsi/sd.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 149d406aacc9..8b71664c54bd 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1693,20 +1693,30 @@ static void sd_rescan(struct device *dev) static int sd_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { - struct scsi_device *sdev = scsi_disk(bdev->bd_disk)->device; + struct gendisk *disk = bdev->bd_disk; + struct scsi_disk *sdkp = scsi_disk(disk); + struct scsi_device *sdev = sdkp->device; + void __user *p = compat_ptr(arg); int error; + error = scsi_verify_blk_ioctl(bdev, cmd); + if (error < 0) + return error; + error = scsi_ioctl_block_when_processing_errors(sdev, cmd, (mode & FMODE_NDELAY) != 0); if (error) return error; + + if (is_sed_ioctl(cmd)) + return sed_ioctl(sdkp->opal_dev, cmd, p); /* * Let the static ioctl translation table take care of it. */ if (!sdev->host->hostt->compat_ioctl) return -ENOIOCTLCMD; - return sdev->host->hostt->compat_ioctl(sdev, cmd, (void __user *)arg); + return sdev->host->hostt->compat_ioctl(sdev, cmd, p); } #endif