Skip to content

Commit 50f4532

Browse files
author
Al Viro
committed
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>
1 parent 82a6857 commit 50f4532

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

drivers/tty/pty.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/mount.h>
2929
#include <linux/file.h>
3030
#include <linux/ioctl.h>
31+
#include <linux/compat.h>
3132

3233
#undef TTY_DEBUG_HANGUP
3334
#ifdef TTY_DEBUG_HANGUP
@@ -488,15 +489,19 @@ static int pty_bsd_ioctl(struct tty_struct *tty,
488489
return -ENOIOCTLCMD;
489490
}
490491

492+
#ifdef CONFIG_COMPAT
491493
static long pty_bsd_compat_ioctl(struct tty_struct *tty,
492494
unsigned int cmd, unsigned long arg)
493495
{
494496
/*
495497
* PTY ioctls don't require any special translation between 32-bit and
496498
* 64-bit userspace, they are already compatible.
497499
*/
498-
return pty_bsd_ioctl(tty, cmd, arg);
500+
return pty_bsd_ioctl(tty, cmd, (unsigned long)compat_ptr(arg));
499501
}
502+
#else
503+
#define pty_bsd_compat_ioctl NULL
504+
#endif
500505

501506
static int legacy_count = CONFIG_LEGACY_PTY_COUNT;
502507
/*
@@ -676,15 +681,20 @@ static int pty_unix98_ioctl(struct tty_struct *tty,
676681
return -ENOIOCTLCMD;
677682
}
678683

684+
#ifdef CONFIG_COMPAT
679685
static long pty_unix98_compat_ioctl(struct tty_struct *tty,
680686
unsigned int cmd, unsigned long arg)
681687
{
682688
/*
683689
* PTY ioctls don't require any special translation between 32-bit and
684690
* 64-bit userspace, they are already compatible.
685691
*/
686-
return pty_unix98_ioctl(tty, cmd, arg);
692+
return pty_unix98_ioctl(tty, cmd,
693+
cmd == TIOCSIG ? arg : (unsigned long)compat_ptr(arg));
687694
}
695+
#else
696+
#define pty_unix98_compat_ioctl NULL
697+
#endif
688698

689699
/**
690700
* ptm_unix98_lookup - find a pty master

0 commit comments

Comments
 (0)