Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

move compat handling of tty ioctls to tty_compat_ioctl()

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>

Al Viro e2112038 77021f8b

+76 -71
+76 -2
drivers/tty/tty_io.c
··· 97 97 #include <linux/seq_file.h> 98 98 #include <linux/serial.h> 99 99 #include <linux/ratelimit.h> 100 + #include <linux/compat.h> 100 101 101 102 #include <linux/uaccess.h> 102 103 ··· 2669 2668 struct tty_ldisc *ld; 2670 2669 int retval = -ENOIOCTLCMD; 2671 2670 2671 + switch (cmd) { 2672 + case TIOCSTI: 2673 + case TIOCGWINSZ: 2674 + case TIOCSWINSZ: 2675 + case TIOCGEXCL: 2676 + case TIOCGETD: 2677 + case TIOCSETD: 2678 + case TIOCGDEV: 2679 + case TIOCMGET: 2680 + case TIOCMSET: 2681 + case TIOCMBIC: 2682 + case TIOCMBIS: 2683 + case TIOCGICOUNT: 2684 + case TIOCGPGRP: 2685 + case TIOCSPGRP: 2686 + case TIOCGSID: 2687 + case TIOCSERGETLSR: 2688 + case TIOCGRS485: 2689 + case TIOCSRS485: 2690 + #ifdef TIOCGETP 2691 + case TIOCGETP: 2692 + case TIOCSETP: 2693 + case TIOCSETN: 2694 + #endif 2695 + #ifdef TIOCGETC 2696 + case TIOCGETC: 2697 + case TIOCSETC: 2698 + #endif 2699 + #ifdef TIOCGLTC 2700 + case TIOCGLTC: 2701 + case TIOCSLTC: 2702 + #endif 2703 + case TCSETSF: 2704 + case TCSETSW: 2705 + case TCSETS: 2706 + case TCGETS: 2707 + #ifdef TCGETS2 2708 + case TCGETS2: 2709 + case TCSETSF2: 2710 + case TCSETSW2: 2711 + case TCSETS2: 2712 + #endif 2713 + case TCGETA: 2714 + case TCSETAF: 2715 + case TCSETAW: 2716 + case TCSETA: 2717 + case TIOCGLCKTRMIOS: 2718 + case TIOCSLCKTRMIOS: 2719 + #ifdef TCGETX 2720 + case TCGETX: 2721 + case TCSETX: 2722 + case TCSETXW: 2723 + case TCSETXF: 2724 + #endif 2725 + case TIOCGSOFTCAR: 2726 + case TIOCSSOFTCAR: 2727 + return tty_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); 2728 + case TIOCCONS: 2729 + case TIOCEXCL: 2730 + case TIOCNXCL: 2731 + case TIOCVHANGUP: 2732 + case TIOCSBRK: 2733 + case TIOCCBRK: 2734 + case TCSBRK: 2735 + case TCSBRKP: 2736 + case TCFLSH: 2737 + case TIOCGPTPEER: 2738 + case TIOCNOTTY: 2739 + case TIOCSCTTY: 2740 + case TCXONC: 2741 + case TIOCMIWAIT: 2742 + case TIOCSERCONFIG: 2743 + return tty_ioctl(file, cmd, arg); 2744 + } 2745 + 2672 2746 if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl")) 2673 2747 return -EINVAL; 2674 2748 ··· 2758 2682 return hung_up_tty_compat_ioctl(file, cmd, arg); 2759 2683 if (ld->ops->compat_ioctl) 2760 2684 retval = ld->ops->compat_ioctl(tty, file, cmd, arg); 2761 - else 2762 - retval = n_tty_compat_ioctl_helper(tty, file, cmd, arg); 2763 2685 tty_ldisc_deref(ld); 2764 2686 2765 2687 return retval;
-16
drivers/tty/tty_ioctl.c
··· 941 941 } 942 942 } 943 943 EXPORT_SYMBOL(n_tty_ioctl_helper); 944 - 945 - #ifdef CONFIG_COMPAT 946 - long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file, 947 - unsigned int cmd, unsigned long arg) 948 - { 949 - switch (cmd) { 950 - case TIOCGLCKTRMIOS: 951 - case TIOCSLCKTRMIOS: 952 - return tty_mode_ioctl(tty, file, cmd, (unsigned long) compat_ptr(arg)); 953 - default: 954 - return -ENOIOCTLCMD; 955 - } 956 - } 957 - EXPORT_SYMBOL(n_tty_compat_ioctl_helper); 958 - #endif 959 -
-51
fs/compat_ioctl.c
··· 711 711 COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */ 712 712 713 713 /* Big T */ 714 - COMPATIBLE_IOCTL(TCGETA) 715 - COMPATIBLE_IOCTL(TCSETA) 716 - COMPATIBLE_IOCTL(TCSETAW) 717 - COMPATIBLE_IOCTL(TCSETAF) 718 - COMPATIBLE_IOCTL(TCSBRK) 719 - COMPATIBLE_IOCTL(TCXONC) 720 - COMPATIBLE_IOCTL(TCFLSH) 721 - COMPATIBLE_IOCTL(TCGETS) 722 - COMPATIBLE_IOCTL(TCSETS) 723 - COMPATIBLE_IOCTL(TCSETSW) 724 - COMPATIBLE_IOCTL(TCSETSF) 725 714 COMPATIBLE_IOCTL(TIOCLINUX) 726 - COMPATIBLE_IOCTL(TIOCSBRK) 727 - COMPATIBLE_IOCTL(TIOCGDEV) 728 - COMPATIBLE_IOCTL(TIOCCBRK) 729 - COMPATIBLE_IOCTL(TIOCGSID) 730 - COMPATIBLE_IOCTL(TIOCGICOUNT) 731 - COMPATIBLE_IOCTL(TIOCGEXCL) 732 715 /* Little t */ 733 - COMPATIBLE_IOCTL(TIOCGETD) 734 - COMPATIBLE_IOCTL(TIOCSETD) 735 - COMPATIBLE_IOCTL(TIOCEXCL) 736 - COMPATIBLE_IOCTL(TIOCNXCL) 737 - COMPATIBLE_IOCTL(TIOCCONS) 738 - COMPATIBLE_IOCTL(TIOCGSOFTCAR) 739 - COMPATIBLE_IOCTL(TIOCSSOFTCAR) 740 - COMPATIBLE_IOCTL(TIOCSWINSZ) 741 - COMPATIBLE_IOCTL(TIOCGWINSZ) 742 - COMPATIBLE_IOCTL(TIOCMGET) 743 - COMPATIBLE_IOCTL(TIOCMBIC) 744 - COMPATIBLE_IOCTL(TIOCMBIS) 745 - COMPATIBLE_IOCTL(TIOCMSET) 746 - COMPATIBLE_IOCTL(TIOCNOTTY) 747 - COMPATIBLE_IOCTL(TIOCSTI) 748 716 COMPATIBLE_IOCTL(TIOCOUTQ) 749 - COMPATIBLE_IOCTL(TIOCSPGRP) 750 - COMPATIBLE_IOCTL(TIOCGPGRP) 751 - COMPATIBLE_IOCTL(TIOCSERGETLSR) 752 - COMPATIBLE_IOCTL(TIOCSRS485) 753 - COMPATIBLE_IOCTL(TIOCGRS485) 754 - #ifdef TCGETS2 755 - COMPATIBLE_IOCTL(TCGETS2) 756 - COMPATIBLE_IOCTL(TCSETS2) 757 - COMPATIBLE_IOCTL(TCSETSW2) 758 - COMPATIBLE_IOCTL(TCSETSF2) 759 - #endif 760 717 /* Little f */ 761 718 COMPATIBLE_IOCTL(FIOCLEX) 762 719 COMPATIBLE_IOCTL(FIONCLEX) ··· 1176 1219 COMPATIBLE_IOCTL(JSIOCGBUTTONS) 1177 1220 COMPATIBLE_IOCTL(JSIOCGNAME(0)) 1178 1221 1179 - #ifdef TIOCGLTC 1180 - COMPATIBLE_IOCTL(TIOCGLTC) 1181 - COMPATIBLE_IOCTL(TIOCSLTC) 1182 - #endif 1183 1222 #ifdef TIOCSTART 1184 1223 /* 1185 1224 * For these two we have definitions in ioctls.h and/or termios.h on ··· 1265 1312 * so we must not do a compat_ptr() translation. 1266 1313 */ 1267 1314 switch (cmd) { 1268 - /* Big T */ 1269 - case TCSBRKP: 1270 - case TIOCMIWAIT: 1271 - case TIOCSCTTY: 1272 1315 /* RAID */ 1273 1316 case HOT_REMOVE_DISK: 1274 1317 case HOT_ADD_DISK:
-2
include/linux/tty.h
··· 746 746 /* tty_ioctl.c */ 747 747 extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, 748 748 unsigned int cmd, unsigned long arg); 749 - extern long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file, 750 - unsigned int cmd, unsigned long arg); 751 749 752 750 /* vt.c */ 753 751