aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/hamradio/6pack.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2009-11-07 01:51:16 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-07 01:52:38 -0500
commit9646e7ce3d1955478aa0573b36c151ab4b649486 (patch)
treeecef431218a43293cf0b71eec52427b20f618b02 /drivers/net/hamradio/6pack.c
parent50857e2a59d8beddc6bb76137df026d67f30d5ca (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/6pack.c')
-rw-r--r--drivers/net/hamradio/6pack.c21
1 files changed, 21 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
782static 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
780static struct tty_ldisc_ops sp_ldisc = { 798static 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};