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

pty: fix compat ioctls

pointer-taking ones need compat_ptr(); int-taking one doesn't.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 50f45326 82a6857b

+12 -2
+12 -2
drivers/tty/pty.c
··· 28 28 #include <linux/mount.h> 29 29 #include <linux/file.h> 30 30 #include <linux/ioctl.h> 31 + #include <linux/compat.h> 31 32 32 33 #undef TTY_DEBUG_HANGUP 33 34 #ifdef TTY_DEBUG_HANGUP ··· 489 488 return -ENOIOCTLCMD; 490 489 } 491 490 491 + #ifdef CONFIG_COMPAT 492 492 static long pty_bsd_compat_ioctl(struct tty_struct *tty, 493 493 unsigned int cmd, unsigned long arg) 494 494 { ··· 497 495 * PTY ioctls don't require any special translation between 32-bit and 498 496 * 64-bit userspace, they are already compatible. 499 497 */ 500 - return pty_bsd_ioctl(tty, cmd, arg); 498 + return pty_bsd_ioctl(tty, cmd, (unsigned long)compat_ptr(arg)); 501 499 } 500 + #else 501 + #define pty_bsd_compat_ioctl NULL 502 + #endif 502 503 503 504 static int legacy_count = CONFIG_LEGACY_PTY_COUNT; 504 505 /* ··· 681 676 return -ENOIOCTLCMD; 682 677 } 683 678 679 + #ifdef CONFIG_COMPAT 684 680 static long pty_unix98_compat_ioctl(struct tty_struct *tty, 685 681 unsigned int cmd, unsigned long arg) 686 682 { ··· 689 683 * PTY ioctls don't require any special translation between 32-bit and 690 684 * 64-bit userspace, they are already compatible. 691 685 */ 692 - return pty_unix98_ioctl(tty, cmd, arg); 686 + return pty_unix98_ioctl(tty, cmd, 687 + cmd == TIOCSIG ? arg : (unsigned long)compat_ptr(arg)); 693 688 } 689 + #else 690 + #define pty_unix98_compat_ioctl NULL 691 + #endif 694 692 695 693 /** 696 694 * ptm_unix98_lookup - find a pty master