From: Arnd Bergmann <arnd@arndb.de>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Arnd Bergmann <arnd@arndb.de>, Karsten Keil <isdn@linux-pingi.de>,
netdev@vger.kernel.org
Subject: [PATCH v5 17/29] compat_ioctl: move isdn/capi ioctl translation into driver
Date: Tue, 30 Jul 2019 21:55:33 +0200 [thread overview]
Message-ID: <20190730195819.901457-5-arnd@arndb.de> (raw)
In-Reply-To: <20190730195819.901457-1-arnd@arndb.de>
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 has some ioctl commands that are
correctly listed in fs/compat_ioctl.c.
We can trivially move all of those into the corresponding
file 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 <arnd@arndb.de>
---
drivers/isdn/capi/capi.c | 31 +++++++++++++++++++++++++++++++
fs/compat_ioctl.c | 17 -----------------
2 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 3c3ad42f22bf..3b72fd8104db 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/fs/compat_ioctl.c b/fs/compat_ioctl.c
index a4e8fb7da968..f3b4179d6dff 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -44,9 +44,6 @@
#include <net/bluetooth/hci_sock.h>
#include <net/bluetooth/rfcomm.h>
-#include <linux/capi.h>
-#include <linux/gigaset_dev.h>
-
#ifdef CONFIG_BLOCK
#include <linux/cdrom.h>
#include <linux/fd.h>
@@ -681,20 +678,6 @@ COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
-/* 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)
/* Misc. */
COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
--
2.20.0
next prev parent reply other threads:[~2019-07-30 20:00 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-30 19:25 [PATCH v5 00/29] compat_ioctl.c removal, part 1/3 Arnd Bergmann
2019-07-30 19:25 ` [PATCH v5 01/29] fix compat handling of FICLONERANGE, FIDEDUPERANGE and FS_IOC_FIEMAP Arnd Bergmann
2019-07-30 19:25 ` [PATCH v5 02/29] FIGETBSZ: fix compat Arnd Bergmann
2019-07-30 19:25 ` [PATCH v5 03/29] compat: itanic doesn't have one Arnd Bergmann
2019-07-30 19:25 ` [PATCH v5 04/29] do_vfs_ioctl(): use saner types Arnd Bergmann
2019-07-30 19:25 ` [PATCH v5 05/29] compat: move FS_IOC_RESVSP_32 handling to fs/ioctl.c Arnd Bergmann
2019-07-30 19:25 ` [PATCH v5 06/29] compat_sys_ioctl(): make parallel to do_vfs_ioctl() Arnd Bergmann
2019-07-30 19:25 ` [PATCH v5 07/29] ceph: fix compat_ioctl for ceph_dir_operations Arnd Bergmann
2019-07-30 19:25 ` [PATCH v5 08/29] compat_ioctl: drop FIOQSIZE table entry Arnd Bergmann
2019-07-30 19:25 ` [PATCH v5 09/29] compat_ioctl: pppoe: fix PPPOEIOCSFWD handling Arnd Bergmann
2019-07-30 21:42 ` David Miller
2019-07-30 19:25 ` [PATCH v5 10/29] compat_ioctl: add compat_ptr_ioctl() Arnd Bergmann
2019-07-30 19:25 ` [PATCH v5 11/29] compat_ioctl: move rtc handling into rtc-dev.c Arnd Bergmann
2019-07-30 19:50 ` [PATCH v5 12/29] compat_ioctl: move drivers to compat_ptr_ioctl Arnd Bergmann
2019-07-30 21:43 ` David Miller
2019-07-31 8:37 ` Cornelia Huck
2019-07-30 19:55 ` [PATCH v5 13/29] compat_ioctl: move more " Arnd Bergmann
2019-07-30 19:55 ` [PATCH v5 14/29] compat_ioctl: use correct compat_ptr() translation in drivers Arnd Bergmann
2019-07-30 19:55 ` [PATCH v5 15/29] compat_ioctl: move tape handling into drivers Arnd Bergmann
2019-07-31 10:50 ` Heiko Carstens
2019-07-31 15:47 ` Arnd Bergmann
2019-07-30 19:55 ` [PATCH v5 16/29] compat_ioctl: move ATYFB_CLK handling to atyfb driver Arnd Bergmann
2019-07-30 19:55 ` Arnd Bergmann [this message]
2019-07-30 19:55 ` [PATCH v5 18/29] compat_ioctl: move rfcomm handlers into driver Arnd Bergmann
2019-08-12 16:29 ` Marcel Holtmann
2019-07-30 19:55 ` [PATCH v5 19/29] compat_ioctl: move hci_sock " Arnd Bergmann
2019-08-12 16:29 ` Marcel Holtmann
2019-07-30 20:14 ` [PATCH v5 13/29] compat_ioctl: move more drivers to compat_ptr_ioctl Dan Williams
2019-07-30 20:01 ` [PATCH v5 20/29] compat_ioctl: remove HCIUART handling Arnd Bergmann
2019-07-30 20:01 ` [PATCH v5 21/29] compat_ioctl: remove HIDIO translation Arnd Bergmann
2019-07-30 20:01 ` [PATCH v5 22/29] compat_ioctl: remove translation for sound ioctls Arnd Bergmann
2019-07-30 20:01 ` [PATCH v5 23/29] compat_ioctl: remove IGNORE_IOCTL() Arnd Bergmann
2019-07-30 20:01 ` [PATCH v5 24/29] compat_ioctl: remove /dev/random commands Arnd Bergmann
2019-07-30 20:01 ` [PATCH v5 25/29] compat_ioctl: remove joystick ioctl translation Arnd Bergmann
2019-07-30 20:01 ` [PATCH v5 26/29] compat_ioctl: remove PCI " Arnd Bergmann
2019-07-30 20:01 ` [PATCH v5 27/29] compat_ioctl: remove /dev/raw " Arnd Bergmann
2019-07-30 20:01 ` [PATCH v5 28/29] compat_ioctl: remove last RAID handling code Arnd Bergmann
2019-07-30 20:01 ` [PATCH v5 29/29] compat_ioctl: remove unused convert_in_user macro Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190730195819.901457-5-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=isdn@linux-pingi.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).