diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-04-23 00:49:25 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-05-01 13:07:21 -0400 |
commit | bf7da7bcfb38409b4cdea34b0905bdf344f1b36d (patch) | |
tree | 802584176a0957ee4bb35adfe187a573d9d1cab3 /arch/mips | |
parent | 74d92abc6143b124db03f0d341f02bde72fba6f5 (diff) |
[PATCH] remove horrors with irix tty ioctls handling
Existing code in there (get_tty(), etc.) is both severely
racy *and* pointless: ioctls in question have Linux equivalents
and there's no need to play silly buggers in irix_ioctl() -
just need to replace arguments and, in case of TIOCGSID,
deal with API differences - Linux one expects pid_t __user *
while Irix one does unsigned long __user *. BFD...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/kernel/irixioctl.c | 55 |
1 files changed, 9 insertions, 46 deletions
diff --git a/arch/mips/kernel/irixioctl.c b/arch/mips/kernel/irixioctl.c index 2bde200d5ad0..b39bdba82e02 100644 --- a/arch/mips/kernel/irixioctl.c +++ b/arch/mips/kernel/irixioctl.c | |||
@@ -27,33 +27,6 @@ struct irix_termios { | |||
27 | cc_t c_cc[NCCS]; | 27 | cc_t c_cc[NCCS]; |
28 | }; | 28 | }; |
29 | 29 | ||
30 | extern void start_tty(struct tty_struct *tty); | ||
31 | static struct tty_struct *get_tty(int fd) | ||
32 | { | ||
33 | struct file *filp; | ||
34 | struct tty_struct *ttyp = NULL; | ||
35 | |||
36 | rcu_read_lock(); | ||
37 | filp = fcheck(fd); | ||
38 | if(filp && filp->private_data) { | ||
39 | ttyp = (struct tty_struct *) filp->private_data; | ||
40 | |||
41 | if(ttyp->magic != TTY_MAGIC) | ||
42 | ttyp =NULL; | ||
43 | } | ||
44 | rcu_read_unlock(); | ||
45 | return ttyp; | ||
46 | } | ||
47 | |||
48 | static struct tty_struct *get_real_tty(struct tty_struct *tp) | ||
49 | { | ||
50 | if (tp->driver->type == TTY_DRIVER_TYPE_PTY && | ||
51 | tp->driver->subtype == PTY_TYPE_MASTER) | ||
52 | return tp->link; | ||
53 | else | ||
54 | return tp; | ||
55 | } | ||
56 | |||
57 | asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg) | 30 | asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg) |
58 | { | 31 | { |
59 | struct tty_struct *tp, *rtp; | 32 | struct tty_struct *tp, *rtp; |
@@ -146,34 +119,24 @@ asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg) | |||
146 | error = sys_ioctl(fd, TIOCNOTTY, arg); | 119 | error = sys_ioctl(fd, TIOCNOTTY, arg); |
147 | break; | 120 | break; |
148 | 121 | ||
149 | case 0x00007416: | 122 | case 0x00007416: { |
123 | pid_t pid; | ||
150 | #ifdef DEBUG_IOCTLS | 124 | #ifdef DEBUG_IOCTLS |
151 | printk("TIOCGSID, %08lx) ", arg); | 125 | printk("TIOCGSID, %08lx) ", arg); |
152 | #endif | 126 | #endif |
153 | tp = get_tty(fd); | 127 | old_fs = get_fs(); set_fs(get_ds()); |
154 | if(!tp) { | 128 | error = sys_ioctl(fd, TIOCGSID, (unsigned long)&pid); |
155 | error = -EINVAL; | 129 | set_fs(old_fs); |
156 | break; | 130 | if (!error) |
157 | } | 131 | error = put_user(pid, (unsigned long __user *) arg); |
158 | rtp = get_real_tty(tp); | ||
159 | #ifdef DEBUG_IOCTLS | ||
160 | printk("rtp->session=%d ", rtp->session); | ||
161 | #endif | ||
162 | error = put_user(rtp->session, (unsigned long __user *) arg); | ||
163 | break; | 132 | break; |
164 | 133 | } | |
165 | case 0x746e: | 134 | case 0x746e: |
166 | /* TIOCSTART, same effect as hitting ^Q */ | 135 | /* TIOCSTART, same effect as hitting ^Q */ |
167 | #ifdef DEBUG_IOCTLS | 136 | #ifdef DEBUG_IOCTLS |
168 | printk("TIOCSTART, %08lx) ", arg); | 137 | printk("TIOCSTART, %08lx) ", arg); |
169 | #endif | 138 | #endif |
170 | tp = get_tty(fd); | 139 | error = sys_ioctl(fd, TCXONC, TCOON); |
171 | if(!tp) { | ||
172 | error = -EINVAL; | ||
173 | break; | ||
174 | } | ||
175 | rtp = get_real_tty(tp); | ||
176 | start_tty(rtp); | ||
177 | break; | 140 | break; |
178 | 141 | ||
179 | case 0x20006968: | 142 | case 0x20006968: |