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/hamradio | |
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/hamradio')
-rw-r--r-- | drivers/net/hamradio/6pack.c | 21 | ||||
-rw-r--r-- | drivers/net/hamradio/mkiss.c | 21 |
2 files changed, 42 insertions, 0 deletions
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c index fb588301a05d..689b9bd377a5 100644 --- a/drivers/net/hamradio/6pack.c +++ b/drivers/net/hamradio/6pack.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/ip.h> | 34 | #include <linux/ip.h> |
35 | #include <linux/tcp.h> | 35 | #include <linux/tcp.h> |
36 | #include <linux/semaphore.h> | 36 | #include <linux/semaphore.h> |
37 | #include <linux/compat.h> | ||
37 | #include <asm/atomic.h> | 38 | #include <asm/atomic.h> |
38 | 39 | ||
39 | #define SIXPACK_VERSION "Revision: 0.3.0" | 40 | #define SIXPACK_VERSION "Revision: 0.3.0" |
@@ -777,6 +778,23 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file, | |||
777 | return err; | 778 | return err; |
778 | } | 779 | } |
779 | 780 | ||
781 | #ifdef CONFIG_COMPAT | ||
782 | static long sixpack_compat_ioctl(struct tty_struct * tty, struct file * file, | ||
783 | unsigned int cmd, unsigned long arg) | ||
784 | { | ||
785 | switch (cmd) { | ||
786 | case SIOCGIFNAME: | ||
787 | case SIOCGIFENCAP: | ||
788 | case SIOCSIFENCAP: | ||
789 | case SIOCSIFHWADDR: | ||
790 | return sixpack_ioctl(tty, file, cmd, | ||
791 | (unsigned long)compat_ptr(arg)); | ||
792 | } | ||
793 | |||
794 | return -ENOIOCTLCMD; | ||
795 | } | ||
796 | #endif | ||
797 | |||
780 | static struct tty_ldisc_ops sp_ldisc = { | 798 | static struct tty_ldisc_ops sp_ldisc = { |
781 | .owner = THIS_MODULE, | 799 | .owner = THIS_MODULE, |
782 | .magic = TTY_LDISC_MAGIC, | 800 | .magic = TTY_LDISC_MAGIC, |
@@ -784,6 +802,9 @@ static struct tty_ldisc_ops sp_ldisc = { | |||
784 | .open = sixpack_open, | 802 | .open = sixpack_open, |
785 | .close = sixpack_close, | 803 | .close = sixpack_close, |
786 | .ioctl = sixpack_ioctl, | 804 | .ioctl = sixpack_ioctl, |
805 | #ifdef CONFIG_COMPAT | ||
806 | .compat_ioctl = sixpack_compat_ioctl, | ||
807 | #endif | ||
787 | .receive_buf = sixpack_receive_buf, | 808 | .receive_buf = sixpack_receive_buf, |
788 | .write_wakeup = sixpack_write_wakeup, | 809 | .write_wakeup = sixpack_write_wakeup, |
789 | }; | 810 | }; |
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c index db4b7f1603f6..fc9c57893f8a 100644 --- a/drivers/net/hamradio/mkiss.c +++ b/drivers/net/hamradio/mkiss.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/skbuff.h> | 36 | #include <linux/skbuff.h> |
37 | #include <linux/if_arp.h> | 37 | #include <linux/if_arp.h> |
38 | #include <linux/jiffies.h> | 38 | #include <linux/jiffies.h> |
39 | #include <linux/compat.h> | ||
39 | 40 | ||
40 | #include <net/ax25.h> | 41 | #include <net/ax25.h> |
41 | 42 | ||
@@ -898,6 +899,23 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file, | |||
898 | return err; | 899 | return err; |
899 | } | 900 | } |
900 | 901 | ||
902 | #ifdef CONFIG_COMPAT | ||
903 | static long mkiss_compat_ioctl(struct tty_struct *tty, struct file *file, | ||
904 | unsigned int cmd, unsigned long arg) | ||
905 | { | ||
906 | switch (arg) { | ||
907 | case SIOCGIFNAME: | ||
908 | case SIOCGIFENCAP: | ||
909 | case SIOCSIFENCAP: | ||
910 | case SIOCSIFHWADDR: | ||
911 | return mkiss_ioctl(tty, file, cmd, | ||
912 | (unsigned long)compat_ptr(arg)); | ||
913 | } | ||
914 | |||
915 | return -ENOIOCTLCMD; | ||
916 | } | ||
917 | #endif | ||
918 | |||
901 | /* | 919 | /* |
902 | * Handle the 'receiver data ready' interrupt. | 920 | * Handle the 'receiver data ready' interrupt. |
903 | * This function is called by the 'tty_io' module in the kernel when | 921 | * This function is called by the 'tty_io' module in the kernel when |
@@ -972,6 +990,9 @@ static struct tty_ldisc_ops ax_ldisc = { | |||
972 | .open = mkiss_open, | 990 | .open = mkiss_open, |
973 | .close = mkiss_close, | 991 | .close = mkiss_close, |
974 | .ioctl = mkiss_ioctl, | 992 | .ioctl = mkiss_ioctl, |
993 | #ifdef CONFIG_COMPAT | ||
994 | .compat_ioctl = mkiss_compat_ioctl, | ||
995 | #endif | ||
975 | .receive_buf = mkiss_receive_buf, | 996 | .receive_buf = mkiss_receive_buf, |
976 | .write_wakeup = mkiss_write_wakeup | 997 | .write_wakeup = mkiss_write_wakeup |
977 | }; | 998 | }; |