From patchwork Wed Sep 12 15:13:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 146578 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4947557ljw; Wed, 12 Sep 2018 08:15:23 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY4o125WlqCAvi7YR3vL8ysHNHS7AvnmOshIXmz9qQeoVZW85WfhVzJMqi4ZSqDgFq1nlv/ X-Received: by 2002:a63:f244:: with SMTP id d4-v6mr2843951pgk.2.1536765323597; Wed, 12 Sep 2018 08:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536765323; cv=none; d=google.com; s=arc-20160816; b=fKyy+fupA7OckEoJBnUylsIDeWK/WjgVf2QYZCCRnP0s4pzFu486rKRtsXldDql5Ky ZoUpSLNG9s07g41k9GSlrVV9mhYH0TJemCg01Xaw4Bqx5/kDiGt7QlckUCSmU1RuHE43 EJ2R95/zlxl/PWBvnAz0WSpr16Wq9YMSyxOTJYRSy2f7ZdcvHs+OsH3L1rtnRT7o5aRi 0Rp4SOvmcy1Fj5QsBwkyKXivKfKFQIxrTzYYjNopfV9Q/SJapXTKiKLuawAHOmSo9w7F DIq98u8g17RIr2PTRmsg3W8M/E7ZF5p6sEEm3mPwZ063OIenHAKHRZpELd8TJvG1NfAU yDTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=GV3Clu7MthYjC+KvMy2f7+jAK/VV9Zr9BI+tTF/HIMM=; b=WggF2rYnGoJTfol0gSELcGpYvmQASSVZDFZl8IZsfK1vfUxU4tlI7N1kbZTjhVvasF uA+fjSh3Mxh1RWLi9uPtlbtyxmkH6mN2CwCsoi4ARjnF8ASs+k9xfWreJyIr8W8j8ACf SQfso9NHMdrWv4fRBSA//ShRQwQIaRhIm816zxKXpn/g2o/d61IujrgVud0LH9Cg3tH0 7Kd2WVDmjuPsDYXEuUq2BMLVNeNLt2n1JlOtWfmRc4FcNzJwdQni1F9nrNs/MfQ6qNaH XDd/5OdAEdVcSFc/0j0qsJQHajvuyaZzZNqM6uHm6ovue3aWU+T7abljY8J9U7f7GWjx UN7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r124-v6si1418508pfc.202.2018.09.12.08.15.23; Wed, 12 Sep 2018 08:15:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728003AbeILUUS (ORCPT + 32 others); Wed, 12 Sep 2018 16:20:18 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:39341 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726672AbeILUUS (ORCPT ); Wed, 12 Sep 2018 16:20:18 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPA (Nemesis) id 1Mzz6s-1ffyyT0KV4-00x52G; Wed, 12 Sep 2018 17:14:51 +0200 From: Arnd Bergmann To: viro@zeniv.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, Arnd Bergmann , Karsten Keil , Paul Bolle , Randy Dunlap , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, gigaset307x-common@lists.sourceforge.net Subject: [PATCH v2 11/17] compat_ioctl: remove isdn ioctl translation Date: Wed, 12 Sep 2018 17:13:03 +0200 Message-Id: <20180912151422.571531-2-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180912151422.571531-1-arnd@arndb.de> References: <20180912150142.157913-1-arnd@arndb.de> <20180912151422.571531-1-arnd@arndb.de> X-Provags-ID: V03:K1:sVY/sja0LHvqNLTgv5hsJPWtmXt9NlBmoBucSJdKP223QjucLmZ 4TenJF1iUocwvkGiOwoKKoST/C9UhEIRxk9Dj8dY95TzM7JKADPn6/x/mfrvd12dC75LslJ Ksxl92emuBImzB+DS1H4dKHFUv/I02Q6h/FYx56/1w/HpImf+Lmos2VhGJeEirRg2OsVN5O uoW7C5ZwYBpyWluA6GOSQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:efvwKRq9x8A=:bJKsz1lvaS2Uj5pj8nFmEm mrvuY08Ka7t622A5rXyC72QXogGbPfKdiZash5ktepftmdWmgG2yt9B5gOjx2K0WL1r2YF5Dv pAlmFMVFgMGbmDEVxcJHgp27S0unRuzc7z+AMC64vXtp7Vq2rGYDdUeLwJaL+r7wk5TqVEBA/ r8196fIzhFxN4awHbhlSVKiWYEZ2+iUTUPvSOx5x3JlKj3RsxP4SyS/Q42/j+A7thmDZMKtza zKooNZ56IB3ZBOXzjph1Ce8EOqf3pE6aVxzGCfiBSq9fopladCH/xYtRvE/iFho9yavToEL1F Q+CyWm+YIRTAHUVvtkprcXgVQVPjkmfLwKnqcno8qDJ2Zi/MQVK++AomlR4EpeTRNdJq4LtvJ jfrjpP0wfb5spt5O5xCXoMydI6jg0G/bDeyr5Hq6CRjIwgTjrpUaoZyYOFkvhka4tDxxmyH+L UeM78+PdB88O7ng4qtXRZIna847YT/+HIzaNIzm7CbktT/vdr7BlUEs7DjmWvP+OFrhEZZHB2 J169thEKbY6aiMXNFSERPmwz16ZGvLue0ps2IgV5ghj8xv9o3KhUbjHCsnNDyhprk6JgmTD9+ CpEOTWfMlwzxRCaBXStecdAJcSmy06dqsjvNRRVHYyMV33AgXzVUu+F7sBfMMOyBvvfurmbuu mUExP8tHJno7AL/AAh47MUkVyUiiper6htX9LQsa0biWBGKYTMKhs85hDviwXdYWA2K8= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Neither the old isdn4linux interface nor the newer mISDN stack ever had working 32-bit compat mode as far as I can tell. However, the CAPI stack and the Gigaset ISDN driver (implemented on top of either CAPI or i4l) have some ioctl commands that are correctly listed in fs/compat_ioctl.c. We can trivially move all of those into the two corresponding files that implement the native handlers by adding a compat_ioctl redirect to that. I did notice that treating CAPI_MANUFACTURER_CMD() as compatible is broken, so I'm also adding a handler for that, realizing that in all likelyhood, nobody is ever going to call it. Signed-off-by: Arnd Bergmann --- drivers/isdn/capi/capi.c | 31 +++++++++++++++++++++++++++++++ drivers/isdn/gigaset/interface.c | 11 +++++++++++ fs/compat_ioctl.c | 22 ---------------------- 3 files changed, 42 insertions(+), 22 deletions(-) -- 2.18.0 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index ef5560b848ab..4851dc3941eb 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c @@ -942,6 +942,34 @@ capi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return ret; } +#ifdef CONFIG_COMPAT +static long +capi_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + int ret; + + if (cmd == CAPI_MANUFACTURER_CMD) { + struct { + unsigned long cmd; + compat_uptr_t data; + } mcmd32; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + if (copy_from_user(&mcmd32, compat_ptr(arg), sizeof(mcmd32))) + return -EFAULT; + + mutex_lock(&capi_mutex); + ret = capi20_manufacturer(mcmd32.cmd, compat_ptr(mcmd32.data)); + mutex_unlock(&capi_mutex); + + return ret; + } + + return capi_unlocked_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); +} +#endif + static int capi_open(struct inode *inode, struct file *file) { struct capidev *cdev; @@ -988,6 +1016,9 @@ static const struct file_operations capi_fops = .write = capi_write, .poll = capi_poll, .unlocked_ioctl = capi_unlocked_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = capi_compat_ioctl, +#endif .open = capi_open, .release = capi_release, }; diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c index 600c79b030cd..e346756b0b45 100644 --- a/drivers/isdn/gigaset/interface.c +++ b/drivers/isdn/gigaset/interface.c @@ -233,6 +233,14 @@ static int if_ioctl(struct tty_struct *tty, return retval; } +#ifdef CONFIG_COMPAT +static long if_compat_ioctl(struct tty_struct *tty, + unsigned int cmd, unsigned long arg) +{ + return if_ioctl(tty, cmd, (unsigned long)compat_ptr(arg)); +} +#endif + static int if_tiocmget(struct tty_struct *tty) { struct cardstate *cs = tty->driver_data; @@ -472,6 +480,9 @@ static const struct tty_operations if_ops = { .open = if_open, .close = if_close, .ioctl = if_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = if_compat_ioctl, +#endif .write = if_write, .write_room = if_write_room, .chars_in_buffer = if_chars_in_buffer, diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index c28fd9f6b1e8..379e04647f83 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -60,9 +60,6 @@ #include #include -#include -#include - #ifdef CONFIG_BLOCK #include #include @@ -840,25 +837,6 @@ COMPATIBLE_IOCTL(HIDPCONNADD) COMPATIBLE_IOCTL(HIDPCONNDEL) COMPATIBLE_IOCTL(HIDPGETCONNLIST) COMPATIBLE_IOCTL(HIDPGETCONNINFO) -/* CAPI */ -COMPATIBLE_IOCTL(CAPI_REGISTER) -COMPATIBLE_IOCTL(CAPI_GET_MANUFACTURER) -COMPATIBLE_IOCTL(CAPI_GET_VERSION) -COMPATIBLE_IOCTL(CAPI_GET_SERIAL) -COMPATIBLE_IOCTL(CAPI_GET_PROFILE) -COMPATIBLE_IOCTL(CAPI_MANUFACTURER_CMD) -COMPATIBLE_IOCTL(CAPI_GET_ERRCODE) -COMPATIBLE_IOCTL(CAPI_INSTALLED) -COMPATIBLE_IOCTL(CAPI_GET_FLAGS) -COMPATIBLE_IOCTL(CAPI_SET_FLAGS) -COMPATIBLE_IOCTL(CAPI_CLR_FLAGS) -COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT) -COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT) -/* Siemens Gigaset */ -COMPATIBLE_IOCTL(GIGASET_REDIR) -COMPATIBLE_IOCTL(GIGASET_CONFIG) -COMPATIBLE_IOCTL(GIGASET_BRKCHARS) -COMPATIBLE_IOCTL(GIGASET_VERSION) /* Misc. */ COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */ COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */