linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 02/50] move compat handling of tty ioctls to tty_compat_ioctl()
Date: Thu, 13 Sep 2018 03:40:01 +0100	[thread overview]
Message-ID: <20180913024049.24567-2-viro@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20180913024049.24567-1-viro@ZenIV.linux.org.uk>

From: Al Viro <viro@zeniv.linux.org.uk>

ioctls that are
	* callable only via tty_ioctl()
	* not driver-specific
	* not demand data structure conversions
	* either always need passing arg as is or always demand compat_ptr()
get intercepted in tty_compat_ioctl() from the very beginning and
redirecter to tty_ioctl().  As the result, their entries in fs/compat_ioctl.c
(some of those had been missing, BTW) got removed, as well as
n_tty_compat_ioctl_helper() (now it's never called with any cmd it would accept).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 drivers/tty/tty_io.c    | 77 +++++++++++++++++++++++++++++++++++++++++++++++--
 drivers/tty/tty_ioctl.c | 16 ----------
 fs/compat_ioctl.c       | 51 --------------------------------
 include/linux/tty.h     |  2 --
 4 files changed, 75 insertions(+), 71 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 32bc3e3fe4d3..c2168b43df0f 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2668,6 +2668,81 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,
 	struct tty_ldisc *ld;
 	int retval = -ENOIOCTLCMD;
 
+	switch (cmd) {
+	case TIOCSTI:
+	case TIOCGWINSZ:
+	case TIOCSWINSZ:
+	case TIOCGEXCL:
+	case TIOCGETD:
+	case TIOCSETD:
+	case TIOCGDEV:
+	case TIOCMGET:
+	case TIOCMSET:
+	case TIOCMBIC:
+	case TIOCMBIS:
+	case TIOCGICOUNT:
+	case TIOCGPGRP:
+	case TIOCSPGRP:
+	case TIOCGSID:
+	case TIOCSERGETLSR:
+	case TIOCGRS485:
+	case TIOCSRS485:
+#ifdef TIOCGETP
+	case TIOCGETP:
+	case TIOCSETP:
+	case TIOCSETN:
+#endif
+#ifdef TIOCGETC
+	case TIOCGETC:
+	case TIOCSETC:
+#endif
+#ifdef TIOCGLTC
+	case TIOCGLTC:
+	case TIOCSLTC:
+#endif
+	case TCSETSF:
+	case TCSETSW:
+	case TCSETS:
+	case TCGETS:
+#ifdef TCGETS2
+	case TCGETS2:
+	case TCSETSF2:
+	case TCSETSW2:
+	case TCSETS2:
+#endif
+	case TCGETA:
+	case TCSETAF:
+	case TCSETAW:
+	case TCSETA:
+	case TIOCGLCKTRMIOS:
+	case TIOCSLCKTRMIOS:
+#ifdef TCGETX
+	case TCGETX:
+	case TCSETX:
+	case TCSETXW:
+	case TCSETXF:
+#endif
+	case TIOCGSOFTCAR:
+	case TIOCSSOFTCAR:
+		return tty_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
+	case TIOCCONS:
+	case TIOCEXCL:
+	case TIOCNXCL:
+	case TIOCVHANGUP:
+	case TIOCSBRK:
+	case TIOCCBRK:
+	case TCSBRK:
+	case TCSBRKP:
+	case TCFLSH:
+	case TIOCGPTPEER:
+	case TIOCNOTTY:
+	case TIOCSCTTY:
+	case TCXONC:
+	case TIOCMIWAIT:
+	case TIOCSERCONFIG:
+		return tty_ioctl(file, cmd, arg);
+	}
+
 	if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl"))
 		return -EINVAL;
 
@@ -2682,8 +2757,6 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,
 		return hung_up_tty_compat_ioctl(file, cmd, arg);
 	if (ld->ops->compat_ioctl)
 		retval = ld->ops->compat_ioctl(tty, file, cmd, arg);
-	else
-		retval = n_tty_compat_ioctl_helper(tty, file, cmd, arg);
 	tty_ldisc_deref(ld);
 
 	return retval;
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index d99fec44036c..9245fffdbceb 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -941,19 +941,3 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
 	}
 }
 EXPORT_SYMBOL(n_tty_ioctl_helper);
-
-#ifdef CONFIG_COMPAT
-long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file,
-					unsigned int cmd, unsigned long arg)
-{
-	switch (cmd) {
-	case TIOCGLCKTRMIOS:
-	case TIOCSLCKTRMIOS:
-		return tty_mode_ioctl(tty, file, cmd, (unsigned long) compat_ptr(arg));
-	default:
-		return -ENOIOCTLCMD;
-	}
-}
-EXPORT_SYMBOL(n_tty_compat_ioctl_helper);
-#endif
-
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 53bc3659dcef..670b8cbd0896 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -711,52 +711,9 @@ COMPATIBLE_IOCTL(0x4B50)   /* KDGHWCLK - not in the kernel, but don't complain *
 COMPATIBLE_IOCTL(0x4B51)   /* KDSHWCLK - not in the kernel, but don't complain */
 
 /* Big T */
-COMPATIBLE_IOCTL(TCGETA)
-COMPATIBLE_IOCTL(TCSETA)
-COMPATIBLE_IOCTL(TCSETAW)
-COMPATIBLE_IOCTL(TCSETAF)
-COMPATIBLE_IOCTL(TCSBRK)
-COMPATIBLE_IOCTL(TCXONC)
-COMPATIBLE_IOCTL(TCFLSH)
-COMPATIBLE_IOCTL(TCGETS)
-COMPATIBLE_IOCTL(TCSETS)
-COMPATIBLE_IOCTL(TCSETSW)
-COMPATIBLE_IOCTL(TCSETSF)
 COMPATIBLE_IOCTL(TIOCLINUX)
-COMPATIBLE_IOCTL(TIOCSBRK)
-COMPATIBLE_IOCTL(TIOCGDEV)
-COMPATIBLE_IOCTL(TIOCCBRK)
-COMPATIBLE_IOCTL(TIOCGSID)
-COMPATIBLE_IOCTL(TIOCGICOUNT)
-COMPATIBLE_IOCTL(TIOCGEXCL)
 /* Little t */
-COMPATIBLE_IOCTL(TIOCGETD)
-COMPATIBLE_IOCTL(TIOCSETD)
-COMPATIBLE_IOCTL(TIOCEXCL)
-COMPATIBLE_IOCTL(TIOCNXCL)
-COMPATIBLE_IOCTL(TIOCCONS)
-COMPATIBLE_IOCTL(TIOCGSOFTCAR)
-COMPATIBLE_IOCTL(TIOCSSOFTCAR)
-COMPATIBLE_IOCTL(TIOCSWINSZ)
-COMPATIBLE_IOCTL(TIOCGWINSZ)
-COMPATIBLE_IOCTL(TIOCMGET)
-COMPATIBLE_IOCTL(TIOCMBIC)
-COMPATIBLE_IOCTL(TIOCMBIS)
-COMPATIBLE_IOCTL(TIOCMSET)
-COMPATIBLE_IOCTL(TIOCNOTTY)
-COMPATIBLE_IOCTL(TIOCSTI)
 COMPATIBLE_IOCTL(TIOCOUTQ)
-COMPATIBLE_IOCTL(TIOCSPGRP)
-COMPATIBLE_IOCTL(TIOCGPGRP)
-COMPATIBLE_IOCTL(TIOCSERGETLSR)
-COMPATIBLE_IOCTL(TIOCSRS485)
-COMPATIBLE_IOCTL(TIOCGRS485)
-#ifdef TCGETS2
-COMPATIBLE_IOCTL(TCGETS2)
-COMPATIBLE_IOCTL(TCSETS2)
-COMPATIBLE_IOCTL(TCSETSW2)
-COMPATIBLE_IOCTL(TCSETSF2)
-#endif
 /* Little f */
 COMPATIBLE_IOCTL(FIOCLEX)
 COMPATIBLE_IOCTL(FIONCLEX)
@@ -1219,10 +1176,6 @@ COMPATIBLE_IOCTL(JSIOCGAXES)
 COMPATIBLE_IOCTL(JSIOCGBUTTONS)
 COMPATIBLE_IOCTL(JSIOCGNAME(0))
 
-#ifdef TIOCGLTC
-COMPATIBLE_IOCTL(TIOCGLTC)
-COMPATIBLE_IOCTL(TIOCSLTC)
-#endif
 #ifdef TIOCSTART
 /*
  * For these two we have definitions in ioctls.h and/or termios.h on
@@ -1312,10 +1265,6 @@ static long do_ioctl_trans(unsigned int cmd,
 	 * so we must not do a compat_ptr() translation.
 	 */
 	switch (cmd) {
-	/* Big T */
-	case TCSBRKP:
-	case TIOCMIWAIT:
-	case TIOCSCTTY:
 	/* RAID */
 	case HOT_REMOVE_DISK:
 	case HOT_ADD_DISK:
diff --git a/include/linux/tty.h b/include/linux/tty.h
index c56e3978b00f..414db2bce715 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -746,8 +746,6 @@ static inline int tty_audit_push(void)
 /* tty_ioctl.c */
 extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
 		       unsigned int cmd, unsigned long arg);
-extern long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file,
-		       unsigned int cmd, unsigned long arg);
 
 /* vt.c */
 
-- 
2.11.0


  reply	other threads:[~2018-09-13  2:44 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-13  2:31 [PATCHES] tty ioctls cleanups, compat and not only Al Viro
2018-09-13  2:40 ` [PATCH 01/50] presence of RS485 ioctls has been unconditional since 2014 Al Viro
2018-09-13  2:40   ` Al Viro [this message]
2018-09-14 15:15     ` [PATCH 02/50] move compat handling of tty ioctls to tty_compat_ioctl() Arnd Bergmann
2018-09-14 18:16       ` gregkh
2018-09-14 19:38         ` Arnd Bergmann
2018-09-15 18:51           ` gregkh
2018-09-13  2:40   ` [PATCH 03/50] tty_ioctl(): drop FIONBIO handling Al Viro
2018-09-13  2:40   ` [PATCH 04/50] mos7720: bury dead TIOCM... in ->ioctl() Al Viro
2018-09-14 13:31     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 05/50] tty_ioctl(): start taking TIOC[SG]SERIAL into separate methods Al Viro
2018-09-14 13:22     ` Johan Hovold
2018-09-14 15:18       ` Al Viro
2018-09-14 16:23         ` Johan Hovold
2018-09-13  2:40   ` [PATCH 06/50] simserial: switch to ->[sg]et_serial() Al Viro
2018-09-13  2:40   ` [PATCH 07/50] fwserial: " Al Viro
2018-09-13  2:40   ` [PATCH 08/50] greybus/uart: " Al Viro
2018-09-14 13:31     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 09/50] amiserial: " Al Viro
2018-09-13 10:33     ` Greg Kroah-Hartman
2018-10-11 17:58     ` Geert Uytterhoeven
2018-10-13  5:36       ` Al Viro
2018-09-13  2:40   ` [PATCH 10/50] cyclades: " Al Viro
2018-09-13  2:40   ` [PATCH 11/50] ipwireless: " Al Viro
2018-09-14 12:00     ` David Sterba
2018-09-13  2:40   ` [PATCH 12/50] isicom: " Al Viro
2018-09-13  2:40   ` [PATCH 13/50] moxa: " Al Viro
2018-09-13  2:40   ` [PATCH 14/50] mxser: " Al Viro
2018-09-13  2:40   ` [PATCH 15/50] serial_core: " Al Viro
2018-09-13  2:40   ` [PATCH 16/50] rfcomm: get rid of mentioning TIOC[SG]SERIAL Al Viro
2018-09-13  2:40   ` [PATCH 17/50] usb-serial: begin switching to ->[sg]et_serial() Al Viro
2018-09-14 13:39     ` Johan Hovold
2018-09-14 15:23       ` Al Viro
2018-09-14 15:26         ` Johan Hovold
2018-09-13  2:40   ` [PATCH 18/50] cdc-acm: switch " Al Viro
2018-09-13  2:40   ` [PATCH 19/50] ark3116: switch to ->get_serial() Al Viro
2018-09-14 13:41     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 20/50] f81232: " Al Viro
2018-09-14 13:42     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 21/50] f81534: " Al Viro
2018-09-14 13:43     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 22/50] fdti_sio: switch to ->[sg]et_serial() Al Viro
2018-09-14 13:47     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 23/50] io_edgeport: switch to ->get_serial() Al Viro
2018-09-14 13:58     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 24/50] io_ti: " Al Viro
2018-09-14 13:59     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 25/50] mos7720: " Al Viro
2018-09-14 14:02     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 26/50] mos7840: " Al Viro
2018-09-14 14:07     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 27/50] opticon: " Al Viro
2018-09-14 14:08     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 28/50] pl2303: " Al Viro
2018-09-14 14:08     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 29/50] quatech2: " Al Viro
2018-09-14 14:09     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 30/50] ssu100: " Al Viro
2018-09-14 14:10     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 31/50] ti_usb_3410_5052: switch to ->[sg]et_serial() Al Viro
2018-09-14 14:12     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 32/50] whiteheat: switch to ->get_serial() Al Viro
2018-09-14 14:15     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 33/50] usb_wwan: switch to ->[sg]et_serial() Al Viro
2018-09-14 14:18     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 34/50] complete ->[sg]et_serial() switchover Al Viro
2018-09-14 14:20     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 35/50] synclink: reduce pointless checks in ->ioctl() Al Viro
2018-09-13  2:40   ` [PATCH 36/50] take compat TIOC[SG]SERIAL treatment into tty_compat_ioctl() Al Viro
2018-09-13  2:40   ` [PATCH 37/50] kill capinc_tty_ioctl() Al Viro
2018-09-13  2:40   ` [PATCH 38/50] isdn_tty: TCSBRK{,P} won't reach ->ioctl() Al Viro
2018-09-13  2:40   ` [PATCH 39/50] dgnc: TIOCM... " Al Viro
2018-09-13  2:40   ` [PATCH 40/50] kill the rest of tty COMPAT_IOCTL() entries Al Viro
2018-09-13 10:55     ` Arnd Bergmann
2018-09-13  2:40   ` [PATCH 41/50] dgnc: break-related ioctls won't reach ->ioctl() Al Viro
2018-09-13 11:59     ` Greg Kroah-Hartman
2018-09-13  2:40   ` [PATCH 42/50] remove fallback to drivers for TIOCGICOUNT Al Viro
2018-09-14 14:23     ` Johan Hovold
2018-09-13  2:40   ` [PATCH 43/50] dgnc: leave TIOC[GS]SOFTCAR to ldisc Al Viro
2018-09-13  2:40   ` [PATCH 44/50] dgnc: don't bother with (empty) stub for TCXONC Al Viro
2018-09-13  2:40   ` [PATCH 45/50] gigaset: don't try to printk userland buffer contents Al Viro
2018-09-13  2:40   ` [PATCH 46/50] vt_compat_ioctl(): clean up, use compat_ptr() properly Al Viro
2018-09-13 10:10     ` Arnd Bergmann
2018-09-13  2:40   ` [PATCH 47/50] gigaset: add ->compat_ioctl() Al Viro
2018-09-13  2:40   ` [PATCH 48/50] compat_ioctl - kill keyboard ioctl handling Al Viro
2018-09-13  2:40   ` [PATCH 49/50] pty: fix compat ioctls Al Viro
2018-09-13  2:40   ` [PATCH 50/50] synclink_gt(): fix compat_ioctl() Al Viro
2018-09-13 11:19 ` [PATCHES] tty ioctls cleanups, compat and not only Arnd Bergmann
2018-09-13 20:31   ` Al Viro
2018-09-13 20:56     ` Arnd Bergmann
2018-09-14  2:27       ` Al Viro
2018-09-14  8:21         ` Arnd Bergmann
2018-09-14 15:10           ` Al Viro
2018-09-14 15:33             ` Arnd Bergmann
2018-09-13 11:59 ` Greg Kroah-Hartman

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=20180913024049.24567-2-viro@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).