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

tty: add compat_ioctl callbacks

In order to avoid future diversions between fs/compat_ioctl.c and
drivers/tty/pty.c, define .compat_ioctl callbacks for the relevant
tty_operations structs. Since both pty_unix98_ioctl() and
pty_bsd_ioctl() are compatible between 32-bit and 64-bit userspace no
special translation is required.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Aleksa Sarai and committed by
Greg Kroah-Hartman
5f0f187f bea8be65

+22 -6
+22
drivers/tty/pty.c
··· 481 481 return -ENOIOCTLCMD; 482 482 } 483 483 484 + static long pty_bsd_compat_ioctl(struct tty_struct *tty, 485 + unsigned int cmd, unsigned long arg) 486 + { 487 + /* 488 + * PTY ioctls don't require any special translation between 32-bit and 489 + * 64-bit userspace, they are already compatible. 490 + */ 491 + return pty_bsd_ioctl(tty, cmd, arg); 492 + } 493 + 484 494 static int legacy_count = CONFIG_LEGACY_PTY_COUNT; 485 495 /* 486 496 * not really modular, but the easiest way to keep compat with existing ··· 512 502 .chars_in_buffer = pty_chars_in_buffer, 513 503 .unthrottle = pty_unthrottle, 514 504 .ioctl = pty_bsd_ioctl, 505 + .compat_ioctl = pty_bsd_compat_ioctl, 515 506 .cleanup = pty_cleanup, 516 507 .resize = pty_resize, 517 508 .remove = pty_remove ··· 620 609 return -ENOIOCTLCMD; 621 610 } 622 611 612 + static long pty_unix98_compat_ioctl(struct tty_struct *tty, 613 + unsigned int cmd, unsigned long arg) 614 + { 615 + /* 616 + * PTY ioctls don't require any special translation between 32-bit and 617 + * 64-bit userspace, they are already compatible. 618 + */ 619 + return pty_unix98_ioctl(tty, cmd, arg); 620 + } 621 + 623 622 /** 624 623 * ptm_unix98_lookup - find a pty master 625 624 * @driver: ptm driver ··· 702 681 .chars_in_buffer = pty_chars_in_buffer, 703 682 .unthrottle = pty_unthrottle, 704 683 .ioctl = pty_unix98_ioctl, 684 + .compat_ioctl = pty_unix98_compat_ioctl, 705 685 .resize = pty_resize, 706 686 .cleanup = pty_cleanup 707 687 };
-6
fs/compat_ioctl.c
··· 866 866 COMPATIBLE_IOCTL(TIOCCBRK) 867 867 COMPATIBLE_IOCTL(TIOCGSID) 868 868 COMPATIBLE_IOCTL(TIOCGICOUNT) 869 - COMPATIBLE_IOCTL(TIOCGPKT) 870 - COMPATIBLE_IOCTL(TIOCGPTLCK) 871 869 COMPATIBLE_IOCTL(TIOCGEXCL) 872 870 /* Little t */ 873 871 COMPATIBLE_IOCTL(TIOCGETD) ··· 881 883 COMPATIBLE_IOCTL(TIOCMBIC) 882 884 COMPATIBLE_IOCTL(TIOCMBIS) 883 885 COMPATIBLE_IOCTL(TIOCMSET) 884 - COMPATIBLE_IOCTL(TIOCPKT) 885 886 COMPATIBLE_IOCTL(TIOCNOTTY) 886 887 COMPATIBLE_IOCTL(TIOCSTI) 887 888 COMPATIBLE_IOCTL(TIOCOUTQ) 888 889 COMPATIBLE_IOCTL(TIOCSPGRP) 889 890 COMPATIBLE_IOCTL(TIOCGPGRP) 890 - COMPATIBLE_IOCTL(TIOCGPTN) 891 - COMPATIBLE_IOCTL(TIOCSPTLCK) 892 891 COMPATIBLE_IOCTL(TIOCSERGETLSR) 893 - COMPATIBLE_IOCTL(TIOCSIG) 894 892 #ifdef TIOCSRS485 895 893 COMPATIBLE_IOCTL(TIOCSRS485) 896 894 #endif