diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-09-12 20:53:46 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-10-13 00:50:51 -0400 |
commit | 50f45326afab723df529eca54095e2feac24da2d (patch) | |
tree | 9bbe51407182819996f7541cc5e0090125089dd8 | |
parent | 82a6857bf9efa8f66e2476f248021c17cd423159 (diff) |
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>
-rw-r--r-- | drivers/tty/pty.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 678406e0948b..00099a8439d2 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/mount.h> | 28 | #include <linux/mount.h> |
29 | #include <linux/file.h> | 29 | #include <linux/file.h> |
30 | #include <linux/ioctl.h> | 30 | #include <linux/ioctl.h> |
31 | #include <linux/compat.h> | ||
31 | 32 | ||
32 | #undef TTY_DEBUG_HANGUP | 33 | #undef TTY_DEBUG_HANGUP |
33 | #ifdef TTY_DEBUG_HANGUP | 34 | #ifdef TTY_DEBUG_HANGUP |
@@ -488,6 +489,7 @@ static int pty_bsd_ioctl(struct tty_struct *tty, | |||
488 | return -ENOIOCTLCMD; | 489 | return -ENOIOCTLCMD; |
489 | } | 490 | } |
490 | 491 | ||
492 | #ifdef CONFIG_COMPAT | ||
491 | static long pty_bsd_compat_ioctl(struct tty_struct *tty, | 493 | static long pty_bsd_compat_ioctl(struct tty_struct *tty, |
492 | unsigned int cmd, unsigned long arg) | 494 | unsigned int cmd, unsigned long arg) |
493 | { | 495 | { |
@@ -495,8 +497,11 @@ static long pty_bsd_compat_ioctl(struct tty_struct *tty, | |||
495 | * PTY ioctls don't require any special translation between 32-bit and | 497 | * PTY ioctls don't require any special translation between 32-bit and |
496 | * 64-bit userspace, they are already compatible. | 498 | * 64-bit userspace, they are already compatible. |
497 | */ | 499 | */ |
498 | return pty_bsd_ioctl(tty, cmd, arg); | 500 | return pty_bsd_ioctl(tty, cmd, (unsigned long)compat_ptr(arg)); |
499 | } | 501 | } |
502 | #else | ||
503 | #define pty_bsd_compat_ioctl NULL | ||
504 | #endif | ||
500 | 505 | ||
501 | static int legacy_count = CONFIG_LEGACY_PTY_COUNT; | 506 | static int legacy_count = CONFIG_LEGACY_PTY_COUNT; |
502 | /* | 507 | /* |
@@ -676,6 +681,7 @@ static int pty_unix98_ioctl(struct tty_struct *tty, | |||
676 | return -ENOIOCTLCMD; | 681 | return -ENOIOCTLCMD; |
677 | } | 682 | } |
678 | 683 | ||
684 | #ifdef CONFIG_COMPAT | ||
679 | static long pty_unix98_compat_ioctl(struct tty_struct *tty, | 685 | static long pty_unix98_compat_ioctl(struct tty_struct *tty, |
680 | unsigned int cmd, unsigned long arg) | 686 | unsigned int cmd, unsigned long arg) |
681 | { | 687 | { |
@@ -683,8 +689,12 @@ static long pty_unix98_compat_ioctl(struct tty_struct *tty, | |||
683 | * PTY ioctls don't require any special translation between 32-bit and | 689 | * PTY ioctls don't require any special translation between 32-bit and |
684 | * 64-bit userspace, they are already compatible. | 690 | * 64-bit userspace, they are already compatible. |
685 | */ | 691 | */ |
686 | return pty_unix98_ioctl(tty, cmd, arg); | 692 | return pty_unix98_ioctl(tty, cmd, |
693 | cmd == TIOCSIG ? arg : (unsigned long)compat_ptr(arg)); | ||
687 | } | 694 | } |
695 | #else | ||
696 | #define pty_unix98_compat_ioctl NULL | ||
697 | #endif | ||
688 | 698 | ||
689 | /** | 699 | /** |
690 | * ptm_unix98_lookup - find a pty master | 700 | * ptm_unix98_lookup - find a pty master |