diff options
| -rw-r--r-- | drivers/char/lp.c | 115 | ||||
| -rw-r--r-- | drivers/usb/core/devio.c | 110 | ||||
| -rw-r--r-- | fs/compat_ioctl.c | 767 | ||||
| -rw-r--r-- | include/linux/usbdevice_fs.h | 26 |
4 files changed, 417 insertions, 601 deletions
diff --git a/drivers/char/lp.c b/drivers/char/lp.c index e444c2dba160..938a3a273886 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c | |||
| @@ -127,6 +127,7 @@ | |||
| 127 | #include <linux/wait.h> | 127 | #include <linux/wait.h> |
| 128 | #include <linux/jiffies.h> | 128 | #include <linux/jiffies.h> |
| 129 | #include <linux/smp_lock.h> | 129 | #include <linux/smp_lock.h> |
| 130 | #include <linux/compat.h> | ||
| 130 | 131 | ||
| 131 | #include <linux/parport.h> | 132 | #include <linux/parport.h> |
| 132 | #undef LP_STATS | 133 | #undef LP_STATS |
| @@ -571,13 +572,11 @@ static int lp_release(struct inode * inode, struct file * file) | |||
| 571 | return 0; | 572 | return 0; |
| 572 | } | 573 | } |
| 573 | 574 | ||
| 574 | static int lp_ioctl(struct inode *inode, struct file *file, | 575 | static int lp_do_ioctl(unsigned int minor, unsigned int cmd, |
| 575 | unsigned int cmd, unsigned long arg) | 576 | unsigned long arg, void __user *argp) |
| 576 | { | 577 | { |
| 577 | unsigned int minor = iminor(inode); | ||
| 578 | int status; | 578 | int status; |
| 579 | int retval = 0; | 579 | int retval = 0; |
| 580 | void __user *argp = (void __user *)arg; | ||
| 581 | 580 | ||
| 582 | #ifdef LP_DEBUG | 581 | #ifdef LP_DEBUG |
| 583 | printk(KERN_DEBUG "lp%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg); | 582 | printk(KERN_DEBUG "lp%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg); |
| @@ -587,9 +586,6 @@ static int lp_ioctl(struct inode *inode, struct file *file, | |||
| 587 | if ((LP_F(minor) & LP_EXIST) == 0) | 586 | if ((LP_F(minor) & LP_EXIST) == 0) |
| 588 | return -ENODEV; | 587 | return -ENODEV; |
| 589 | switch ( cmd ) { | 588 | switch ( cmd ) { |
| 590 | struct timeval par_timeout; | ||
| 591 | long to_jiffies; | ||
| 592 | |||
| 593 | case LPTIME: | 589 | case LPTIME: |
| 594 | LP_TIME(minor) = arg * HZ/100; | 590 | LP_TIME(minor) = arg * HZ/100; |
| 595 | break; | 591 | break; |
| @@ -652,34 +648,101 @@ static int lp_ioctl(struct inode *inode, struct file *file, | |||
| 652 | return -EFAULT; | 648 | return -EFAULT; |
| 653 | break; | 649 | break; |
| 654 | 650 | ||
| 655 | case LPSETTIMEOUT: | ||
| 656 | if (copy_from_user (&par_timeout, argp, | ||
| 657 | sizeof (struct timeval))) { | ||
| 658 | return -EFAULT; | ||
| 659 | } | ||
| 660 | /* Convert to jiffies, place in lp_table */ | ||
| 661 | if ((par_timeout.tv_sec < 0) || | ||
| 662 | (par_timeout.tv_usec < 0)) { | ||
| 663 | return -EINVAL; | ||
| 664 | } | ||
| 665 | to_jiffies = DIV_ROUND_UP(par_timeout.tv_usec, 1000000/HZ); | ||
| 666 | to_jiffies += par_timeout.tv_sec * (long) HZ; | ||
| 667 | if (to_jiffies <= 0) { | ||
| 668 | return -EINVAL; | ||
| 669 | } | ||
| 670 | lp_table[minor].timeout = to_jiffies; | ||
| 671 | break; | ||
| 672 | |||
| 673 | default: | 651 | default: |
| 674 | retval = -EINVAL; | 652 | retval = -EINVAL; |
| 675 | } | 653 | } |
| 676 | return retval; | 654 | return retval; |
| 677 | } | 655 | } |
| 678 | 656 | ||
| 657 | static int lp_set_timeout(unsigned int minor, struct timeval *par_timeout) | ||
| 658 | { | ||
| 659 | long to_jiffies; | ||
| 660 | |||
| 661 | /* Convert to jiffies, place in lp_table */ | ||
| 662 | if ((par_timeout->tv_sec < 0) || | ||
| 663 | (par_timeout->tv_usec < 0)) { | ||
| 664 | return -EINVAL; | ||
| 665 | } | ||
| 666 | to_jiffies = DIV_ROUND_UP(par_timeout->tv_usec, 1000000/HZ); | ||
| 667 | to_jiffies += par_timeout->tv_sec * (long) HZ; | ||
| 668 | if (to_jiffies <= 0) { | ||
| 669 | return -EINVAL; | ||
| 670 | } | ||
| 671 | lp_table[minor].timeout = to_jiffies; | ||
| 672 | return 0; | ||
| 673 | } | ||
| 674 | |||
| 675 | static long lp_ioctl(struct file *file, unsigned int cmd, | ||
| 676 | unsigned long arg) | ||
| 677 | { | ||
| 678 | unsigned int minor; | ||
| 679 | struct timeval par_timeout; | ||
| 680 | int ret; | ||
| 681 | |||
| 682 | minor = iminor(file->f_path.dentry->d_inode); | ||
| 683 | lock_kernel(); | ||
| 684 | switch (cmd) { | ||
| 685 | case LPSETTIMEOUT: | ||
| 686 | if (copy_from_user(&par_timeout, (void __user *)arg, | ||
| 687 | sizeof (struct timeval))) { | ||
| 688 | ret = -EFAULT; | ||
| 689 | break; | ||
| 690 | } | ||
| 691 | ret = lp_set_timeout(minor, &par_timeout); | ||
| 692 | break; | ||
| 693 | default: | ||
| 694 | ret = lp_do_ioctl(minor, cmd, arg, (void __user *)arg); | ||
| 695 | break; | ||
| 696 | } | ||
| 697 | unlock_kernel(); | ||
| 698 | |||
| 699 | return ret; | ||
| 700 | } | ||
| 701 | |||
| 702 | #ifdef CONFIG_COMPAT | ||
| 703 | static long lp_compat_ioctl(struct file *file, unsigned int cmd, | ||
| 704 | unsigned long arg) | ||
| 705 | { | ||
| 706 | unsigned int minor; | ||
| 707 | struct timeval par_timeout; | ||
| 708 | struct compat_timeval __user *tc; | ||
| 709 | int ret; | ||
| 710 | |||
| 711 | minor = iminor(file->f_path.dentry->d_inode); | ||
| 712 | lock_kernel(); | ||
| 713 | switch (cmd) { | ||
| 714 | case LPSETTIMEOUT: | ||
| 715 | tc = compat_ptr(arg); | ||
| 716 | if (get_user(par_timeout.tv_sec, &tc->tv_sec) || | ||
| 717 | get_user(par_timeout.tv_usec, &tc->tv_usec)) { | ||
| 718 | ret = -EFAULT; | ||
| 719 | break; | ||
| 720 | } | ||
| 721 | ret = lp_set_timeout(minor, &par_timeout); | ||
| 722 | break; | ||
| 723 | #ifdef LP_STATS | ||
| 724 | case LPGETSTATS: | ||
| 725 | /* FIXME: add an implementation if you set LP_STATS */ | ||
| 726 | ret = -EINVAL; | ||
| 727 | break; | ||
| 728 | #endif | ||
| 729 | default: | ||
| 730 | ret = lp_do_ioctl(minor, cmd, arg, compat_ptr(arg)); | ||
| 731 | break; | ||
| 732 | } | ||
| 733 | unlock_kernel(); | ||
| 734 | |||
| 735 | return ret; | ||
| 736 | } | ||
| 737 | #endif | ||
| 738 | |||
| 679 | static const struct file_operations lp_fops = { | 739 | static const struct file_operations lp_fops = { |
| 680 | .owner = THIS_MODULE, | 740 | .owner = THIS_MODULE, |
| 681 | .write = lp_write, | 741 | .write = lp_write, |
| 682 | .ioctl = lp_ioctl, | 742 | .unlocked_ioctl = lp_ioctl, |
| 743 | #ifdef CONFIG_COMPAT | ||
| 744 | .compat_ioctl = lp_compat_ioctl, | ||
| 745 | #endif | ||
| 683 | .open = lp_open, | 746 | .open = lp_open, |
| 684 | .release = lp_release, | 747 | .release = lp_release, |
| 685 | #ifdef CONFIG_PARPORT_1284 | 748 | #ifdef CONFIG_PARPORT_1284 |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 181f78c84105..6e8bcdfd23b4 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
| @@ -1388,6 +1388,46 @@ static int proc_reapurbnonblock(struct dev_state *ps, void __user *arg) | |||
| 1388 | } | 1388 | } |
| 1389 | 1389 | ||
| 1390 | #ifdef CONFIG_COMPAT | 1390 | #ifdef CONFIG_COMPAT |
| 1391 | static int proc_control_compat(struct dev_state *ps, | ||
| 1392 | struct usbdevfs_ctrltransfer32 __user *p32) | ||
| 1393 | { | ||
| 1394 | struct usbdevfs_ctrltransfer __user *p; | ||
| 1395 | __u32 udata; | ||
| 1396 | p = compat_alloc_user_space(sizeof(*p)); | ||
| 1397 | if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) || | ||
| 1398 | get_user(udata, &p32->data) || | ||
| 1399 | put_user(compat_ptr(udata), &p->data)) | ||
| 1400 | return -EFAULT; | ||
| 1401 | return proc_control(ps, p); | ||
| 1402 | } | ||
| 1403 | |||
| 1404 | static int proc_bulk_compat(struct dev_state *ps, | ||
| 1405 | struct usbdevfs_bulktransfer32 __user *p32) | ||
| 1406 | { | ||
| 1407 | struct usbdevfs_bulktransfer __user *p; | ||
| 1408 | compat_uint_t n; | ||
| 1409 | compat_caddr_t addr; | ||
| 1410 | |||
| 1411 | p = compat_alloc_user_space(sizeof(*p)); | ||
| 1412 | |||
| 1413 | if (get_user(n, &p32->ep) || put_user(n, &p->ep) || | ||
| 1414 | get_user(n, &p32->len) || put_user(n, &p->len) || | ||
| 1415 | get_user(n, &p32->timeout) || put_user(n, &p->timeout) || | ||
| 1416 | get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data)) | ||
| 1417 | return -EFAULT; | ||
| 1418 | |||
| 1419 | return proc_bulk(ps, p); | ||
| 1420 | } | ||
| 1421 | static int proc_disconnectsignal_compat(struct dev_state *ps, void __user *arg) | ||
| 1422 | { | ||
| 1423 | struct usbdevfs_disconnectsignal32 ds; | ||
| 1424 | |||
| 1425 | if (copy_from_user(&ds, arg, sizeof(ds))) | ||
| 1426 | return -EFAULT; | ||
| 1427 | ps->discsignr = ds.signr; | ||
| 1428 | ps->disccontext = compat_ptr(ds.context); | ||
| 1429 | return 0; | ||
| 1430 | } | ||
| 1391 | 1431 | ||
| 1392 | static int get_urb32(struct usbdevfs_urb *kurb, | 1432 | static int get_urb32(struct usbdevfs_urb *kurb, |
| 1393 | struct usbdevfs_urb32 __user *uurb) | 1433 | struct usbdevfs_urb32 __user *uurb) |
| @@ -1482,6 +1522,7 @@ static int proc_reapurbnonblock_compat(struct dev_state *ps, void __user *arg) | |||
| 1482 | return processcompl_compat(as, (void __user * __user *)arg); | 1522 | return processcompl_compat(as, (void __user * __user *)arg); |
| 1483 | } | 1523 | } |
| 1484 | 1524 | ||
| 1525 | |||
| 1485 | #endif | 1526 | #endif |
| 1486 | 1527 | ||
| 1487 | static int proc_disconnectsignal(struct dev_state *ps, void __user *arg) | 1528 | static int proc_disconnectsignal(struct dev_state *ps, void __user *arg) |
| @@ -1648,12 +1689,12 @@ static int proc_release_port(struct dev_state *ps, void __user *arg) | |||
| 1648 | * are assuming that somehow the configuration has been prevented from | 1689 | * are assuming that somehow the configuration has been prevented from |
| 1649 | * changing. But there's no mechanism to ensure that... | 1690 | * changing. But there's no mechanism to ensure that... |
| 1650 | */ | 1691 | */ |
| 1651 | static int usbdev_ioctl(struct inode *inode, struct file *file, | 1692 | static long usbdev_do_ioctl(struct file *file, unsigned int cmd, |
| 1652 | unsigned int cmd, unsigned long arg) | 1693 | void __user *p) |
| 1653 | { | 1694 | { |
| 1654 | struct dev_state *ps = file->private_data; | 1695 | struct dev_state *ps = file->private_data; |
| 1696 | struct inode *inode = file->f_path.dentry->d_inode; | ||
| 1655 | struct usb_device *dev = ps->dev; | 1697 | struct usb_device *dev = ps->dev; |
| 1656 | void __user *p = (void __user *)arg; | ||
| 1657 | int ret = -ENOTTY; | 1698 | int ret = -ENOTTY; |
| 1658 | 1699 | ||
| 1659 | if (!(file->f_mode & FMODE_WRITE)) | 1700 | if (!(file->f_mode & FMODE_WRITE)) |
| @@ -1726,6 +1767,24 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, | |||
| 1726 | break; | 1767 | break; |
| 1727 | 1768 | ||
| 1728 | #ifdef CONFIG_COMPAT | 1769 | #ifdef CONFIG_COMPAT |
| 1770 | case USBDEVFS_CONTROL32: | ||
| 1771 | snoop(&dev->dev, "%s: CONTROL32\n", __func__); | ||
| 1772 | ret = proc_control_compat(ps, p); | ||
| 1773 | if (ret >= 0) | ||
| 1774 | inode->i_mtime = CURRENT_TIME; | ||
| 1775 | break; | ||
| 1776 | |||
| 1777 | case USBDEVFS_BULK32: | ||
| 1778 | snoop(&dev->dev, "%s: BULK32\n", __func__); | ||
| 1779 | ret = proc_bulk_compat(ps, p); | ||
| 1780 | if (ret >= 0) | ||
| 1781 | inode->i_mtime = CURRENT_TIME; | ||
| 1782 | break; | ||
| 1783 | |||
| 1784 | case USBDEVFS_DISCSIGNAL32: | ||
| 1785 | snoop(&dev->dev, "%s: DISCSIGNAL32\n", __func__); | ||
| 1786 | ret = proc_disconnectsignal_compat(ps, p); | ||
| 1787 | break; | ||
| 1729 | 1788 | ||
| 1730 | case USBDEVFS_SUBMITURB32: | 1789 | case USBDEVFS_SUBMITURB32: |
| 1731 | snoop(&dev->dev, "%s: SUBMITURB32\n", __func__); | 1790 | snoop(&dev->dev, "%s: SUBMITURB32\n", __func__); |
| @@ -1745,7 +1804,7 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, | |||
| 1745 | break; | 1804 | break; |
| 1746 | 1805 | ||
| 1747 | case USBDEVFS_IOCTL32: | 1806 | case USBDEVFS_IOCTL32: |
| 1748 | snoop(&dev->dev, "%s: IOCTL\n", __func__); | 1807 | snoop(&dev->dev, "%s: IOCTL32\n", __func__); |
| 1749 | ret = proc_ioctl_compat(ps, ptr_to_compat(p)); | 1808 | ret = proc_ioctl_compat(ps, ptr_to_compat(p)); |
| 1750 | break; | 1809 | break; |
| 1751 | #endif | 1810 | #endif |
| @@ -1801,6 +1860,32 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, | |||
| 1801 | return ret; | 1860 | return ret; |
| 1802 | } | 1861 | } |
| 1803 | 1862 | ||
| 1863 | static long usbdev_ioctl(struct file *file, unsigned int cmd, | ||
| 1864 | unsigned long arg) | ||
| 1865 | { | ||
| 1866 | int ret; | ||
| 1867 | |||
| 1868 | lock_kernel(); | ||
| 1869 | ret = usbdev_do_ioctl(file, cmd, (void __user *)arg); | ||
| 1870 | unlock_kernel(); | ||
| 1871 | |||
| 1872 | return ret; | ||
| 1873 | } | ||
| 1874 | |||
| 1875 | #ifdef CONFIG_COMPAT | ||
| 1876 | static long usbdev_compat_ioctl(struct file *file, unsigned int cmd, | ||
| 1877 | unsigned long arg) | ||
| 1878 | { | ||
| 1879 | int ret; | ||
| 1880 | |||
| 1881 | lock_kernel(); | ||
| 1882 | ret = usbdev_do_ioctl(file, cmd, compat_ptr(arg)); | ||
| 1883 | unlock_kernel(); | ||
| 1884 | |||
| 1885 | return ret; | ||
| 1886 | } | ||
| 1887 | #endif | ||
| 1888 | |||
| 1804 | /* No kernel lock - fine */ | 1889 | /* No kernel lock - fine */ |
| 1805 | static unsigned int usbdev_poll(struct file *file, | 1890 | static unsigned int usbdev_poll(struct file *file, |
| 1806 | struct poll_table_struct *wait) | 1891 | struct poll_table_struct *wait) |
| @@ -1817,13 +1902,16 @@ static unsigned int usbdev_poll(struct file *file, | |||
| 1817 | } | 1902 | } |
| 1818 | 1903 | ||
| 1819 | const struct file_operations usbdev_file_operations = { | 1904 | const struct file_operations usbdev_file_operations = { |
| 1820 | .owner = THIS_MODULE, | 1905 | .owner = THIS_MODULE, |
| 1821 | .llseek = usbdev_lseek, | 1906 | .llseek = usbdev_lseek, |
| 1822 | .read = usbdev_read, | 1907 | .read = usbdev_read, |
| 1823 | .poll = usbdev_poll, | 1908 | .poll = usbdev_poll, |
| 1824 | .ioctl = usbdev_ioctl, | 1909 | .unlocked_ioctl = usbdev_ioctl, |
| 1825 | .open = usbdev_open, | 1910 | #ifdef CONFIG_COMPAT |
| 1826 | .release = usbdev_release, | 1911 | .compat_ioctl = usbdev_compat_ioctl, |
| 1912 | #endif | ||
| 1913 | .open = usbdev_open, | ||
| 1914 | .release = usbdev_release, | ||
| 1827 | }; | 1915 | }; |
| 1828 | 1916 | ||
| 1829 | static void usbdev_remove(struct usb_device *udev) | 1917 | static void usbdev_remove(struct usb_device *udev) |
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 2346895b3a77..278020d2449c 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
| @@ -111,43 +111,40 @@ | |||
| 111 | #include <linux/dvb/frontend.h> | 111 | #include <linux/dvb/frontend.h> |
| 112 | #include <linux/dvb/video.h> | 112 | #include <linux/dvb/video.h> |
| 113 | 113 | ||
| 114 | #include <linux/sort.h> | ||
| 115 | |||
| 114 | #ifdef CONFIG_SPARC | 116 | #ifdef CONFIG_SPARC |
| 115 | #include <asm/fbio.h> | 117 | #include <asm/fbio.h> |
| 116 | #endif | 118 | #endif |
| 117 | 119 | ||
| 118 | static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, | 120 | static int w_long(unsigned int fd, unsigned int cmd, |
| 119 | unsigned long arg, struct file *f) | 121 | compat_ulong_t __user *argp) |
| 120 | { | ||
| 121 | return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg)); | ||
| 122 | } | ||
| 123 | |||
| 124 | static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 125 | { | 122 | { |
| 126 | mm_segment_t old_fs = get_fs(); | 123 | mm_segment_t old_fs = get_fs(); |
| 127 | int err; | 124 | int err; |
| 128 | unsigned long val; | 125 | unsigned long val; |
| 129 | 126 | ||
| 130 | set_fs (KERNEL_DS); | 127 | set_fs (KERNEL_DS); |
| 131 | err = sys_ioctl(fd, cmd, (unsigned long)&val); | 128 | err = sys_ioctl(fd, cmd, (unsigned long)&val); |
| 132 | set_fs (old_fs); | 129 | set_fs (old_fs); |
| 133 | if (!err && put_user(val, (u32 __user *)compat_ptr(arg))) | 130 | if (!err && put_user(val, argp)) |
| 134 | return -EFAULT; | 131 | return -EFAULT; |
| 135 | return err; | 132 | return err; |
| 136 | } | 133 | } |
| 137 | 134 | ||
| 138 | static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg) | 135 | static int rw_long(unsigned int fd, unsigned int cmd, |
| 136 | compat_ulong_t __user *argp) | ||
| 139 | { | 137 | { |
| 140 | mm_segment_t old_fs = get_fs(); | 138 | mm_segment_t old_fs = get_fs(); |
| 141 | u32 __user *argptr = compat_ptr(arg); | ||
| 142 | int err; | 139 | int err; |
| 143 | unsigned long val; | 140 | unsigned long val; |
| 144 | 141 | ||
| 145 | if(get_user(val, argptr)) | 142 | if(get_user(val, argp)) |
| 146 | return -EFAULT; | 143 | return -EFAULT; |
| 147 | set_fs (KERNEL_DS); | 144 | set_fs (KERNEL_DS); |
| 148 | err = sys_ioctl(fd, cmd, (unsigned long)&val); | 145 | err = sys_ioctl(fd, cmd, (unsigned long)&val); |
| 149 | set_fs (old_fs); | 146 | set_fs (old_fs); |
| 150 | if (!err && put_user(val, argptr)) | 147 | if (!err && put_user(val, argp)) |
| 151 | return -EFAULT; | 148 | return -EFAULT; |
| 152 | return err; | 149 | return err; |
| 153 | } | 150 | } |
| @@ -161,7 +158,8 @@ struct compat_video_event { | |||
| 161 | } u; | 158 | } u; |
| 162 | }; | 159 | }; |
| 163 | 160 | ||
| 164 | static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg) | 161 | static int do_video_get_event(unsigned int fd, unsigned int cmd, |
| 162 | struct compat_video_event __user *up) | ||
| 165 | { | 163 | { |
| 166 | struct video_event kevent; | 164 | struct video_event kevent; |
| 167 | mm_segment_t old_fs = get_fs(); | 165 | mm_segment_t old_fs = get_fs(); |
| @@ -172,8 +170,6 @@ static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long a | |||
| 172 | set_fs(old_fs); | 170 | set_fs(old_fs); |
| 173 | 171 | ||
| 174 | if (!err) { | 172 | if (!err) { |
| 175 | struct compat_video_event __user *up = compat_ptr(arg); | ||
| 176 | |||
| 177 | err = put_user(kevent.type, &up->type); | 173 | err = put_user(kevent.type, &up->type); |
| 178 | err |= put_user(kevent.timestamp, &up->timestamp); | 174 | err |= put_user(kevent.timestamp, &up->timestamp); |
| 179 | err |= put_user(kevent.u.size.w, &up->u.size.w); | 175 | err |= put_user(kevent.u.size.w, &up->u.size.w); |
| @@ -192,15 +188,14 @@ struct compat_video_still_picture { | |||
| 192 | int32_t size; | 188 | int32_t size; |
| 193 | }; | 189 | }; |
| 194 | 190 | ||
| 195 | static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg) | 191 | static int do_video_stillpicture(unsigned int fd, unsigned int cmd, |
| 192 | struct compat_video_still_picture __user *up) | ||
| 196 | { | 193 | { |
| 197 | struct compat_video_still_picture __user *up; | ||
| 198 | struct video_still_picture __user *up_native; | 194 | struct video_still_picture __user *up_native; |
| 199 | compat_uptr_t fp; | 195 | compat_uptr_t fp; |
| 200 | int32_t size; | 196 | int32_t size; |
| 201 | int err; | 197 | int err; |
| 202 | 198 | ||
| 203 | up = (struct compat_video_still_picture __user *) arg; | ||
| 204 | err = get_user(fp, &up->iFrame); | 199 | err = get_user(fp, &up->iFrame); |
| 205 | err |= get_user(size, &up->size); | 200 | err |= get_user(size, &up->size); |
| 206 | if (err) | 201 | if (err) |
| @@ -224,14 +219,13 @@ struct compat_video_spu_palette { | |||
| 224 | compat_uptr_t palette; | 219 | compat_uptr_t palette; |
| 225 | }; | 220 | }; |
| 226 | 221 | ||
| 227 | static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg) | 222 | static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, |
| 223 | struct compat_video_spu_palette __user *up) | ||
| 228 | { | 224 | { |
| 229 | struct compat_video_spu_palette __user *up; | ||
| 230 | struct video_spu_palette __user *up_native; | 225 | struct video_spu_palette __user *up_native; |
| 231 | compat_uptr_t palp; | 226 | compat_uptr_t palp; |
| 232 | int length, err; | 227 | int length, err; |
| 233 | 228 | ||
| 234 | up = (struct compat_video_spu_palette __user *) arg; | ||
| 235 | err = get_user(palp, &up->palette); | 229 | err = get_user(palp, &up->palette); |
| 236 | err |= get_user(length, &up->length); | 230 | err |= get_user(length, &up->length); |
| 237 | 231 | ||
| @@ -299,16 +293,15 @@ static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iov | |||
| 299 | return 0; | 293 | return 0; |
| 300 | } | 294 | } |
| 301 | 295 | ||
| 302 | static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 296 | static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, |
| 297 | sg_io_hdr32_t __user *sgio32) | ||
| 303 | { | 298 | { |
| 304 | sg_io_hdr_t __user *sgio; | 299 | sg_io_hdr_t __user *sgio; |
| 305 | sg_io_hdr32_t __user *sgio32; | ||
| 306 | u16 iovec_count; | 300 | u16 iovec_count; |
| 307 | u32 data; | 301 | u32 data; |
| 308 | void __user *dxferp; | 302 | void __user *dxferp; |
| 309 | int err; | 303 | int err; |
| 310 | 304 | ||
| 311 | sgio32 = compat_ptr(arg); | ||
| 312 | if (get_user(iovec_count, &sgio32->iovec_count)) | 305 | if (get_user(iovec_count, &sgio32->iovec_count)) |
| 313 | return -EFAULT; | 306 | return -EFAULT; |
| 314 | 307 | ||
| @@ -398,11 +391,11 @@ struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */ | |||
| 398 | int unused; | 391 | int unused; |
| 399 | }; | 392 | }; |
| 400 | 393 | ||
| 401 | static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 394 | static int sg_grt_trans(unsigned int fd, unsigned int cmd, struct |
| 395 | compat_sg_req_info __user *o) | ||
| 402 | { | 396 | { |
| 403 | int err, i; | 397 | int err, i; |
| 404 | sg_req_info_t __user *r; | 398 | sg_req_info_t __user *r; |
| 405 | struct compat_sg_req_info __user *o = (void __user *)arg; | ||
| 406 | r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE); | 399 | r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE); |
| 407 | err = sys_ioctl(fd,cmd,(unsigned long)r); | 400 | err = sys_ioctl(fd,cmd,(unsigned long)r); |
| 408 | if (err < 0) | 401 | if (err < 0) |
| @@ -430,9 +423,9 @@ struct sock_fprog32 { | |||
| 430 | #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32) | 423 | #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32) |
| 431 | #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32) | 424 | #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32) |
| 432 | 425 | ||
| 433 | static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 426 | static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, |
| 427 | struct sock_fprog32 __user *u_fprog32) | ||
| 434 | { | 428 | { |
| 435 | struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg); | ||
| 436 | struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog)); | 429 | struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog)); |
| 437 | void __user *fptr64; | 430 | void __user *fptr64; |
| 438 | u32 fptr32; | 431 | u32 fptr32; |
| @@ -469,15 +462,14 @@ struct ppp_idle32 { | |||
| 469 | }; | 462 | }; |
| 470 | #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32) | 463 | #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32) |
| 471 | 464 | ||
| 472 | static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg) | 465 | static int ppp_gidle(unsigned int fd, unsigned int cmd, |
| 466 | struct ppp_idle32 __user *idle32) | ||
| 473 | { | 467 | { |
| 474 | struct ppp_idle __user *idle; | 468 | struct ppp_idle __user *idle; |
| 475 | struct ppp_idle32 __user *idle32; | ||
| 476 | __kernel_time_t xmit, recv; | 469 | __kernel_time_t xmit, recv; |
| 477 | int err; | 470 | int err; |
| 478 | 471 | ||
| 479 | idle = compat_alloc_user_space(sizeof(*idle)); | 472 | idle = compat_alloc_user_space(sizeof(*idle)); |
| 480 | idle32 = compat_ptr(arg); | ||
| 481 | 473 | ||
| 482 | err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle); | 474 | err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle); |
| 483 | 475 | ||
| @@ -491,15 +483,14 @@ static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
| 491 | return err; | 483 | return err; |
| 492 | } | 484 | } |
| 493 | 485 | ||
| 494 | static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg) | 486 | static int ppp_scompress(unsigned int fd, unsigned int cmd, |
| 487 | struct ppp_option_data32 __user *odata32) | ||
| 495 | { | 488 | { |
| 496 | struct ppp_option_data __user *odata; | 489 | struct ppp_option_data __user *odata; |
| 497 | struct ppp_option_data32 __user *odata32; | ||
| 498 | __u32 data; | 490 | __u32 data; |
| 499 | void __user *datap; | 491 | void __user *datap; |
| 500 | 492 | ||
| 501 | odata = compat_alloc_user_space(sizeof(*odata)); | 493 | odata = compat_alloc_user_space(sizeof(*odata)); |
| 502 | odata32 = compat_ptr(arg); | ||
| 503 | 494 | ||
| 504 | if (get_user(data, &odata32->ptr)) | 495 | if (get_user(data, &odata32->ptr)) |
| 505 | return -EFAULT; | 496 | return -EFAULT; |
| @@ -515,35 +506,6 @@ static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
| 515 | return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata); | 506 | return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata); |
| 516 | } | 507 | } |
| 517 | 508 | ||
| 518 | static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 519 | { | ||
| 520 | int err; | ||
| 521 | |||
| 522 | switch (cmd) { | ||
| 523 | case PPPIOCGIDLE32: | ||
| 524 | err = ppp_gidle(fd, cmd, arg); | ||
| 525 | break; | ||
| 526 | |||
| 527 | case PPPIOCSCOMPRESS32: | ||
| 528 | err = ppp_scompress(fd, cmd, arg); | ||
| 529 | break; | ||
| 530 | |||
| 531 | default: | ||
| 532 | do { | ||
| 533 | static int count; | ||
| 534 | if (++count <= 20) | ||
| 535 | printk("ppp_ioctl: Unknown cmd fd(%d) " | ||
| 536 | "cmd(%08x) arg(%08x)\n", | ||
| 537 | (int)fd, (unsigned int)cmd, (unsigned int)arg); | ||
| 538 | } while(0); | ||
| 539 | err = -EINVAL; | ||
| 540 | break; | ||
| 541 | }; | ||
| 542 | |||
| 543 | return err; | ||
| 544 | } | ||
| 545 | |||
| 546 | |||
| 547 | #ifdef CONFIG_BLOCK | 509 | #ifdef CONFIG_BLOCK |
| 548 | struct mtget32 { | 510 | struct mtget32 { |
| 549 | compat_long_t mt_type; | 511 | compat_long_t mt_type; |
| @@ -561,7 +523,7 @@ struct mtpos32 { | |||
| 561 | }; | 523 | }; |
| 562 | #define MTIOCPOS32 _IOR('m', 3, struct mtpos32) | 524 | #define MTIOCPOS32 _IOR('m', 3, struct mtpos32) |
| 563 | 525 | ||
| 564 | static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 526 | static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, void __user *argp) |
| 565 | { | 527 | { |
| 566 | mm_segment_t old_fs = get_fs(); | 528 | mm_segment_t old_fs = get_fs(); |
| 567 | struct mtget get; | 529 | struct mtget get; |
| @@ -581,15 +543,6 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
| 581 | kcmd = MTIOCGET; | 543 | kcmd = MTIOCGET; |
| 582 | karg = &get; | 544 | karg = &get; |
| 583 | break; | 545 | break; |
| 584 | default: | ||
| 585 | do { | ||
| 586 | static int count; | ||
| 587 | if (++count <= 20) | ||
| 588 | printk("mt_ioctl: Unknown cmd fd(%d) " | ||
| 589 | "cmd(%08x) arg(%08x)\n", | ||
| 590 | (int)fd, (unsigned int)cmd, (unsigned int)arg); | ||
| 591 | } while(0); | ||
| 592 | return -EINVAL; | ||
| 593 | } | 546 | } |
| 594 | set_fs (KERNEL_DS); | 547 | set_fs (KERNEL_DS); |
| 595 | err = sys_ioctl (fd, kcmd, (unsigned long)karg); | 548 | err = sys_ioctl (fd, kcmd, (unsigned long)karg); |
| @@ -598,11 +551,11 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
| 598 | return err; | 551 | return err; |
| 599 | switch (cmd) { | 552 | switch (cmd) { |
| 600 | case MTIOCPOS32: | 553 | case MTIOCPOS32: |
| 601 | upos32 = compat_ptr(arg); | 554 | upos32 = argp; |
| 602 | err = __put_user(pos.mt_blkno, &upos32->mt_blkno); | 555 | err = __put_user(pos.mt_blkno, &upos32->mt_blkno); |
| 603 | break; | 556 | break; |
| 604 | case MTIOCGET32: | 557 | case MTIOCGET32: |
| 605 | umget32 = compat_ptr(arg); | 558 | umget32 = argp; |
| 606 | err = __put_user(get.mt_type, &umget32->mt_type); | 559 | err = __put_user(get.mt_type, &umget32->mt_type); |
| 607 | err |= __put_user(get.mt_resid, &umget32->mt_resid); | 560 | err |= __put_user(get.mt_resid, &umget32->mt_resid); |
| 608 | err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg); | 561 | err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg); |
| @@ -617,162 +570,8 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
| 617 | 570 | ||
| 618 | #endif /* CONFIG_BLOCK */ | 571 | #endif /* CONFIG_BLOCK */ |
| 619 | 572 | ||
| 620 | #ifdef CONFIG_VT | 573 | static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, |
| 621 | 574 | compat_uid_t __user *argp) | |
| 622 | static int vt_check(struct file *file) | ||
| 623 | { | ||
| 624 | struct tty_struct *tty; | ||
| 625 | struct inode *inode = file->f_path.dentry->d_inode; | ||
| 626 | struct vc_data *vc; | ||
| 627 | |||
| 628 | if (file->f_op->unlocked_ioctl != tty_ioctl) | ||
| 629 | return -EINVAL; | ||
| 630 | |||
| 631 | tty = (struct tty_struct *)file->private_data; | ||
| 632 | if (tty_paranoia_check(tty, inode, "tty_ioctl")) | ||
| 633 | return -EINVAL; | ||
| 634 | |||
| 635 | if (tty->ops->ioctl != vt_ioctl) | ||
| 636 | return -EINVAL; | ||
| 637 | |||
| 638 | vc = (struct vc_data *)tty->driver_data; | ||
| 639 | if (!vc_cons_allocated(vc->vc_num)) /* impossible? */ | ||
| 640 | return -ENOIOCTLCMD; | ||
| 641 | |||
| 642 | /* | ||
| 643 | * To have permissions to do most of the vt ioctls, we either have | ||
| 644 | * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG. | ||
| 645 | */ | ||
| 646 | if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG)) | ||
| 647 | return 1; | ||
| 648 | return 0; | ||
| 649 | } | ||
| 650 | |||
| 651 | struct consolefontdesc32 { | ||
| 652 | unsigned short charcount; /* characters in font (256 or 512) */ | ||
| 653 | unsigned short charheight; /* scan lines per character (1-32) */ | ||
| 654 | compat_caddr_t chardata; /* font data in expanded form */ | ||
| 655 | }; | ||
| 656 | |||
| 657 | static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) | ||
| 658 | { | ||
| 659 | struct consolefontdesc32 __user *user_cfd = compat_ptr(arg); | ||
| 660 | struct console_font_op op; | ||
| 661 | compat_caddr_t data; | ||
| 662 | int i, perm; | ||
| 663 | |||
| 664 | perm = vt_check(file); | ||
| 665 | if (perm < 0) return perm; | ||
| 666 | |||
| 667 | switch (cmd) { | ||
| 668 | case PIO_FONTX: | ||
| 669 | if (!perm) | ||
| 670 | return -EPERM; | ||
| 671 | op.op = KD_FONT_OP_SET; | ||
| 672 | op.flags = 0; | ||
| 673 | op.width = 8; | ||
| 674 | if (get_user(op.height, &user_cfd->charheight) || | ||
| 675 | get_user(op.charcount, &user_cfd->charcount) || | ||
| 676 | get_user(data, &user_cfd->chardata)) | ||
| 677 | return -EFAULT; | ||
| 678 | op.data = compat_ptr(data); | ||
| 679 | return con_font_op(vc_cons[fg_console].d, &op); | ||
| 680 | case GIO_FONTX: | ||
| 681 | op.op = KD_FONT_OP_GET; | ||
| 682 | op.flags = 0; | ||
| 683 | op.width = 8; | ||
| 684 | if (get_user(op.height, &user_cfd->charheight) || | ||
| 685 | get_user(op.charcount, &user_cfd->charcount) || | ||
| 686 | get_user(data, &user_cfd->chardata)) | ||
| 687 | return -EFAULT; | ||
| 688 | if (!data) | ||
| 689 | return 0; | ||
| 690 | op.data = compat_ptr(data); | ||
| 691 | i = con_font_op(vc_cons[fg_console].d, &op); | ||
| 692 | if (i) | ||
| 693 | return i; | ||
| 694 | if (put_user(op.height, &user_cfd->charheight) || | ||
| 695 | put_user(op.charcount, &user_cfd->charcount) || | ||
| 696 | put_user((compat_caddr_t)(unsigned long)op.data, | ||
| 697 | &user_cfd->chardata)) | ||
| 698 | return -EFAULT; | ||
| 699 | return 0; | ||
| 700 | } | ||
| 701 | return -EINVAL; | ||
| 702 | } | ||
| 703 | |||
| 704 | struct console_font_op32 { | ||
| 705 | compat_uint_t op; /* operation code KD_FONT_OP_* */ | ||
| 706 | compat_uint_t flags; /* KD_FONT_FLAG_* */ | ||
| 707 | compat_uint_t width, height; /* font size */ | ||
| 708 | compat_uint_t charcount; | ||
| 709 | compat_caddr_t data; /* font data with height fixed to 32 */ | ||
| 710 | }; | ||
| 711 | |||
| 712 | static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) | ||
| 713 | { | ||
| 714 | struct console_font_op op; | ||
| 715 | struct console_font_op32 __user *fontop = compat_ptr(arg); | ||
| 716 | int perm = vt_check(file), i; | ||
| 717 | struct vc_data *vc; | ||
| 718 | |||
| 719 | if (perm < 0) return perm; | ||
| 720 | |||
| 721 | if (copy_from_user(&op, fontop, sizeof(struct console_font_op32))) | ||
| 722 | return -EFAULT; | ||
| 723 | if (!perm && op.op != KD_FONT_OP_GET) | ||
| 724 | return -EPERM; | ||
| 725 | op.data = compat_ptr(((struct console_font_op32 *)&op)->data); | ||
| 726 | op.flags |= KD_FONT_FLAG_OLD; | ||
| 727 | vc = ((struct tty_struct *)file->private_data)->driver_data; | ||
| 728 | i = con_font_op(vc, &op); | ||
| 729 | if (i) | ||
| 730 | return i; | ||
| 731 | ((struct console_font_op32 *)&op)->data = (unsigned long)op.data; | ||
| 732 | if (copy_to_user(fontop, &op, sizeof(struct console_font_op32))) | ||
| 733 | return -EFAULT; | ||
| 734 | return 0; | ||
| 735 | } | ||
| 736 | |||
| 737 | struct unimapdesc32 { | ||
| 738 | unsigned short entry_ct; | ||
| 739 | compat_caddr_t entries; | ||
| 740 | }; | ||
| 741 | |||
| 742 | static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) | ||
| 743 | { | ||
| 744 | struct unimapdesc32 tmp; | ||
| 745 | struct unimapdesc32 __user *user_ud = compat_ptr(arg); | ||
| 746 | int perm = vt_check(file); | ||
| 747 | struct vc_data *vc; | ||
| 748 | |||
| 749 | if (perm < 0) | ||
| 750 | return perm; | ||
| 751 | if (copy_from_user(&tmp, user_ud, sizeof tmp)) | ||
| 752 | return -EFAULT; | ||
| 753 | if (tmp.entries) | ||
| 754 | if (!access_ok(VERIFY_WRITE, compat_ptr(tmp.entries), | ||
| 755 | tmp.entry_ct*sizeof(struct unipair))) | ||
| 756 | return -EFAULT; | ||
| 757 | vc = ((struct tty_struct *)file->private_data)->driver_data; | ||
| 758 | switch (cmd) { | ||
| 759 | case PIO_UNIMAP: | ||
| 760 | if (!perm) | ||
| 761 | return -EPERM; | ||
| 762 | return con_set_unimap(vc, tmp.entry_ct, | ||
| 763 | compat_ptr(tmp.entries)); | ||
| 764 | case GIO_UNIMAP: | ||
| 765 | if (!perm && fg_console != vc->vc_num) | ||
| 766 | return -EPERM; | ||
| 767 | return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct), | ||
| 768 | compat_ptr(tmp.entries)); | ||
| 769 | } | ||
| 770 | return 0; | ||
| 771 | } | ||
| 772 | |||
| 773 | #endif /* CONFIG_VT */ | ||
| 774 | |||
| 775 | static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 776 | { | 575 | { |
| 777 | mm_segment_t old_fs = get_fs(); | 576 | mm_segment_t old_fs = get_fs(); |
| 778 | __kernel_uid_t kuid; | 577 | __kernel_uid_t kuid; |
| @@ -785,20 +584,15 @@ static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long a | |||
| 785 | set_fs(old_fs); | 584 | set_fs(old_fs); |
| 786 | 585 | ||
| 787 | if (err >= 0) | 586 | if (err >= 0) |
| 788 | err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg)); | 587 | err = put_user(kuid, argp); |
| 789 | 588 | ||
| 790 | return err; | 589 | return err; |
| 791 | } | 590 | } |
| 792 | 591 | ||
| 793 | static __used int | 592 | static int ioc_settimeout(unsigned int fd, unsigned int cmd, |
| 794 | ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg) | 593 | compat_ulong_t __user *argp) |
| 795 | { | ||
| 796 | return -EINVAL; | ||
| 797 | } | ||
| 798 | |||
| 799 | static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 800 | { | 594 | { |
| 801 | return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg); | 595 | return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, argp); |
| 802 | } | 596 | } |
| 803 | 597 | ||
| 804 | /* Bluetooth ioctls */ | 598 | /* Bluetooth ioctls */ |
| @@ -856,7 +650,8 @@ static int set_raw32_request(struct raw_config_request *req, struct raw32_config | |||
| 856 | return ret ? -EFAULT : 0; | 650 | return ret ? -EFAULT : 0; |
| 857 | } | 651 | } |
| 858 | 652 | ||
| 859 | static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | 653 | static int raw_ioctl(unsigned fd, unsigned cmd, |
| 654 | struct raw32_config_request __user *user_req) | ||
| 860 | { | 655 | { |
| 861 | int ret; | 656 | int ret; |
| 862 | 657 | ||
| @@ -864,7 +659,6 @@ static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | |||
| 864 | case RAW_SETBIND: | 659 | case RAW_SETBIND: |
| 865 | case RAW_GETBIND: { | 660 | case RAW_GETBIND: { |
| 866 | struct raw_config_request req; | 661 | struct raw_config_request req; |
| 867 | struct raw32_config_request __user *user_req = compat_ptr(arg); | ||
| 868 | mm_segment_t oldfs = get_fs(); | 662 | mm_segment_t oldfs = get_fs(); |
| 869 | 663 | ||
| 870 | if ((ret = get_raw32_request(&req, user_req))) | 664 | if ((ret = get_raw32_request(&req, user_req))) |
| @@ -879,9 +673,6 @@ static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | |||
| 879 | } | 673 | } |
| 880 | break; | 674 | break; |
| 881 | } | 675 | } |
| 882 | default: | ||
| 883 | ret = sys_ioctl(fd, cmd, arg); | ||
| 884 | break; | ||
| 885 | } | 676 | } |
| 886 | return ret; | 677 | return ret; |
| 887 | } | 678 | } |
| @@ -909,11 +700,11 @@ struct serial_struct32 { | |||
| 909 | compat_int_t reserved[1]; | 700 | compat_int_t reserved[1]; |
| 910 | }; | 701 | }; |
| 911 | 702 | ||
| 912 | static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | 703 | static int serial_struct_ioctl(unsigned fd, unsigned cmd, |
| 704 | struct serial_struct32 __user *ss32) | ||
| 913 | { | 705 | { |
| 914 | typedef struct serial_struct SS; | 706 | typedef struct serial_struct SS; |
| 915 | typedef struct serial_struct32 SS32; | 707 | typedef struct serial_struct32 SS32; |
| 916 | struct serial_struct32 __user *ss32 = compat_ptr(arg); | ||
| 917 | int err; | 708 | int err; |
| 918 | struct serial_struct ss; | 709 | struct serial_struct ss; |
| 919 | mm_segment_t oldseg = get_fs(); | 710 | mm_segment_t oldseg = get_fs(); |
| @@ -951,96 +742,6 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | |||
| 951 | return err; | 742 | return err; |
| 952 | } | 743 | } |
| 953 | 744 | ||
| 954 | struct usbdevfs_ctrltransfer32 { | ||
| 955 | u8 bRequestType; | ||
| 956 | u8 bRequest; | ||
| 957 | u16 wValue; | ||
| 958 | u16 wIndex; | ||
| 959 | u16 wLength; | ||
| 960 | u32 timeout; /* in milliseconds */ | ||
| 961 | compat_caddr_t data; | ||
| 962 | }; | ||
| 963 | |||
| 964 | #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32) | ||
| 965 | |||
| 966 | static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 967 | { | ||
| 968 | struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg); | ||
| 969 | struct usbdevfs_ctrltransfer __user *p; | ||
| 970 | __u32 udata; | ||
| 971 | p = compat_alloc_user_space(sizeof(*p)); | ||
| 972 | if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) || | ||
| 973 | get_user(udata, &p32->data) || | ||
| 974 | put_user(compat_ptr(udata), &p->data)) | ||
| 975 | return -EFAULT; | ||
| 976 | return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p); | ||
| 977 | } | ||
| 978 | |||
| 979 | |||
| 980 | struct usbdevfs_bulktransfer32 { | ||
| 981 | compat_uint_t ep; | ||
| 982 | compat_uint_t len; | ||
| 983 | compat_uint_t timeout; /* in milliseconds */ | ||
| 984 | compat_caddr_t data; | ||
| 985 | }; | ||
| 986 | |||
| 987 | #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32) | ||
| 988 | |||
| 989 | static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 990 | { | ||
| 991 | struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg); | ||
| 992 | struct usbdevfs_bulktransfer __user *p; | ||
| 993 | compat_uint_t n; | ||
| 994 | compat_caddr_t addr; | ||
| 995 | |||
| 996 | p = compat_alloc_user_space(sizeof(*p)); | ||
| 997 | |||
| 998 | if (get_user(n, &p32->ep) || put_user(n, &p->ep) || | ||
| 999 | get_user(n, &p32->len) || put_user(n, &p->len) || | ||
| 1000 | get_user(n, &p32->timeout) || put_user(n, &p->timeout) || | ||
| 1001 | get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data)) | ||
| 1002 | return -EFAULT; | ||
| 1003 | |||
| 1004 | return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p); | ||
| 1005 | } | ||
| 1006 | |||
| 1007 | |||
| 1008 | /* | ||
| 1009 | * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY | ||
| 1010 | * are handled in usbdevfs core. -Christopher Li | ||
| 1011 | */ | ||
| 1012 | |||
| 1013 | struct usbdevfs_disconnectsignal32 { | ||
| 1014 | compat_int_t signr; | ||
| 1015 | compat_caddr_t context; | ||
| 1016 | }; | ||
| 1017 | |||
| 1018 | #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32) | ||
| 1019 | |||
| 1020 | static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 1021 | { | ||
| 1022 | struct usbdevfs_disconnectsignal kdis; | ||
| 1023 | struct usbdevfs_disconnectsignal32 __user *udis; | ||
| 1024 | mm_segment_t old_fs; | ||
| 1025 | u32 uctx; | ||
| 1026 | int err; | ||
| 1027 | |||
| 1028 | udis = compat_ptr(arg); | ||
| 1029 | |||
| 1030 | if (get_user(kdis.signr, &udis->signr) || | ||
| 1031 | __get_user(uctx, &udis->context)) | ||
| 1032 | return -EFAULT; | ||
| 1033 | |||
| 1034 | kdis.context = compat_ptr(uctx); | ||
| 1035 | |||
| 1036 | old_fs = get_fs(); | ||
| 1037 | set_fs(KERNEL_DS); | ||
| 1038 | err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis); | ||
| 1039 | set_fs(old_fs); | ||
| 1040 | |||
| 1041 | return err; | ||
| 1042 | } | ||
| 1043 | |||
| 1044 | /* | 745 | /* |
| 1045 | * I2C layer ioctls | 746 | * I2C layer ioctls |
| 1046 | */ | 747 | */ |
| @@ -1069,9 +770,9 @@ struct i2c_rdwr_aligned { | |||
| 1069 | struct i2c_msg msgs[0]; | 770 | struct i2c_msg msgs[0]; |
| 1070 | }; | 771 | }; |
| 1071 | 772 | ||
| 1072 | static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | 773 | static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, |
| 774 | struct i2c_rdwr_ioctl_data32 __user *udata) | ||
| 1073 | { | 775 | { |
| 1074 | struct i2c_rdwr_ioctl_data32 __user *udata = compat_ptr(arg); | ||
| 1075 | struct i2c_rdwr_aligned __user *tdata; | 776 | struct i2c_rdwr_aligned __user *tdata; |
| 1076 | struct i2c_msg __user *tmsgs; | 777 | struct i2c_msg __user *tmsgs; |
| 1077 | struct i2c_msg32 __user *umsgs; | 778 | struct i2c_msg32 __user *umsgs; |
| @@ -1105,10 +806,10 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long ar | |||
| 1105 | return sys_ioctl(fd, cmd, (unsigned long)tdata); | 806 | return sys_ioctl(fd, cmd, (unsigned long)tdata); |
| 1106 | } | 807 | } |
| 1107 | 808 | ||
| 1108 | static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | 809 | static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, |
| 810 | struct i2c_smbus_ioctl_data32 __user *udata) | ||
| 1109 | { | 811 | { |
| 1110 | struct i2c_smbus_ioctl_data __user *tdata; | 812 | struct i2c_smbus_ioctl_data __user *tdata; |
| 1111 | struct i2c_smbus_ioctl_data32 __user *udata; | ||
| 1112 | compat_caddr_t datap; | 813 | compat_caddr_t datap; |
| 1113 | 814 | ||
| 1114 | tdata = compat_alloc_user_space(sizeof(*tdata)); | 815 | tdata = compat_alloc_user_space(sizeof(*tdata)); |
| @@ -1117,7 +818,6 @@ static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long a | |||
| 1117 | if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata))) | 818 | if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata))) |
| 1118 | return -EFAULT; | 819 | return -EFAULT; |
| 1119 | 820 | ||
| 1120 | udata = compat_ptr(arg); | ||
| 1121 | if (!access_ok(VERIFY_READ, udata, sizeof(*udata))) | 821 | if (!access_ok(VERIFY_READ, udata, sizeof(*udata))) |
| 1122 | return -EFAULT; | 822 | return -EFAULT; |
| 1123 | 823 | ||
| @@ -1137,7 +837,7 @@ static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long a | |||
| 1137 | #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t) | 837 | #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t) |
| 1138 | #define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t) | 838 | #define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t) |
| 1139 | 839 | ||
| 1140 | static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | 840 | static int rtc_ioctl(unsigned fd, unsigned cmd, void __user *argp) |
| 1141 | { | 841 | { |
| 1142 | mm_segment_t oldfs = get_fs(); | 842 | mm_segment_t oldfs = get_fs(); |
| 1143 | compat_ulong_t val32; | 843 | compat_ulong_t val32; |
| @@ -1155,29 +855,14 @@ static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | |||
| 1155 | if (ret) | 855 | if (ret) |
| 1156 | return ret; | 856 | return ret; |
| 1157 | val32 = kval; | 857 | val32 = kval; |
| 1158 | return put_user(val32, (unsigned int __user *)arg); | 858 | return put_user(val32, (unsigned int __user *)argp); |
| 1159 | case RTC_IRQP_SET32: | 859 | case RTC_IRQP_SET32: |
| 1160 | return sys_ioctl(fd, RTC_IRQP_SET, arg); | 860 | return sys_ioctl(fd, RTC_IRQP_SET, (unsigned long)argp); |
| 1161 | case RTC_EPOCH_SET32: | 861 | case RTC_EPOCH_SET32: |
| 1162 | return sys_ioctl(fd, RTC_EPOCH_SET, arg); | 862 | return sys_ioctl(fd, RTC_EPOCH_SET, (unsigned long)argp); |
| 1163 | default: | ||
| 1164 | /* unreached */ | ||
| 1165 | return -ENOIOCTLCMD; | ||
| 1166 | } | 863 | } |
| 1167 | } | ||
| 1168 | 864 | ||
| 1169 | static int | 865 | return -ENOIOCTLCMD; |
| 1170 | lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 1171 | { | ||
| 1172 | struct compat_timeval __user *tc = (struct compat_timeval __user *)arg; | ||
| 1173 | struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval)); | ||
| 1174 | struct timeval ts; | ||
| 1175 | if (get_user(ts.tv_sec, &tc->tv_sec) || | ||
| 1176 | get_user(ts.tv_usec, &tc->tv_usec) || | ||
| 1177 | put_user(ts.tv_sec, &tn->tv_sec) || | ||
| 1178 | put_user(ts.tv_usec, &tn->tv_usec)) | ||
| 1179 | return -EFAULT; | ||
| 1180 | return sys_ioctl(fd, cmd, (unsigned long)tn); | ||
| 1181 | } | 866 | } |
| 1182 | 867 | ||
| 1183 | /* on ia32 l_start is on a 32-bit boundary */ | 868 | /* on ia32 l_start is on a 32-bit boundary */ |
| @@ -1197,9 +882,9 @@ struct space_resv_32 { | |||
| 1197 | #define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32) | 882 | #define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32) |
| 1198 | 883 | ||
| 1199 | /* just account for different alignment */ | 884 | /* just account for different alignment */ |
| 1200 | static int compat_ioctl_preallocate(struct file *file, unsigned long arg) | 885 | static int compat_ioctl_preallocate(struct file *file, |
| 886 | struct space_resv_32 __user *p32) | ||
| 1201 | { | 887 | { |
| 1202 | struct space_resv_32 __user *p32 = compat_ptr(arg); | ||
| 1203 | struct space_resv __user *p = compat_alloc_user_space(sizeof(*p)); | 888 | struct space_resv __user *p = compat_alloc_user_space(sizeof(*p)); |
| 1204 | 889 | ||
| 1205 | if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) || | 890 | if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) || |
| @@ -1215,27 +900,13 @@ static int compat_ioctl_preallocate(struct file *file, unsigned long arg) | |||
| 1215 | } | 900 | } |
| 1216 | #endif | 901 | #endif |
| 1217 | 902 | ||
| 903 | /* | ||
| 904 | * simple reversible transform to make our table more evenly | ||
| 905 | * distributed after sorting. | ||
| 906 | */ | ||
| 907 | #define XFORM(i) (((i) ^ ((i) << 27) ^ ((i) << 17)) & 0xffffffff) | ||
| 1218 | 908 | ||
| 1219 | typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int, | 909 | #define COMPATIBLE_IOCTL(cmd) XFORM(cmd), |
| 1220 | unsigned long, struct file *); | ||
| 1221 | |||
| 1222 | struct ioctl_trans { | ||
| 1223 | unsigned long cmd; | ||
| 1224 | ioctl_trans_handler_t handler; | ||
| 1225 | struct ioctl_trans *next; | ||
| 1226 | }; | ||
| 1227 | |||
| 1228 | #define HANDLE_IOCTL(cmd,handler) \ | ||
| 1229 | { (cmd), (ioctl_trans_handler_t)(handler) }, | ||
| 1230 | |||
| 1231 | /* pointer to compatible structure or no argument */ | ||
| 1232 | #define COMPATIBLE_IOCTL(cmd) \ | ||
| 1233 | { (cmd), do_ioctl32_pointer }, | ||
| 1234 | |||
| 1235 | /* argument is an unsigned long integer, not a pointer */ | ||
| 1236 | #define ULONG_IOCTL(cmd) \ | ||
| 1237 | { (cmd), (ioctl_trans_handler_t)sys_ioctl }, | ||
| 1238 | |||
| 1239 | /* ioctl should not be warned about even if it's not implemented. | 910 | /* ioctl should not be warned about even if it's not implemented. |
| 1240 | Valid reasons to use this: | 911 | Valid reasons to use this: |
| 1241 | - It is implemented with ->compat_ioctl on some device, but programs | 912 | - It is implemented with ->compat_ioctl on some device, but programs |
| @@ -1245,7 +916,7 @@ struct ioctl_trans { | |||
| 1245 | Most other reasons are not valid. */ | 916 | Most other reasons are not valid. */ |
| 1246 | #define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd) | 917 | #define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd) |
| 1247 | 918 | ||
| 1248 | static struct ioctl_trans ioctl_start[] = { | 919 | static unsigned int ioctl_pointer[] = { |
| 1249 | /* compatible ioctls first */ | 920 | /* compatible ioctls first */ |
| 1250 | COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */ | 921 | COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */ |
| 1251 | COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */ | 922 | COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */ |
| @@ -1256,7 +927,6 @@ COMPATIBLE_IOCTL(TCSETA) | |||
| 1256 | COMPATIBLE_IOCTL(TCSETAW) | 927 | COMPATIBLE_IOCTL(TCSETAW) |
| 1257 | COMPATIBLE_IOCTL(TCSETAF) | 928 | COMPATIBLE_IOCTL(TCSETAF) |
| 1258 | COMPATIBLE_IOCTL(TCSBRK) | 929 | COMPATIBLE_IOCTL(TCSBRK) |
| 1259 | ULONG_IOCTL(TCSBRKP) | ||
| 1260 | COMPATIBLE_IOCTL(TCXONC) | 930 | COMPATIBLE_IOCTL(TCXONC) |
| 1261 | COMPATIBLE_IOCTL(TCFLSH) | 931 | COMPATIBLE_IOCTL(TCFLSH) |
| 1262 | COMPATIBLE_IOCTL(TCGETS) | 932 | COMPATIBLE_IOCTL(TCGETS) |
| @@ -1266,7 +936,6 @@ COMPATIBLE_IOCTL(TCSETSF) | |||
| 1266 | COMPATIBLE_IOCTL(TIOCLINUX) | 936 | COMPATIBLE_IOCTL(TIOCLINUX) |
| 1267 | COMPATIBLE_IOCTL(TIOCSBRK) | 937 | COMPATIBLE_IOCTL(TIOCSBRK) |
| 1268 | COMPATIBLE_IOCTL(TIOCCBRK) | 938 | COMPATIBLE_IOCTL(TIOCCBRK) |
| 1269 | ULONG_IOCTL(TIOCMIWAIT) | ||
| 1270 | COMPATIBLE_IOCTL(TIOCGICOUNT) | 939 | COMPATIBLE_IOCTL(TIOCGICOUNT) |
| 1271 | /* Little t */ | 940 | /* Little t */ |
| 1272 | COMPATIBLE_IOCTL(TIOCGETD) | 941 | COMPATIBLE_IOCTL(TIOCGETD) |
| @@ -1288,7 +957,6 @@ COMPATIBLE_IOCTL(TIOCSTI) | |||
| 1288 | COMPATIBLE_IOCTL(TIOCOUTQ) | 957 | COMPATIBLE_IOCTL(TIOCOUTQ) |
| 1289 | COMPATIBLE_IOCTL(TIOCSPGRP) | 958 | COMPATIBLE_IOCTL(TIOCSPGRP) |
| 1290 | COMPATIBLE_IOCTL(TIOCGPGRP) | 959 | COMPATIBLE_IOCTL(TIOCGPGRP) |
| 1291 | ULONG_IOCTL(TIOCSCTTY) | ||
| 1292 | COMPATIBLE_IOCTL(TIOCGPTN) | 960 | COMPATIBLE_IOCTL(TIOCGPTN) |
| 1293 | COMPATIBLE_IOCTL(TIOCSPTLCK) | 961 | COMPATIBLE_IOCTL(TIOCSPTLCK) |
| 1294 | COMPATIBLE_IOCTL(TIOCSERGETLSR) | 962 | COMPATIBLE_IOCTL(TIOCSERGETLSR) |
| @@ -1319,36 +987,21 @@ COMPATIBLE_IOCTL(PRINT_RAID_DEBUG) | |||
| 1319 | COMPATIBLE_IOCTL(RAID_AUTORUN) | 987 | COMPATIBLE_IOCTL(RAID_AUTORUN) |
| 1320 | COMPATIBLE_IOCTL(CLEAR_ARRAY) | 988 | COMPATIBLE_IOCTL(CLEAR_ARRAY) |
| 1321 | COMPATIBLE_IOCTL(ADD_NEW_DISK) | 989 | COMPATIBLE_IOCTL(ADD_NEW_DISK) |
| 1322 | ULONG_IOCTL(HOT_REMOVE_DISK) | ||
| 1323 | COMPATIBLE_IOCTL(SET_ARRAY_INFO) | 990 | COMPATIBLE_IOCTL(SET_ARRAY_INFO) |
| 1324 | COMPATIBLE_IOCTL(SET_DISK_INFO) | 991 | COMPATIBLE_IOCTL(SET_DISK_INFO) |
| 1325 | COMPATIBLE_IOCTL(WRITE_RAID_INFO) | 992 | COMPATIBLE_IOCTL(WRITE_RAID_INFO) |
| 1326 | COMPATIBLE_IOCTL(UNPROTECT_ARRAY) | 993 | COMPATIBLE_IOCTL(UNPROTECT_ARRAY) |
| 1327 | COMPATIBLE_IOCTL(PROTECT_ARRAY) | 994 | COMPATIBLE_IOCTL(PROTECT_ARRAY) |
| 1328 | ULONG_IOCTL(HOT_ADD_DISK) | ||
| 1329 | ULONG_IOCTL(SET_DISK_FAULTY) | ||
| 1330 | COMPATIBLE_IOCTL(RUN_ARRAY) | 995 | COMPATIBLE_IOCTL(RUN_ARRAY) |
| 1331 | COMPATIBLE_IOCTL(STOP_ARRAY) | 996 | COMPATIBLE_IOCTL(STOP_ARRAY) |
| 1332 | COMPATIBLE_IOCTL(STOP_ARRAY_RO) | 997 | COMPATIBLE_IOCTL(STOP_ARRAY_RO) |
| 1333 | COMPATIBLE_IOCTL(RESTART_ARRAY_RW) | 998 | COMPATIBLE_IOCTL(RESTART_ARRAY_RW) |
| 1334 | COMPATIBLE_IOCTL(GET_BITMAP_FILE) | 999 | COMPATIBLE_IOCTL(GET_BITMAP_FILE) |
| 1335 | ULONG_IOCTL(SET_BITMAP_FILE) | ||
| 1336 | /* Big K */ | ||
| 1337 | COMPATIBLE_IOCTL(PIO_FONT) | ||
| 1338 | COMPATIBLE_IOCTL(GIO_FONT) | ||
| 1339 | COMPATIBLE_IOCTL(PIO_CMAP) | ||
| 1340 | COMPATIBLE_IOCTL(GIO_CMAP) | ||
| 1341 | ULONG_IOCTL(KDSIGACCEPT) | ||
| 1342 | COMPATIBLE_IOCTL(KDGETKEYCODE) | 1000 | COMPATIBLE_IOCTL(KDGETKEYCODE) |
| 1343 | COMPATIBLE_IOCTL(KDSETKEYCODE) | 1001 | COMPATIBLE_IOCTL(KDSETKEYCODE) |
| 1344 | ULONG_IOCTL(KIOCSOUND) | ||
| 1345 | ULONG_IOCTL(KDMKTONE) | ||
| 1346 | COMPATIBLE_IOCTL(KDGKBTYPE) | 1002 | COMPATIBLE_IOCTL(KDGKBTYPE) |
| 1347 | ULONG_IOCTL(KDSETMODE) | ||
| 1348 | COMPATIBLE_IOCTL(KDGETMODE) | 1003 | COMPATIBLE_IOCTL(KDGETMODE) |
| 1349 | ULONG_IOCTL(KDSKBMODE) | ||
| 1350 | COMPATIBLE_IOCTL(KDGKBMODE) | 1004 | COMPATIBLE_IOCTL(KDGKBMODE) |
| 1351 | ULONG_IOCTL(KDSKBMETA) | ||
| 1352 | COMPATIBLE_IOCTL(KDGKBMETA) | 1005 | COMPATIBLE_IOCTL(KDGKBMETA) |
| 1353 | COMPATIBLE_IOCTL(KDGKBENT) | 1006 | COMPATIBLE_IOCTL(KDGKBENT) |
| 1354 | COMPATIBLE_IOCTL(KDSKBENT) | 1007 | COMPATIBLE_IOCTL(KDSKBENT) |
| @@ -1358,15 +1011,7 @@ COMPATIBLE_IOCTL(KDGKBDIACR) | |||
| 1358 | COMPATIBLE_IOCTL(KDSKBDIACR) | 1011 | COMPATIBLE_IOCTL(KDSKBDIACR) |
| 1359 | COMPATIBLE_IOCTL(KDKBDREP) | 1012 | COMPATIBLE_IOCTL(KDKBDREP) |
| 1360 | COMPATIBLE_IOCTL(KDGKBLED) | 1013 | COMPATIBLE_IOCTL(KDGKBLED) |
| 1361 | ULONG_IOCTL(KDSKBLED) | ||
| 1362 | COMPATIBLE_IOCTL(KDGETLED) | 1014 | COMPATIBLE_IOCTL(KDGETLED) |
| 1363 | ULONG_IOCTL(KDSETLED) | ||
| 1364 | COMPATIBLE_IOCTL(GIO_SCRNMAP) | ||
| 1365 | COMPATIBLE_IOCTL(PIO_SCRNMAP) | ||
| 1366 | COMPATIBLE_IOCTL(GIO_UNISCRNMAP) | ||
| 1367 | COMPATIBLE_IOCTL(PIO_UNISCRNMAP) | ||
| 1368 | COMPATIBLE_IOCTL(PIO_FONTRESET) | ||
| 1369 | COMPATIBLE_IOCTL(PIO_UNIMAPCLR) | ||
| 1370 | #ifdef CONFIG_BLOCK | 1015 | #ifdef CONFIG_BLOCK |
| 1371 | /* Big S */ | 1016 | /* Big S */ |
| 1372 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) | 1017 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) |
| @@ -1378,20 +1023,6 @@ COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND) | |||
| 1378 | COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST) | 1023 | COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST) |
| 1379 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI) | 1024 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI) |
| 1380 | #endif | 1025 | #endif |
| 1381 | /* Big V */ | ||
| 1382 | COMPATIBLE_IOCTL(VT_SETMODE) | ||
| 1383 | COMPATIBLE_IOCTL(VT_GETMODE) | ||
| 1384 | COMPATIBLE_IOCTL(VT_GETSTATE) | ||
| 1385 | COMPATIBLE_IOCTL(VT_OPENQRY) | ||
| 1386 | ULONG_IOCTL(VT_ACTIVATE) | ||
| 1387 | ULONG_IOCTL(VT_WAITACTIVE) | ||
| 1388 | ULONG_IOCTL(VT_RELDISP) | ||
| 1389 | ULONG_IOCTL(VT_DISALLOCATE) | ||
| 1390 | COMPATIBLE_IOCTL(VT_RESIZE) | ||
| 1391 | COMPATIBLE_IOCTL(VT_RESIZEX) | ||
| 1392 | COMPATIBLE_IOCTL(VT_LOCKSWITCH) | ||
| 1393 | COMPATIBLE_IOCTL(VT_UNLOCKSWITCH) | ||
| 1394 | COMPATIBLE_IOCTL(VT_GETHIFONTMASK) | ||
| 1395 | /* Little p (/dev/rtc, /dev/envctrl, etc.) */ | 1026 | /* Little p (/dev/rtc, /dev/envctrl, etc.) */ |
| 1396 | COMPATIBLE_IOCTL(RTC_AIE_ON) | 1027 | COMPATIBLE_IOCTL(RTC_AIE_ON) |
| 1397 | COMPATIBLE_IOCTL(RTC_AIE_OFF) | 1028 | COMPATIBLE_IOCTL(RTC_AIE_OFF) |
| @@ -1420,11 +1051,12 @@ COMPATIBLE_IOCTL(MTIOCTOP) | |||
| 1420 | /* Socket level stuff */ | 1051 | /* Socket level stuff */ |
| 1421 | COMPATIBLE_IOCTL(FIOQSIZE) | 1052 | COMPATIBLE_IOCTL(FIOQSIZE) |
| 1422 | #ifdef CONFIG_BLOCK | 1053 | #ifdef CONFIG_BLOCK |
| 1054 | /* loop */ | ||
| 1055 | IGNORE_IOCTL(LOOP_CLR_FD) | ||
| 1423 | /* SG stuff */ | 1056 | /* SG stuff */ |
| 1424 | COMPATIBLE_IOCTL(SG_SET_TIMEOUT) | 1057 | COMPATIBLE_IOCTL(SG_SET_TIMEOUT) |
| 1425 | COMPATIBLE_IOCTL(SG_GET_TIMEOUT) | 1058 | COMPATIBLE_IOCTL(SG_GET_TIMEOUT) |
| 1426 | COMPATIBLE_IOCTL(SG_EMULATED_HOST) | 1059 | COMPATIBLE_IOCTL(SG_EMULATED_HOST) |
| 1427 | ULONG_IOCTL(SG_SET_TRANSFORM) | ||
| 1428 | COMPATIBLE_IOCTL(SG_GET_TRANSFORM) | 1060 | COMPATIBLE_IOCTL(SG_GET_TRANSFORM) |
| 1429 | COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE) | 1061 | COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE) |
| 1430 | COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE) | 1062 | COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE) |
| @@ -1478,8 +1110,6 @@ COMPATIBLE_IOCTL(PPPIOCGCHAN) | |||
| 1478 | /* PPPOX */ | 1110 | /* PPPOX */ |
| 1479 | COMPATIBLE_IOCTL(PPPOEIOCSFWD) | 1111 | COMPATIBLE_IOCTL(PPPOEIOCSFWD) |
| 1480 | COMPATIBLE_IOCTL(PPPOEIOCDFWD) | 1112 | COMPATIBLE_IOCTL(PPPOEIOCDFWD) |
| 1481 | /* LP */ | ||
| 1482 | COMPATIBLE_IOCTL(LPGETSTATUS) | ||
| 1483 | /* ppdev */ | 1113 | /* ppdev */ |
| 1484 | COMPATIBLE_IOCTL(PPSETMODE) | 1114 | COMPATIBLE_IOCTL(PPSETMODE) |
| 1485 | COMPATIBLE_IOCTL(PPRSTATUS) | 1115 | COMPATIBLE_IOCTL(PPRSTATUS) |
| @@ -1661,8 +1291,6 @@ COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS) | |||
| 1661 | COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS) | 1291 | COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS) |
| 1662 | COMPATIBLE_IOCTL(OSS_GETVERSION) | 1292 | COMPATIBLE_IOCTL(OSS_GETVERSION) |
| 1663 | /* AUTOFS */ | 1293 | /* AUTOFS */ |
| 1664 | ULONG_IOCTL(AUTOFS_IOC_READY) | ||
| 1665 | ULONG_IOCTL(AUTOFS_IOC_FAIL) | ||
| 1666 | COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC) | 1294 | COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC) |
| 1667 | COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER) | 1295 | COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER) |
| 1668 | COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE) | 1296 | COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE) |
| @@ -1755,30 +1383,11 @@ COMPATIBLE_IOCTL(PCIIOC_CONTROLLER) | |||
| 1755 | COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO) | 1383 | COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO) |
| 1756 | COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM) | 1384 | COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM) |
| 1757 | COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE) | 1385 | COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE) |
| 1758 | /* USB */ | ||
| 1759 | COMPATIBLE_IOCTL(USBDEVFS_RESETEP) | ||
| 1760 | COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE) | ||
| 1761 | COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION) | ||
| 1762 | COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER) | ||
| 1763 | COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB) | ||
| 1764 | COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE) | ||
| 1765 | COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE) | ||
| 1766 | COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO) | ||
| 1767 | COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO) | ||
| 1768 | COMPATIBLE_IOCTL(USBDEVFS_RESET) | ||
| 1769 | COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32) | ||
| 1770 | COMPATIBLE_IOCTL(USBDEVFS_REAPURB32) | ||
| 1771 | COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32) | ||
| 1772 | COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT) | ||
| 1773 | /* NBD */ | 1386 | /* NBD */ |
| 1774 | ULONG_IOCTL(NBD_SET_SOCK) | ||
| 1775 | ULONG_IOCTL(NBD_SET_BLKSIZE) | ||
| 1776 | ULONG_IOCTL(NBD_SET_SIZE) | ||
| 1777 | COMPATIBLE_IOCTL(NBD_DO_IT) | 1387 | COMPATIBLE_IOCTL(NBD_DO_IT) |
| 1778 | COMPATIBLE_IOCTL(NBD_CLEAR_SOCK) | 1388 | COMPATIBLE_IOCTL(NBD_CLEAR_SOCK) |
| 1779 | COMPATIBLE_IOCTL(NBD_CLEAR_QUE) | 1389 | COMPATIBLE_IOCTL(NBD_CLEAR_QUE) |
| 1780 | COMPATIBLE_IOCTL(NBD_PRINT_DEBUG) | 1390 | COMPATIBLE_IOCTL(NBD_PRINT_DEBUG) |
| 1781 | ULONG_IOCTL(NBD_SET_SIZE_BLOCKS) | ||
| 1782 | COMPATIBLE_IOCTL(NBD_DISCONNECT) | 1391 | COMPATIBLE_IOCTL(NBD_DISCONNECT) |
| 1783 | /* i2c */ | 1392 | /* i2c */ |
| 1784 | COMPATIBLE_IOCTL(I2C_SLAVE) | 1393 | COMPATIBLE_IOCTL(I2C_SLAVE) |
| @@ -1878,42 +1487,6 @@ COMPATIBLE_IOCTL(JSIOCGAXES) | |||
| 1878 | COMPATIBLE_IOCTL(JSIOCGBUTTONS) | 1487 | COMPATIBLE_IOCTL(JSIOCGBUTTONS) |
| 1879 | COMPATIBLE_IOCTL(JSIOCGNAME(0)) | 1488 | COMPATIBLE_IOCTL(JSIOCGNAME(0)) |
| 1880 | 1489 | ||
| 1881 | /* now things that need handlers */ | ||
| 1882 | #ifdef CONFIG_BLOCK | ||
| 1883 | HANDLE_IOCTL(SG_IO,sg_ioctl_trans) | ||
| 1884 | HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans) | ||
| 1885 | #endif | ||
| 1886 | HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans) | ||
| 1887 | HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans) | ||
| 1888 | HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans) | ||
| 1889 | HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans) | ||
| 1890 | #ifdef CONFIG_BLOCK | ||
| 1891 | HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans) | ||
| 1892 | HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans) | ||
| 1893 | #endif | ||
| 1894 | #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int) | ||
| 1895 | HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout) | ||
| 1896 | #ifdef CONFIG_VT | ||
| 1897 | HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl) | ||
| 1898 | HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl) | ||
| 1899 | HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl) | ||
| 1900 | HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl) | ||
| 1901 | HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl) | ||
| 1902 | #endif | ||
| 1903 | /* One SMB ioctl needs translations. */ | ||
| 1904 | #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) | ||
| 1905 | HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid) | ||
| 1906 | /* block stuff */ | ||
| 1907 | #ifdef CONFIG_BLOCK | ||
| 1908 | /* loop */ | ||
| 1909 | IGNORE_IOCTL(LOOP_CLR_FD) | ||
| 1910 | /* Raw devices */ | ||
| 1911 | HANDLE_IOCTL(RAW_SETBIND, raw_ioctl) | ||
| 1912 | HANDLE_IOCTL(RAW_GETBIND, raw_ioctl) | ||
| 1913 | #endif | ||
| 1914 | /* Serial */ | ||
| 1915 | HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl) | ||
| 1916 | HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl) | ||
| 1917 | #ifdef TIOCGLTC | 1490 | #ifdef TIOCGLTC |
| 1918 | COMPATIBLE_IOCTL(TIOCGLTC) | 1491 | COMPATIBLE_IOCTL(TIOCGLTC) |
| 1919 | COMPATIBLE_IOCTL(TIOCSLTC) | 1492 | COMPATIBLE_IOCTL(TIOCSLTC) |
| @@ -1928,39 +1501,6 @@ COMPATIBLE_IOCTL(TIOCSLTC) | |||
| 1928 | COMPATIBLE_IOCTL(TIOCSTART) | 1501 | COMPATIBLE_IOCTL(TIOCSTART) |
| 1929 | COMPATIBLE_IOCTL(TIOCSTOP) | 1502 | COMPATIBLE_IOCTL(TIOCSTOP) |
| 1930 | #endif | 1503 | #endif |
| 1931 | /* Usbdevfs */ | ||
| 1932 | HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control) | ||
| 1933 | HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk) | ||
| 1934 | HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal) | ||
| 1935 | COMPATIBLE_IOCTL(USBDEVFS_IOCTL32) | ||
| 1936 | /* i2c */ | ||
| 1937 | HANDLE_IOCTL(I2C_FUNCS, w_long) | ||
| 1938 | HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl) | ||
| 1939 | HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl) | ||
| 1940 | /* Not implemented in the native kernel */ | ||
| 1941 | HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl) | ||
| 1942 | HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl) | ||
| 1943 | HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl) | ||
| 1944 | HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl) | ||
| 1945 | |||
| 1946 | /* dvb */ | ||
| 1947 | HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event) | ||
| 1948 | HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture) | ||
| 1949 | HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette) | ||
| 1950 | |||
| 1951 | /* parport */ | ||
| 1952 | COMPATIBLE_IOCTL(LPTIME) | ||
| 1953 | COMPATIBLE_IOCTL(LPCHAR) | ||
| 1954 | COMPATIBLE_IOCTL(LPABORTOPEN) | ||
| 1955 | COMPATIBLE_IOCTL(LPCAREFUL) | ||
| 1956 | COMPATIBLE_IOCTL(LPWAIT) | ||
| 1957 | COMPATIBLE_IOCTL(LPSETIRQ) | ||
| 1958 | COMPATIBLE_IOCTL(LPGETSTATUS) | ||
| 1959 | COMPATIBLE_IOCTL(LPGETSTATUS) | ||
| 1960 | COMPATIBLE_IOCTL(LPRESET) | ||
| 1961 | /*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/ | ||
| 1962 | COMPATIBLE_IOCTL(LPGETFLAGS) | ||
| 1963 | HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans) | ||
| 1964 | 1504 | ||
| 1965 | /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl, | 1505 | /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl, |
| 1966 | but we don't want warnings on other file systems. So declare | 1506 | but we don't want warnings on other file systems. So declare |
| @@ -1988,12 +1528,110 @@ IGNORE_IOCTL(FBIOGCURSOR32) | |||
| 1988 | #endif | 1528 | #endif |
| 1989 | }; | 1529 | }; |
| 1990 | 1530 | ||
| 1991 | #define IOCTL_HASHSIZE 256 | 1531 | /* |
| 1992 | static struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE]; | 1532 | * Convert common ioctl arguments based on their command number |
| 1993 | 1533 | * | |
| 1994 | static inline unsigned long ioctl32_hash(unsigned long cmd) | 1534 | * Please do not add any code in here. Instead, implement |
| 1535 | * a compat_ioctl operation in the place that handleѕ the | ||
| 1536 | * ioctl for the native case. | ||
| 1537 | */ | ||
| 1538 | static long do_ioctl_trans(int fd, unsigned int cmd, | ||
| 1539 | unsigned long arg, struct file *file) | ||
| 1995 | { | 1540 | { |
| 1996 | return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE; | 1541 | void __user *argp = compat_ptr(arg); |
| 1542 | |||
| 1543 | switch (cmd) { | ||
| 1544 | case PPPIOCGIDLE32: | ||
| 1545 | return ppp_gidle(fd, cmd, argp); | ||
| 1546 | case PPPIOCSCOMPRESS32: | ||
| 1547 | return ppp_scompress(fd, cmd, argp); | ||
| 1548 | case PPPIOCSPASS32: | ||
| 1549 | case PPPIOCSACTIVE32: | ||
| 1550 | return ppp_sock_fprog_ioctl_trans(fd, cmd, argp); | ||
| 1551 | #ifdef CONFIG_BLOCK | ||
| 1552 | case SG_IO: | ||
| 1553 | return sg_ioctl_trans(fd, cmd, argp); | ||
| 1554 | case SG_GET_REQUEST_TABLE: | ||
| 1555 | return sg_grt_trans(fd, cmd, argp); | ||
| 1556 | case MTIOCGET32: | ||
| 1557 | case MTIOCPOS32: | ||
| 1558 | return mt_ioctl_trans(fd, cmd, argp); | ||
| 1559 | /* Raw devices */ | ||
| 1560 | case RAW_SETBIND: | ||
| 1561 | case RAW_GETBIND: | ||
| 1562 | return raw_ioctl(fd, cmd, argp); | ||
| 1563 | #endif | ||
| 1564 | #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int) | ||
| 1565 | case AUTOFS_IOC_SETTIMEOUT32: | ||
| 1566 | return ioc_settimeout(fd, cmd, argp); | ||
| 1567 | /* One SMB ioctl needs translations. */ | ||
| 1568 | #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) | ||
| 1569 | case SMB_IOC_GETMOUNTUID_32: | ||
| 1570 | return do_smb_getmountuid(fd, cmd, argp); | ||
| 1571 | /* Serial */ | ||
| 1572 | case TIOCGSERIAL: | ||
| 1573 | case TIOCSSERIAL: | ||
| 1574 | return serial_struct_ioctl(fd, cmd, argp); | ||
| 1575 | /* i2c */ | ||
| 1576 | case I2C_FUNCS: | ||
| 1577 | return w_long(fd, cmd, argp); | ||
| 1578 | case I2C_RDWR: | ||
| 1579 | return do_i2c_rdwr_ioctl(fd, cmd, argp); | ||
| 1580 | case I2C_SMBUS: | ||
| 1581 | return do_i2c_smbus_ioctl(fd, cmd, argp); | ||
| 1582 | /* Not implemented in the native kernel */ | ||
| 1583 | case RTC_IRQP_READ32: | ||
| 1584 | case RTC_IRQP_SET32: | ||
| 1585 | case RTC_EPOCH_READ32: | ||
| 1586 | case RTC_EPOCH_SET32: | ||
| 1587 | return rtc_ioctl(fd, cmd, argp); | ||
| 1588 | |||
| 1589 | /* dvb */ | ||
| 1590 | case VIDEO_GET_EVENT: | ||
| 1591 | return do_video_get_event(fd, cmd, argp); | ||
| 1592 | case VIDEO_STILLPICTURE: | ||
| 1593 | return do_video_stillpicture(fd, cmd, argp); | ||
| 1594 | case VIDEO_SET_SPU_PALETTE: | ||
| 1595 | return do_video_set_spu_palette(fd, cmd, argp); | ||
| 1596 | } | ||
| 1597 | |||
| 1598 | /* | ||
| 1599 | * These take an integer instead of a pointer as 'arg', | ||
| 1600 | * so we must not do a compat_ptr() translation. | ||
| 1601 | */ | ||
| 1602 | switch (cmd) { | ||
| 1603 | /* Big T */ | ||
| 1604 | case TCSBRKP: | ||
| 1605 | case TIOCMIWAIT: | ||
| 1606 | case TIOCSCTTY: | ||
| 1607 | /* RAID */ | ||
| 1608 | case HOT_REMOVE_DISK: | ||
| 1609 | case HOT_ADD_DISK: | ||
| 1610 | case SET_DISK_FAULTY: | ||
| 1611 | case SET_BITMAP_FILE: | ||
| 1612 | /* Big K */ | ||
| 1613 | case KDSIGACCEPT: | ||
| 1614 | case KIOCSOUND: | ||
| 1615 | case KDMKTONE: | ||
| 1616 | case KDSETMODE: | ||
| 1617 | case KDSKBMODE: | ||
| 1618 | case KDSKBMETA: | ||
| 1619 | case KDSKBLED: | ||
| 1620 | case KDSETLED: | ||
| 1621 | /* SG stuff */ | ||
| 1622 | case SG_SET_TRANSFORM: | ||
| 1623 | /* AUTOFS */ | ||
| 1624 | case AUTOFS_IOC_READY: | ||
| 1625 | case AUTOFS_IOC_FAIL: | ||
| 1626 | /* NBD */ | ||
| 1627 | case NBD_SET_SOCK: | ||
| 1628 | case NBD_SET_BLKSIZE: | ||
| 1629 | case NBD_SET_SIZE: | ||
| 1630 | case NBD_SET_SIZE_BLOCKS: | ||
| 1631 | return do_vfs_ioctl(file, fd, cmd, arg); | ||
| 1632 | } | ||
| 1633 | |||
| 1634 | return -ENOIOCTLCMD; | ||
| 1997 | } | 1635 | } |
| 1998 | 1636 | ||
| 1999 | static void compat_ioctl_error(struct file *filp, unsigned int fd, | 1637 | static void compat_ioctl_error(struct file *filp, unsigned int fd, |
| @@ -2025,12 +1663,33 @@ static void compat_ioctl_error(struct file *filp, unsigned int fd, | |||
| 2025 | free_page((unsigned long)path); | 1663 | free_page((unsigned long)path); |
| 2026 | } | 1664 | } |
| 2027 | 1665 | ||
| 1666 | static int compat_ioctl_check_table(unsigned int xcmd) | ||
| 1667 | { | ||
| 1668 | int i; | ||
| 1669 | const int max = ARRAY_SIZE(ioctl_pointer) - 1; | ||
| 1670 | |||
| 1671 | BUILD_BUG_ON(max >= (1 << 16)); | ||
| 1672 | |||
| 1673 | /* guess initial offset into table, assuming a | ||
| 1674 | normalized distribution */ | ||
| 1675 | i = ((xcmd >> 16) * max) >> 16; | ||
| 1676 | |||
| 1677 | /* do linear search up first, until greater or equal */ | ||
| 1678 | while (ioctl_pointer[i] < xcmd && i < max) | ||
| 1679 | i++; | ||
| 1680 | |||
| 1681 | /* then do linear search down */ | ||
| 1682 | while (ioctl_pointer[i] > xcmd && i > 0) | ||
| 1683 | i--; | ||
| 1684 | |||
| 1685 | return ioctl_pointer[i] == xcmd; | ||
| 1686 | } | ||
| 1687 | |||
| 2028 | asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | 1688 | asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, |
| 2029 | unsigned long arg) | 1689 | unsigned long arg) |
| 2030 | { | 1690 | { |
| 2031 | struct file *filp; | 1691 | struct file *filp; |
| 2032 | int error = -EBADF; | 1692 | int error = -EBADF; |
| 2033 | struct ioctl_trans *t; | ||
| 2034 | int fput_needed; | 1693 | int fput_needed; |
| 2035 | 1694 | ||
| 2036 | filp = fget_light(fd, &fput_needed); | 1695 | filp = fget_light(fd, &fput_needed); |
| @@ -2058,7 +1717,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
| 2058 | #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) | 1717 | #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) |
| 2059 | case FS_IOC_RESVSP_32: | 1718 | case FS_IOC_RESVSP_32: |
| 2060 | case FS_IOC_RESVSP64_32: | 1719 | case FS_IOC_RESVSP64_32: |
| 2061 | error = compat_ioctl_preallocate(filp, arg); | 1720 | error = compat_ioctl_preallocate(filp, compat_ptr(arg)); |
| 2062 | goto out_fput; | 1721 | goto out_fput; |
| 2063 | #else | 1722 | #else |
| 2064 | case FS_IOC_RESVSP: | 1723 | case FS_IOC_RESVSP: |
| @@ -2087,12 +1746,11 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
| 2087 | break; | 1746 | break; |
| 2088 | } | 1747 | } |
| 2089 | 1748 | ||
| 2090 | for (t = ioctl32_hash_table[ioctl32_hash(cmd)]; t; t = t->next) { | 1749 | if (compat_ioctl_check_table(XFORM(cmd))) |
| 2091 | if (t->cmd == cmd) | 1750 | goto found_handler; |
| 2092 | goto found_handler; | ||
| 2093 | } | ||
| 2094 | 1751 | ||
| 2095 | { | 1752 | error = do_ioctl_trans(fd, cmd, arg, filp); |
| 1753 | if (error == -ENOIOCTLCMD) { | ||
| 2096 | static int count; | 1754 | static int count; |
| 2097 | 1755 | ||
| 2098 | if (++count <= 50) | 1756 | if (++count <= 50) |
| @@ -2103,13 +1761,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
| 2103 | goto out_fput; | 1761 | goto out_fput; |
| 2104 | 1762 | ||
| 2105 | found_handler: | 1763 | found_handler: |
| 2106 | if (t->handler) { | 1764 | arg = (unsigned long)compat_ptr(arg); |
| 2107 | lock_kernel(); | ||
| 2108 | error = t->handler(fd, cmd, arg, filp); | ||
| 2109 | unlock_kernel(); | ||
| 2110 | goto out_fput; | ||
| 2111 | } | ||
| 2112 | |||
| 2113 | do_ioctl: | 1765 | do_ioctl: |
| 2114 | error = do_vfs_ioctl(filp, fd, cmd, arg); | 1766 | error = do_vfs_ioctl(filp, fd, cmd, arg); |
| 2115 | out_fput: | 1767 | out_fput: |
| @@ -2118,35 +1770,22 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
| 2118 | return error; | 1770 | return error; |
| 2119 | } | 1771 | } |
| 2120 | 1772 | ||
| 2121 | static void ioctl32_insert_translation(struct ioctl_trans *trans) | 1773 | static int __init init_sys32_ioctl_cmp(const void *p, const void *q) |
| 2122 | { | 1774 | { |
| 2123 | unsigned long hash; | 1775 | unsigned int a, b; |
| 2124 | struct ioctl_trans *t; | 1776 | a = *(unsigned int *)p; |
| 2125 | 1777 | b = *(unsigned int *)q; | |
| 2126 | hash = ioctl32_hash (trans->cmd); | 1778 | if (a > b) |
| 2127 | if (!ioctl32_hash_table[hash]) | 1779 | return 1; |
| 2128 | ioctl32_hash_table[hash] = trans; | 1780 | if (a < b) |
| 2129 | else { | 1781 | return -1; |
| 2130 | t = ioctl32_hash_table[hash]; | 1782 | return 0; |
| 2131 | while (t->next) | ||
| 2132 | t = t->next; | ||
| 2133 | trans->next = NULL; | ||
| 2134 | t->next = trans; | ||
| 2135 | } | ||
| 2136 | } | 1783 | } |
| 2137 | 1784 | ||
| 2138 | static int __init init_sys32_ioctl(void) | 1785 | static int __init init_sys32_ioctl(void) |
| 2139 | { | 1786 | { |
| 2140 | int i; | 1787 | sort(ioctl_pointer, ARRAY_SIZE(ioctl_pointer), sizeof(*ioctl_pointer), |
| 2141 | 1788 | init_sys32_ioctl_cmp, NULL); | |
| 2142 | for (i = 0; i < ARRAY_SIZE(ioctl_start); i++) { | ||
| 2143 | if (ioctl_start[i].next) { | ||
| 2144 | printk("ioctl translation %d bad\n",i); | ||
| 2145 | return -1; | ||
| 2146 | } | ||
| 2147 | |||
| 2148 | ioctl32_insert_translation(&ioctl_start[i]); | ||
| 2149 | } | ||
| 2150 | return 0; | 1789 | return 0; |
| 2151 | } | 1790 | } |
| 2152 | __initcall(init_sys32_ioctl); | 1791 | __initcall(init_sys32_ioctl); |
diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h index b2a7d8ba6ee3..15591d2ea400 100644 --- a/include/linux/usbdevice_fs.h +++ b/include/linux/usbdevice_fs.h | |||
| @@ -128,6 +128,29 @@ struct usbdevfs_hub_portinfo { | |||
| 128 | #ifdef __KERNEL__ | 128 | #ifdef __KERNEL__ |
| 129 | #ifdef CONFIG_COMPAT | 129 | #ifdef CONFIG_COMPAT |
| 130 | #include <linux/compat.h> | 130 | #include <linux/compat.h> |
| 131 | |||
| 132 | struct usbdevfs_ctrltransfer32 { | ||
| 133 | u8 bRequestType; | ||
| 134 | u8 bRequest; | ||
| 135 | u16 wValue; | ||
| 136 | u16 wIndex; | ||
| 137 | u16 wLength; | ||
| 138 | u32 timeout; /* in milliseconds */ | ||
| 139 | compat_caddr_t data; | ||
| 140 | }; | ||
| 141 | |||
| 142 | struct usbdevfs_bulktransfer32 { | ||
| 143 | compat_uint_t ep; | ||
| 144 | compat_uint_t len; | ||
| 145 | compat_uint_t timeout; /* in milliseconds */ | ||
| 146 | compat_caddr_t data; | ||
| 147 | }; | ||
| 148 | |||
| 149 | struct usbdevfs_disconnectsignal32 { | ||
| 150 | compat_int_t signr; | ||
| 151 | compat_caddr_t context; | ||
| 152 | }; | ||
| 153 | |||
| 131 | struct usbdevfs_urb32 { | 154 | struct usbdevfs_urb32 { |
| 132 | unsigned char type; | 155 | unsigned char type; |
| 133 | unsigned char endpoint; | 156 | unsigned char endpoint; |
| @@ -153,7 +176,9 @@ struct usbdevfs_ioctl32 { | |||
| 153 | #endif /* __KERNEL__ */ | 176 | #endif /* __KERNEL__ */ |
| 154 | 177 | ||
| 155 | #define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer) | 178 | #define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer) |
| 179 | #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32) | ||
| 156 | #define USBDEVFS_BULK _IOWR('U', 2, struct usbdevfs_bulktransfer) | 180 | #define USBDEVFS_BULK _IOWR('U', 2, struct usbdevfs_bulktransfer) |
| 181 | #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32) | ||
| 157 | #define USBDEVFS_RESETEP _IOR('U', 3, unsigned int) | 182 | #define USBDEVFS_RESETEP _IOR('U', 3, unsigned int) |
| 158 | #define USBDEVFS_SETINTERFACE _IOR('U', 4, struct usbdevfs_setinterface) | 183 | #define USBDEVFS_SETINTERFACE _IOR('U', 4, struct usbdevfs_setinterface) |
| 159 | #define USBDEVFS_SETCONFIGURATION _IOR('U', 5, unsigned int) | 184 | #define USBDEVFS_SETCONFIGURATION _IOR('U', 5, unsigned int) |
| @@ -166,6 +191,7 @@ struct usbdevfs_ioctl32 { | |||
| 166 | #define USBDEVFS_REAPURBNDELAY _IOW('U', 13, void *) | 191 | #define USBDEVFS_REAPURBNDELAY _IOW('U', 13, void *) |
| 167 | #define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, __u32) | 192 | #define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, __u32) |
| 168 | #define USBDEVFS_DISCSIGNAL _IOR('U', 14, struct usbdevfs_disconnectsignal) | 193 | #define USBDEVFS_DISCSIGNAL _IOR('U', 14, struct usbdevfs_disconnectsignal) |
| 194 | #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32) | ||
| 169 | #define USBDEVFS_CLAIMINTERFACE _IOR('U', 15, unsigned int) | 195 | #define USBDEVFS_CLAIMINTERFACE _IOR('U', 15, unsigned int) |
| 170 | #define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int) | 196 | #define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int) |
| 171 | #define USBDEVFS_CONNECTINFO _IOW('U', 17, struct usbdevfs_connectinfo) | 197 | #define USBDEVFS_CONNECTINFO _IOW('U', 17, struct usbdevfs_connectinfo) |
