diff options
author | Arnd Bergmann <arnd@arndb.de> | 2009-11-07 01:51:16 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-07 01:52:38 -0500 |
commit | 9646e7ce3d1955478aa0573b36c151ab4b649486 (patch) | |
tree | ecef431218a43293cf0b71eec52427b20f618b02 /drivers/net/slip.c | |
parent | 50857e2a59d8beddc6bb76137df026d67f30d5ca (diff) |
net, compat_ioctl: handle socket ioctl abuses in tty drivers
Slip and a few other drivers use the same ioctl numbers on
tty devices that are normally meant for sockets. This causes
problems with our compat_ioctl handling that tries to convert
the data structures in a different format.
Fortunately, these five drivers all use 32 bit compatible
data structures in the ioctl numbers, so we can just add
a trivial compat_ioctl conversion function to each of them.
SIOCSIFENCAP and SIOCGIFENCAP do not need to live in
fs/compat_ioctl.c after this any more, and they are not
used on any sockets.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/slip.c')
-rw-r--r-- | drivers/net/slip.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/net/slip.c b/drivers/net/slip.c index e17c535a577e..ccfe45924fd9 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c | |||
@@ -79,6 +79,7 @@ | |||
79 | #include <linux/rtnetlink.h> | 79 | #include <linux/rtnetlink.h> |
80 | #include <linux/if_arp.h> | 80 | #include <linux/if_arp.h> |
81 | #include <linux/if_slip.h> | 81 | #include <linux/if_slip.h> |
82 | #include <linux/compat.h> | ||
82 | #include <linux/delay.h> | 83 | #include <linux/delay.h> |
83 | #include <linux/init.h> | 84 | #include <linux/init.h> |
84 | #include "slip.h" | 85 | #include "slip.h" |
@@ -1168,6 +1169,27 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, | |||
1168 | } | 1169 | } |
1169 | } | 1170 | } |
1170 | 1171 | ||
1172 | #ifdef CONFIG_COMPAT | ||
1173 | static long slip_compat_ioctl(struct tty_struct *tty, struct file *file, | ||
1174 | unsigned int cmd, unsigned long arg) | ||
1175 | { | ||
1176 | switch (cmd) { | ||
1177 | case SIOCGIFNAME: | ||
1178 | case SIOCGIFENCAP: | ||
1179 | case SIOCSIFENCAP: | ||
1180 | case SIOCSIFHWADDR: | ||
1181 | case SIOCSKEEPALIVE: | ||
1182 | case SIOCGKEEPALIVE: | ||
1183 | case SIOCSOUTFILL: | ||
1184 | case SIOCGOUTFILL: | ||
1185 | return slip_ioctl(tty, file, cmd, | ||
1186 | (unsigned long)compat_ptr(arg)); | ||
1187 | } | ||
1188 | |||
1189 | return -ENOIOCTLCMD; | ||
1190 | } | ||
1191 | #endif | ||
1192 | |||
1171 | /* VSV changes start here */ | 1193 | /* VSV changes start here */ |
1172 | #ifdef CONFIG_SLIP_SMART | 1194 | #ifdef CONFIG_SLIP_SMART |
1173 | /* function do_ioctl called from net/core/dev.c | 1195 | /* function do_ioctl called from net/core/dev.c |
@@ -1260,6 +1282,9 @@ static struct tty_ldisc_ops sl_ldisc = { | |||
1260 | .close = slip_close, | 1282 | .close = slip_close, |
1261 | .hangup = slip_hangup, | 1283 | .hangup = slip_hangup, |
1262 | .ioctl = slip_ioctl, | 1284 | .ioctl = slip_ioctl, |
1285 | #ifdef CONFIG_COMPAT | ||
1286 | .compat_ioctl = slip_compat_ioctl, | ||
1287 | #endif | ||
1263 | .receive_buf = slip_receive_buf, | 1288 | .receive_buf = slip_receive_buf, |
1264 | .write_wakeup = slip_write_wakeup, | 1289 | .write_wakeup = slip_write_wakeup, |
1265 | }; | 1290 | }; |